Skip to content

Commit

Permalink
Merge pull request #46 from bytedance/add-chmod-rule
Browse files Browse the repository at this point in the history
Combine similar syscalls in the `disable-chmod-x-bit` rule
  • Loading branch information
Danny-Wei authored Mar 28, 2024
2 parents 07b4c34 + daa0c5b commit b4e7da1
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 b4e7da1

Please sign in to comment.