Skip to content

Commit 95acdd8

Browse files
committed
rule.Rule.Build: Don't assume that no syscalls means all syscalls
Rule.Build assumes that if no syscalls are specified they all are set. This is really only the case when the exit list is used since the syscall numbers aren't available in the other lists. When we assume that all of the syscalls are enabled, we end up generating wireformat rules for e.g. 'task,never' that have all of the syscall bits set. That doesn't match what is already used when 'auditctl -a task,never' is used. It may be ignored by the kernel when such a rule is added, but it would cause problems when that rule is deleted.
1 parent d7bead3 commit 95acdd8

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

rule/rule.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,22 @@ const (
4141

4242
// Build builds an audit rule.
4343
func Build(rule Rule) (WireFormat, error) {
44-
data := &ruleData{allSyscalls: true}
44+
data := &ruleData{}
4545
var err error
4646

4747
switch v := rule.(type) {
4848
case *SyscallRule:
4949
if err = data.setList(v.List); err != nil {
5050
return nil, err
5151
}
52+
53+
// While it's possible to set syscalls on lists other than the 'exit' list
54+
// they don't actually do anything since the syscall information isn't
55+
// available at that time. Don't assume that all syscalls are enabled.
56+
if data.flags == exitFilter {
57+
data.allSyscalls = true
58+
}
59+
5260
if err = data.setAction(v.Action); err != nil {
5361
return nil, err
5462
}

0 commit comments

Comments
 (0)