History

audit: Record fanotify access control decisions

The fanotify interface allows user space daemons to make access control decisions. Under common criteria requirements, we need to optionally record decisions based on policy. This patch adds a bit mask, FAN_AUDIT, that a user space daemon can 'or' into the response decision which will tell the kernel that it made a decision and record it. It would be used something like this in user space code: response.response = FAN_DENY | FAN_AUDIT; write(fd, &response, sizeof(struct fanotify_response)); When the syscall ends, the audit system will record the decision as a AUDIT_FANOTIFY auxiliary record to denote that the reason this event occurred is the result of an access control decision from fanotify rather than DAC or MAC policy. A sample event looks like this: type=PATH msg=audit(1504310584.332:290): item=0 name="./evil-ls" inode=1319561 dev=fc:03 mode=0100755 ouid=1000 ogid=1000 rdev=00:00 obj=unconfined_u:object_r:user_home_t:s0 nametype=NORMAL type=CWD msg=audit(1504310584.332:290): cwd="/home/sgrubb" type=SYSCALL msg=audit(1504310584.332:290): arch=c000003e syscall=2 success=no exit=-1 a0=32cb3fca90 a1=0 a2=43 a3=8 items=1 ppid=901 pid=959 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts1 ses=3 comm="bash" exe="/usr/bin/bash" subj=unconfined_u:unconfined_r:unconfined_t: s0-s0:c0.c1023 key=(null) type=FANOTIFY msg=audit(1504310584.332:290): resp=2 Prior to using the audit flag, the developer needs to call fanotify_init or'ing in FAN_ENABLE_AUDIT to ensure that the kernel supports auditing. The calling process must also have the CAP_AUDIT_WRITE capability.

Steve Grubb committed 9 years ago

Commit de8cd831 parent 8a5776a8 files · +46 −2Browse files

Showing the changes to include/uapi/linux (2 of 8 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/audit.h +1 −0
  2. include/uapi/linux/fanotify.h +3 −0
include/uapi/linux/audit.h+1−0
@@ -112,6 +112,7 @@ · 111 unmodified lines
112#define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */112#define AUDIT_FEATURE_CHANGE 1328 /* audit log listing feature changes */
113#define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */113#define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */
114#define AUDIT_KERN_MODULE 1330 /* Kernel Module events */114#define AUDIT_KERN_MODULE 1330 /* Kernel Module events */
115#define AUDIT_FANOTIFY 1331 /* Fanotify access decision */
115 116
116#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */117#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
117#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */118#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
include/uapi/linux/fanotify.h+3−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
35 35
36#define FAN_UNLIMITED_QUEUE 0x0000001036#define FAN_UNLIMITED_QUEUE 0x00000010
37#define FAN_UNLIMITED_MARKS 0x0000002037#define FAN_UNLIMITED_MARKS 0x00000020
38#define FAN_ENABLE_AUDIT 0x00000040
38 39
39#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \40#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \
40 FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\41 FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\
@@ -99,6 +100,8 @@ struct fanotify_response { · 58 unmodified lines
99/* Legit userspace responses to a _PERM event */100/* Legit userspace responses to a _PERM event */
100#define FAN_ALLOW 0x01101#define FAN_ALLOW 0x01
101#define FAN_DENY 0x02102#define FAN_DENY 0x02
103#define FAN_AUDIT 0x10 /* Bit mask to create audit record for result */
104
102/* No fd set in event */105/* No fd set in event */
103#define FAN_NOFD -1106#define FAN_NOFD -1
104 107