diff options
author | Richard Guy Briggs <rgb@redhat.com> | 2019-05-09 20:01:36 -0400 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2019-05-23 21:07:30 -0400 |
commit | bf361231c295d92a28ca283ea713f56e93e55796 (patch) | |
tree | 9a986adb29ff2eb417798e1e27262da8830a2ccc | |
parent | ecc68904a3e5efb07cb4f0b97d15c7e0e4623d13 (diff) |
audit: add saddr_fam filter field
Provide a method to filter out sockaddr and bind calls by network
address family.
Existing SOCKADDR records are listed for any network activity.
Implement the AUDIT_SADDR_FAM field selector to be able to classify or
limit records to specific network address families, such as AF_INET or
AF_INET6.
An example of a network record that is unlikely to be useful and flood
the logs:
type=SOCKADDR msg=audit(07/27/2017 12:18:27.019:845) : saddr={ fam=local
path=/var/run/nscd/socket }
type=SYSCALL msg=audit(07/27/2017 12:18:27.019:845) : arch=x86_64
syscall=connect success=no exit=ENOENT(No such file or directory) a0=0x3
a1=0x7fff229c4980 a2=0x6e a3=0x6 items=1 ppid=3301 pid=6145 auid=sgrubb
uid=sgrubb gid=sgrubb euid=sgrubb suid=sgrubb fsuid=sgrubb egid=sgrubb
sgid=sgrubb fsgid=sgrubb tty=pts3 ses=4 comm=bash exe=/usr/bin/bash
subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
key=network-test
Please see the audit-testsuite PR at
https://github.com/linux-audit/audit-testsuite/pull/87
Please see the github issue
https://github.com/linux-audit/audit-kernel/issues/64
Please see the github issue for the accompanying userspace support
https://github.com/linux-audit/audit-userspace/issues/93
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
[PM: merge fuzz in auditfilter.c]
Signed-off-by: Paul Moore <paul@paul-moore.com>
-rw-r--r-- | include/uapi/linux/audit.h | 1 | ||||
-rw-r--r-- | kernel/auditfilter.c | 5 | ||||
-rw-r--r-- | kernel/auditsc.c | 5 |
3 files changed, 11 insertions, 0 deletions
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index a1280af20336..c89c6495983d 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h | |||
@@ -281,6 +281,7 @@ | |||
281 | #define AUDIT_OBJ_GID 110 | 281 | #define AUDIT_OBJ_GID 110 |
282 | #define AUDIT_FIELD_COMPARE 111 | 282 | #define AUDIT_FIELD_COMPARE 111 |
283 | #define AUDIT_EXE 112 | 283 | #define AUDIT_EXE 112 |
284 | #define AUDIT_SADDR_FAM 113 | ||
284 | 285 | ||
285 | #define AUDIT_ARG0 200 | 286 | #define AUDIT_ARG0 200 |
286 | #define AUDIT_ARG1 (AUDIT_ARG0+1) | 287 | #define AUDIT_ARG1 (AUDIT_ARG0+1) |
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index d5e54e944f72..e69d136eeaf6 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -391,6 +391,7 @@ static int audit_field_valid(struct audit_entry *entry, struct audit_field *f) | |||
391 | case AUDIT_SUBJ_CLR: | 391 | case AUDIT_SUBJ_CLR: |
392 | case AUDIT_OBJ_LEV_LOW: | 392 | case AUDIT_OBJ_LEV_LOW: |
393 | case AUDIT_OBJ_LEV_HIGH: | 393 | case AUDIT_OBJ_LEV_HIGH: |
394 | case AUDIT_SADDR_FAM: | ||
394 | /* bit ops are only useful on syscall args */ | 395 | /* bit ops are only useful on syscall args */ |
395 | if (f->op == Audit_bitmask || f->op == Audit_bittest) | 396 | if (f->op == Audit_bitmask || f->op == Audit_bittest) |
396 | return -EINVAL; | 397 | return -EINVAL; |
@@ -438,6 +439,10 @@ static int audit_field_valid(struct audit_entry *entry, struct audit_field *f) | |||
438 | if (f->val > AUDIT_MAX_FIELD_COMPARE) | 439 | if (f->val > AUDIT_MAX_FIELD_COMPARE) |
439 | return -EINVAL; | 440 | return -EINVAL; |
440 | break; | 441 | break; |
442 | case AUDIT_SADDR_FAM: | ||
443 | if (f->val >= AF_MAX) | ||
444 | return -EINVAL; | ||
445 | break; | ||
441 | default: | 446 | default: |
442 | break; | 447 | break; |
443 | } | 448 | } |
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 30aa07b0115f..9134fe11ff6c 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -615,6 +615,11 @@ static int audit_filter_rules(struct task_struct *tsk, | |||
615 | case AUDIT_LOGINUID_SET: | 615 | case AUDIT_LOGINUID_SET: |
616 | result = audit_comparator(audit_loginuid_set(tsk), f->op, f->val); | 616 | result = audit_comparator(audit_loginuid_set(tsk), f->op, f->val); |
617 | break; | 617 | break; |
618 | case AUDIT_SADDR_FAM: | ||
619 | if (ctx->sockaddr) | ||
620 | result = audit_comparator(ctx->sockaddr->ss_family, | ||
621 | f->op, f->val); | ||
622 | break; | ||
618 | case AUDIT_SUBJ_USER: | 623 | case AUDIT_SUBJ_USER: |
619 | case AUDIT_SUBJ_ROLE: | 624 | case AUDIT_SUBJ_ROLE: |
620 | case AUDIT_SUBJ_TYPE: | 625 | case AUDIT_SUBJ_TYPE: |