Skip to content

Commit

Permalink
Combine similar syscalls in the disable-chmod-x-bit rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny-Wei committed Mar 27, 2024
1 parent 38826e3 commit daa0c5b
Showing 1 changed file with 3 additions and 53 deletions.
56 changes: 3 additions & 53 deletions internal/profile/seccomp/seccomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,33 +77,8 @@ func generateAttackProtectionRules(rule string, profile *specs.LinuxSeccomp) {

switch rule {
case "disable-chmod-x-bit":
fchmodat2 := specs.LinuxSyscall{
Names: []string{"fchmodat2"},
Action: specs.ActErrno,
Args: []specs.LinuxSeccompArg{
{
Index: 2,
Value: unix.S_IXUSR,
ValueTwo: unix.S_IXUSR,
Op: specs.OpMaskedEqual,
},
{
Index: 2,
Value: unix.S_IXGRP,
ValueTwo: unix.S_IXGRP,
Op: specs.OpMaskedEqual,
},
{
Index: 2,
Value: unix.S_IXOTH,
ValueTwo: unix.S_IXOTH,
Op: specs.OpMaskedEqual,
},
},
}

fchmodat := specs.LinuxSyscall{
Names: []string{"fchmodat"},
Names: []string{"fchmodat", "fchmodat2"},
Action: specs.ActErrno,
Args: []specs.LinuxSeccompArg{
{
Expand All @@ -127,33 +102,8 @@ func generateAttackProtectionRules(rule string, profile *specs.LinuxSeccomp) {
},
}

fchmod := specs.LinuxSyscall{
Names: []string{"fchmod"},
Action: specs.ActErrno,
Args: []specs.LinuxSeccompArg{
{
Index: 1,
Value: unix.S_IXUSR,
ValueTwo: unix.S_IXUSR,
Op: specs.OpMaskedEqual,
},
{
Index: 1,
Value: unix.S_IXGRP,
ValueTwo: unix.S_IXGRP,
Op: specs.OpMaskedEqual,
},
{
Index: 1,
Value: unix.S_IXOTH,
ValueTwo: unix.S_IXOTH,
Op: specs.OpMaskedEqual,
},
},
}

chmod := specs.LinuxSyscall{
Names: []string{"chmod"},
Names: []string{"chmod", "fchmod"},
Action: specs.ActErrno,
Args: []specs.LinuxSeccompArg{
{
Expand All @@ -177,7 +127,7 @@ func generateAttackProtectionRules(rule string, profile *specs.LinuxSeccomp) {
},
}

profile.Syscalls = append(profile.Syscalls, fchmodat2, fchmodat, fchmod, chmod)
profile.Syscalls = append(profile.Syscalls, fchmodat, chmod)
}
}

Expand Down

0 comments on commit daa0c5b

Please sign in to comment.