Skip to content

Commit 7b9205b

Browse files
keestorvalds
authored andcommitted
audit: create explicit AUDIT_SECCOMP event type
The seccomp path was using AUDIT_ANOM_ABEND from when seccomp mode 1 could only kill a process. While we still want to make sure an audit record is forced on a kill, this should use a separate record type since seccomp mode 2 introduces other behaviors. In the case of "handled" behaviors (process wasn't killed), only emit a record if the process is under inspection. This change also fixes userspace examination of seccomp audit events, since it was considered malformed due to missing fields of the AUDIT_ANOM_ABEND event type. Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Eric Paris <eparis@redhat.com> Cc: Jeff Layton <jlayton@redhat.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Julien Tinnes <jln@google.com> Acked-by: Will Drewry <wad@chromium.org> Acked-by: Steve Grubb <sgrubb@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 56ca9d9 commit 7b9205b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

include/linux/audit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ void audit_core_dumps(long signr);
157157

158158
static inline void audit_seccomp(unsigned long syscall, long signr, int code)
159159
{
160-
if (unlikely(!audit_dummy_context()))
160+
/* Force a record to be reported if a signal was delivered. */
161+
if (signr || unlikely(!audit_dummy_context()))
161162
__audit_seccomp(syscall, signr, code);
162163
}
163164

include/uapi/linux/audit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#define AUDIT_MMAP 1323 /* Record showing descriptor and flags in mmap */
107107
#define AUDIT_NETFILTER_PKT 1324 /* Packets traversing netfilter chains */
108108
#define AUDIT_NETFILTER_CFG 1325 /* Netfilter chain modifications */
109+
#define AUDIT_SECCOMP 1326 /* Secure Computing event */
109110

110111
#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
111112
#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */

kernel/auditsc.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ void __audit_mmap_fd(int fd, int flags)
26752675
context->type = AUDIT_MMAP;
26762676
}
26772677

2678-
static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
2678+
static void audit_log_task(struct audit_buffer *ab)
26792679
{
26802680
kuid_t auid, uid;
26812681
kgid_t gid;
@@ -2693,6 +2693,11 @@ static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
26932693
audit_log_task_context(ab);
26942694
audit_log_format(ab, " pid=%d comm=", current->pid);
26952695
audit_log_untrustedstring(ab, current->comm);
2696+
}
2697+
2698+
static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
2699+
{
2700+
audit_log_task(ab);
26962701
audit_log_format(ab, " reason=");
26972702
audit_log_string(ab, reason);
26982703
audit_log_format(ab, " sig=%ld", signr);
@@ -2723,8 +2728,11 @@ void __audit_seccomp(unsigned long syscall, long signr, int code)
27232728
{
27242729
struct audit_buffer *ab;
27252730

2726-
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_ANOM_ABEND);
2727-
audit_log_abend(ab, "seccomp", signr);
2731+
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_SECCOMP);
2732+
if (unlikely(!ab))
2733+
return;
2734+
audit_log_task(ab);
2735+
audit_log_format(ab, " sig=%ld", signr);
27282736
audit_log_format(ab, " syscall=%ld", syscall);
27292737
audit_log_format(ab, " compat=%d", is_compat_task());
27302738
audit_log_format(ab, " ip=0x%lx", KSTK_EIP(current));

0 commit comments

Comments
 (0)