History

Merge tag 'audit-pr-20211101' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit

Pull audit updates from Paul Moore: "Add some additional audit logging to capture the openat2() syscall open_how struct info. Previous variations of the open()/openat() syscalls allowed audit admins to inspect the syscall args to get the information contained in the new open_how struct used in openat2()" * tag 'audit-pr-20211101' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: audit: return early if the filter rule has a lower priority audit: add OPENAT2 record to list "how" info audit: add support for the openat2 syscall audit: replace magic audit syscall class numbers with macros lsm_audit: avoid overloading the "key" audit field audit: Convert to SPDX identifier audit: rename struct node to struct audit_node to prevent future name collisions

Linus Torvalds committed 5 years ago

Commit d2fac0a2 parents cdab10b d9516f323 files · +184 −98Browse files

Unified · Split

23 files
  1. MAINTAINERS +1 −0
  2. arch/alpha/kernel/audit.c +6 −4
  3. arch/ia64/kernel/audit.c +6 −4
  4. arch/parisc/kernel/audit.c +6 −4
  5. arch/parisc/kernel/compat_audit.c +7 −4
  6. arch/powerpc/kernel/audit.c +7 −5
  7. arch/powerpc/kernel/compat_audit.c +8 −5
  8. arch/s390/kernel/audit.c +7 −5
  9. arch/s390/kernel/compat_audit.c +8 −5
  10. arch/sparc/kernel/audit.c +7 −5
  11. arch/sparc/kernel/compat_audit.c +8 −5
  12. arch/x86/ia32/audit.c +8 −5
  13. arch/x86/kernel/audit_64.c +6 −4
  14. fs/open.c +2 −0
  15. include/linux/audit.h +11 −0
  16. include/linux/audit_arch.h +24 −0
  17. include/uapi/linux/audit.h +1 −0
  18. kernel/audit.h +2 −0
  19. kernel/audit_tree.c +10 −10
  20. kernel/auditsc.c +29 −22
  21. lib/audit.c +9 −5
  22. lib/compat_audit.c +10 −5
  23. security/lsm_audit.c +1 −1
MAINTAINERS+1−0
@@ -3127,6 +3127,7 @@ W: https://github.com/linux-audit · 3126 unmodified lines
31273127 T: git git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git
31283128 F: include/asm-generic/audit_*.h
31293129 F: include/linux/audit.h
3130+F: include/linux/audit_arch.h
31303131 F: include/uapi/linux/audit.h
31313132 F: kernel/audit*
31323133 F: lib/*audit.c
arch/alpha/kernel/audit.c+6−4
@@ -37,13 +37,15 @@ int audit_classify_syscall(int abi, unsigned syscall) · 36 unmodified lines
3737 {
3838 switch(syscall) {
3939 case __NR_open:
40− return 2;
40+ return AUDITSC_OPEN;
4141 case __NR_openat:
42− return 3;
42+ return AUDITSC_OPENAT;
4343 case __NR_execve:
44− return 5;
44+ return AUDITSC_EXECVE;
45+ case __NR_openat2:
46+ return AUDITSC_OPENAT2;
4547 default:
46− return 0;
48+ return AUDITSC_NATIVE;
4749 }
4850 }
4951
arch/ia64/kernel/audit.c+6−4
@@ -38,13 +38,15 @@ int audit_classify_syscall(int abi, unsigned syscall) · 37 unmodified lines
3838 {
3939 switch(syscall) {
4040 case __NR_open:
41− return 2;
41+ return AUDITSC_OPEN;
4242 case __NR_openat:
43− return 3;
43+ return AUDITSC_OPENAT;
4444 case __NR_execve:
45− return 5;
45+ return AUDITSC_EXECVE;
46+ case __NR_openat2:
47+ return AUDITSC_OPENAT2;
4648 default:
47− return 0;
49+ return AUDITSC_NATIVE;
4850 }
4951 }
5052
arch/parisc/kernel/audit.c+6−4
@@ -47,13 +47,15 @@ int audit_classify_syscall(int abi, unsigned syscall) · 46 unmodified lines
4747 #endif
4848 switch (syscall) {
4949 case __NR_open:
50− return 2;
50+ return AUDITSC_OPEN;
5151 case __NR_openat:
52− return 3;
52+ return AUDITSC_OPENAT;
5353 case __NR_execve:
54− return 5;
54+ return AUDITSC_EXECVE;
55+ case __NR_openat2:
56+ return AUDITSC_OPENAT2;
5557 default:
56− return 0;
58+ return AUDITSC_NATIVE;
5759 }
5860 }
5961
arch/parisc/kernel/compat_audit.c+7−4
@@ -1,4 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2+#include <linux/audit_arch.h>
23 #include <asm/unistd.h>
34
45 unsigned int parisc32_dir_class[] = {
@@ -30,12 +31,14 @@ int parisc32_classify_syscall(unsigned syscall) · 25 unmodified lines
3031 {
3132 switch (syscall) {
3233 case __NR_open:
33− return 2;
34+ return AUDITSC_OPEN;
3435 case __NR_openat:
35− return 3;
36+ return AUDITSC_OPENAT;
3637 case __NR_execve:
37− return 5;
38+ return AUDITSC_EXECVE;
39+ case __NR_openat2:
40+ return AUDITSC_OPENAT2;
3841 default:
39− return 1;
42+ return AUDITSC_COMPAT;
4043 }
4144 }
arch/powerpc/kernel/audit.c+7−5
@@ -47,15 +47,17 @@ int audit_classify_syscall(int abi, unsigned syscall) · 46 unmodified lines
4747 #endif
4848 switch(syscall) {
4949 case __NR_open:
50− return 2;
50+ return AUDITSC_OPEN;
5151 case __NR_openat:
52− return 3;
52+ return AUDITSC_OPENAT;
5353 case __NR_socketcall:
54− return 4;
54+ return AUDITSC_SOCKETCALL;
5555 case __NR_execve:
56− return 5;
56+ return AUDITSC_EXECVE;
57+ case __NR_openat2:
58+ return AUDITSC_OPENAT2;
5759 default:
58− return 0;
60+ return AUDITSC_NATIVE;
5961 }
6062 }
6163
arch/powerpc/kernel/compat_audit.c+8−5
@@ -1,5 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #undef __powerpc64__
3+#include <linux/audit_arch.h>
34 #include <asm/unistd.h>
45
56 unsigned ppc32_dir_class[] = {
@@ -31,14 +32,16 @@ int ppc32_classify_syscall(unsigned syscall) · 25 unmodified lines
3132 {
3233 switch(syscall) {
3334 case __NR_open:
34− return 2;
35+ return AUDITSC_OPEN;
3536 case __NR_openat:
36− return 3;
37+ return AUDITSC_OPENAT;
3738 case __NR_socketcall:
38− return 4;
39+ return AUDITSC_SOCKETCALL;
3940 case __NR_execve:
40− return 5;
41+ return AUDITSC_EXECVE;
42+ case __NR_openat2:
43+ return AUDITSC_OPENAT2;
4144 default:
42− return 1;
45+ return AUDITSC_COMPAT;
4346 }
4447 }
arch/s390/kernel/audit.c+7−5
@@ -47,15 +47,17 @@ int audit_classify_syscall(int abi, unsigned syscall) · 46 unmodified lines
4747 #endif
4848 switch(syscall) {
4949 case __NR_open:
50− return 2;
50+ return AUDITSC_OPEN;
5151 case __NR_openat:
52− return 3;
52+ return AUDITSC_OPENAT;
5353 case __NR_socketcall:
54− return 4;
54+ return AUDITSC_SOCKETCALL;
5555 case __NR_execve:
56− return 5;
56+ return AUDITSC_EXECVE;
57+ case __NR_openat2:
58+ return AUDITSC_OPENAT2;
5759 default:
58− return 0;
60+ return AUDITSC_NATIVE;
5961 }
6062 }
6163
arch/s390/kernel/compat_audit.c+8−5
@@ -1,5 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #undef __s390x__
3+#include <linux/audit_arch.h>
34 #include <asm/unistd.h>
45 #include "audit.h"
56
@@ -32,14 +33,16 @@ int s390_classify_syscall(unsigned syscall) · 26 unmodified lines
3233 {
3334 switch(syscall) {
3435 case __NR_open:
35− return 2;
36+ return AUDITSC_OPEN;
3637 case __NR_openat:
37− return 3;
38+ return AUDITSC_OPENAT;
3839 case __NR_socketcall:
39− return 4;
40+ return AUDITSC_SOCKETCALL;
4041 case __NR_execve:
41− return 5;
42+ return AUDITSC_EXECVE;
43+ case __NR_openat2:
44+ return AUDITSC_OPENAT2;
4245 default:
43− return 1;
46+ return AUDITSC_COMPAT;
4447 }
4548 }
arch/sparc/kernel/audit.c+7−5
@@ -48,15 +48,17 @@ int audit_classify_syscall(int abi, unsigned int syscall) · 47 unmodified lines
4848 #endif
4949 switch(syscall) {
5050 case __NR_open:
51− return 2;
51+ return AUDITSC_OPEN;
5252 case __NR_openat:
53− return 3;
53+ return AUDITSC_OPENAT;
5454 case __NR_socketcall:
55− return 4;
55+ return AUDITSC_SOCKETCALL;
5656 case __NR_execve:
57− return 5;
57+ return AUDITSC_EXECVE;
58+ case __NR_openat2:
59+ return AUDITSC_OPENAT2;
5860 default:
59− return 0;
61+ return AUDITSC_NATIVE;
6062 }
6163 }
6264
arch/sparc/kernel/compat_audit.c+8−5
@@ -1,5 +1,6 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #define __32bit_syscall_numbers__
3+#include <linux/audit_arch.h>
34 #include <asm/unistd.h>
45 #include "kernel.h"
56
@@ -32,14 +33,16 @@ int sparc32_classify_syscall(unsigned int syscall) · 26 unmodified lines
3233 {
3334 switch(syscall) {
3435 case __NR_open:
35− return 2;
36+ return AUDITSC_OPEN;
3637 case __NR_openat:
37− return 3;
38+ return AUDITSC_OPENAT;
3839 case __NR_socketcall:
39− return 4;
40+ return AUDITSC_SOCKETCALL;
4041 case __NR_execve:
41− return 5;
42+ return AUDITSC_EXECVE;
43+ case __NR_openat2:
44+ return AUDITSC_OPENAT2;
4245 default:
43− return 1;
46+ return AUDITSC_COMPAT;
4447 }
4548 }
arch/x86/ia32/audit.c+8−5
@@ -1,4 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2+#include <linux/audit_arch.h>
23 #include <asm/unistd_32.h>
34 #include <asm/audit.h>
45
@@ -31,15 +32,17 @@ int ia32_classify_syscall(unsigned syscall) · 26 unmodified lines
3132 {
3233 switch (syscall) {
3334 case __NR_open:
34− return 2;
35+ return AUDITSC_OPEN;
3536 case __NR_openat:
36− return 3;
37+ return AUDITSC_OPENAT;
3738 case __NR_socketcall:
38− return 4;
39+ return AUDITSC_SOCKETCALL;
3940 case __NR_execve:
4041 case __NR_execveat:
41− return 5;
42+ return AUDITSC_EXECVE;
43+ case __NR_openat2:
44+ return AUDITSC_OPENAT2;
4245 default:
43− return 1;
46+ return AUDITSC_COMPAT;
4447 }
4548 }
arch/x86/kernel/audit_64.c+6−4
@@ -47,14 +47,16 @@ int audit_classify_syscall(int abi, unsigned syscall) · 46 unmodified lines
4747 #endif
4848 switch(syscall) {
4949 case __NR_open:
50− return 2;
50+ return AUDITSC_OPEN;
5151 case __NR_openat:
52− return 3;
52+ return AUDITSC_OPENAT;
5353 case __NR_execve:
5454 case __NR_execveat:
55− return 5;
55+ return AUDITSC_EXECVE;
56+ case __NR_openat2:
57+ return AUDITSC_OPENAT2;
5658 default:
57− return 0;
59+ return AUDITSC_NATIVE;
5860 }
5961 }
6062
fs/open.c+2−0
@@ -1248,6 +1248,8 @@ SYSCALL_DEFINE4(openat2, int, dfd, const char __user *, filename, · 1247 unmodified lines
12481248 if (err)
12491249 return err;
12501250
1251+ audit_openat2_how(&tmp);
1252+
12511253 /* O_LARGEFILE is only allowed for non-O_PATH. */
12521254 if (!(tmp.flags & O_PATH) && force_o_largefile())
12531255 tmp.flags |= O_LARGEFILE;
include/linux/audit.h+11−0
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111
1212 #include <linux/sched.h>
1313 #include <linux/ptrace.h>
14+#include <linux/audit_arch.h>
1415 #include <uapi/linux/audit.h>
1516 #include <uapi/linux/netfilter/nf_tables.h>
1617
@@ -416,6 +417,7 @@ extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, · 399 unmodified lines
416417 const struct cred *old);
417418 extern void __audit_log_capset(const struct cred *new, const struct cred *old);
418419 extern void __audit_mmap_fd(int fd, int flags);
420+extern void __audit_openat2_how(struct open_how *how);
419421 extern void __audit_log_kern_module(char *name);
420422 extern void __audit_fanotify(unsigned int response);
421423 extern void __audit_tk_injoffset(struct timespec64 offset);
@@ -512,6 +514,12 @@ static inline void audit_mmap_fd(int fd, int flags) · 90 unmodified lines
512514 __audit_mmap_fd(fd, flags);
513515 }
514516
517+static inline void audit_openat2_how(struct open_how *how)
518+{
519+ if (unlikely(!audit_dummy_context()))
520+ __audit_openat2_how(how);
521+}
522+
515523 static inline void audit_log_kern_module(char *name)
516524 {
517525 if (!audit_dummy_context())
@@ -671,6 +679,9 @@ static inline void audit_log_capset(const struct cred *new, · 153 unmodified lines
671679 static inline void audit_mmap_fd(int fd, int flags)
672680 { }
673681
682+static inline void audit_openat2_how(struct open_how *how)
683+{ }
684+
674685 static inline void audit_log_kern_module(char *name)
675686 {
676687 }
include/linux/audit_arch.h+24−0
@@ -0,0 +1,24 @@
1+/* SPDX-License-Identifier: GPL-2.0-or-later */
2+/* audit_arch.h -- Arch layer specific support for audit
3+ *
4+ * Copyright 2021 Red Hat Inc., Durham, North Carolina.
5+ * All Rights Reserved.
6+ *
7+ * Author: Richard Guy Briggs <rgb@redhat.com>
8+ */
9+#ifndef _LINUX_AUDIT_ARCH_H_
10+#define _LINUX_AUDIT_ARCH_H_
11+
12+enum auditsc_class_t {
13+ AUDITSC_NATIVE = 0,
14+ AUDITSC_COMPAT,
15+ AUDITSC_OPEN,
16+ AUDITSC_OPENAT,
17+ AUDITSC_SOCKETCALL,
18+ AUDITSC_EXECVE,
19+ AUDITSC_OPENAT2,
20+
21+ AUDITSC_NVALS /* count */
22+};
23+
24+#endif
include/uapi/linux/audit.h+1−0
@@ -119,6 +119,7 @@ · 118 unmodified lines
119119 #define AUDIT_BPF 1334 /* BPF subsystem */
120120 #define AUDIT_EVENT_LISTENER 1335 /* Task joined multicast read socket */
121121 #define AUDIT_URINGOP 1336 /* io_uring operation */
122+#define AUDIT_OPENAT2 1337 /* Record showing openat2 how args */
122123
123124 #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
124125 #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
kernel/audit.h+2−0
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/skbuff.h>
1515 #include <uapi/linux/mqueue.h>
1616 #include <linux/tty.h>
17+#include <uapi/linux/openat2.h> // struct open_how
1718
1819 /* AUDIT_NAMES is the number of slots we reserve in the audit_context
1920 * for saving names from getname(). If we get more names we will allocate
@@ -193,6 +194,7 @@ struct audit_context { · 173 unmodified lines
193194 int fd;
194195 int flags;
195196 } mmap;
197+ struct open_how openat2;
196198 struct {
197199 int argc;
198200 } execve;
kernel/audit_tree.c+10−10
@@ -30,7 +30,7 @@ struct audit_chunk { · 29 unmodified lines
3030 int count;
3131 atomic_long_t refs;
3232 struct rcu_head head;
33− struct node {
33+ struct audit_node {
3434 struct list_head list;
3535 struct audit_tree *owner;
3636 unsigned index; /* index; upper bit indicates 'will prune' */
@@ -269,7 +269,7 @@ bool audit_tree_match(struct audit_chunk *chunk, struct audit_tree *tree) · 232 unmodified lines
269269
270270 /* tagging and untagging inodes with trees */
271271
272−static struct audit_chunk *find_chunk(struct node *p)
272+static struct audit_chunk *find_chunk(struct audit_node *p)
273273 {
274274 int index = p->index & ~(1U<<31);
275275 p -= index;
@@ -322,7 +322,7 @@ static void replace_chunk(struct audit_chunk *new, struct audit_chunk *old) · 46 unmodified lines
322322 list_replace_rcu(&old->hash, &new->hash);
323323 }
324324
325−static void remove_chunk_node(struct audit_chunk *chunk, struct node *p)
325+static void remove_chunk_node(struct audit_chunk *chunk, struct audit_node *p)
326326 {
327327 struct audit_tree *owner = p->owner;
328328
@@ -459,7 +459,7 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree) · 130 unmodified lines
459459 {
460460 struct fsnotify_mark *mark;
461461 struct audit_chunk *chunk, *old;
462− struct node *p;
462+ struct audit_node *p;
463463 int n;
464464
465465 mutex_lock(&audit_tree_group->mark_mutex);
@@ -570,11 +570,11 @@ static void prune_tree_chunks(struct audit_tree *victim, bool tagged) · 104 unmodified lines
570570 {
571571 spin_lock(&hash_lock);
572572 while (!list_empty(&victim->chunks)) {
573− struct node *p;
573+ struct audit_node *p;
574574 struct audit_chunk *chunk;
575575 struct fsnotify_mark *mark;
576576
577− p = list_first_entry(&victim->chunks, struct node, list);
577+ p = list_first_entry(&victim->chunks, struct audit_node, list);
578578 /* have we run out of marked? */
579579 if (tagged && !(p->index & (1U<<31)))
580580 break;
@@ -616,7 +616,7 @@ static void trim_marked(struct audit_tree *tree) · 35 unmodified lines
616616 }
617617 /* reorder */
618618 for (p = tree->chunks.next; p != &tree->chunks; p = q) {
619− struct node *node = list_entry(p, struct node, list);
619+ struct audit_node *node = list_entry(p, struct audit_node, list);
620620 q = p->next;
621621 if (node->index & (1U<<31)) {
622622 list_del_init(p);
@@ -684,7 +684,7 @@ void audit_trim_trees(void) · 61 unmodified lines
684684 struct audit_tree *tree;
685685 struct path path;
686686 struct vfsmount *root_mnt;
687− struct node *node;
687+ struct audit_node *node;
688688 int err;
689689
690690 tree = container_of(cursor.next, struct audit_tree, list);
@@ -840,7 +840,7 @@ int audit_add_tree_rule(struct audit_krule *rule) · 149 unmodified lines
840840 drop_collected_mounts(mnt);
841841
842842 if (!err) {
843− struct node *node;
843+ struct audit_node *node;
844844 spin_lock(&hash_lock);
845845 list_for_each_entry(node, &tree->chunks, list)
846846 node->index &= ~(1U<<31);
@@ -939,7 +939,7 @@ int audit_tag_tree(char *old, char *new) · 92 unmodified lines
939939 mutex_unlock(&audit_filter_mutex);
940940
941941 if (!failed) {
942− struct node *node;
942+ struct audit_node *node;
943943 spin_lock(&hash_lock);
944944 list_for_each_entry(node, &tree->chunks, list)
945945 node->index &= ~(1U<<31);
kernel/auditsc.c+29−22
@@ -1,3 +1,4 @@
1+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* auditsc.c -- System-call auditing support
23 * Handles all system-call specific auditing features.
34 *
@@ -6,20 +7,6 @@ · 2 unmodified lines
67 * Copyright (C) 2005, 2006 IBM Corporation
78 * All Rights Reserved.
89 *
9− * This program is free software; you can redistribute it and/or modify
10− * it under the terms of the GNU General Public License as published by
11− * the Free Software Foundation; either version 2 of the License, or
12− * (at your option) any later version.
13− *
14− * This program is distributed in the hope that it will be useful,
15− * but WITHOUT ANY WARRANTY; without even the implied warranty of
16− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17− * GNU General Public License for more details.
18− *
19− * You should have received a copy of the GNU General Public License
20− * along with this program; if not, write to the Free Software
21− * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22− *
2310 * Written by Rickard E. (Rik) Faith <faith@redhat.com>
2411 *
2512 * Many of the ideas implemented here are from Stephen C. Tweedie,
@@ -76,6 +63,7 @@ · 50 unmodified lines
7663 #include <linux/fsnotify_backend.h>
7764 #include <uapi/linux/limits.h>
7865 #include <uapi/linux/netfilter/nf_tables.h>
66+#include <uapi/linux/openat2.h> // struct open_how
7967
8068 #include "audit.h"
8169
@@ -166,7 +154,7 @@ static int audit_match_perm(struct audit_context *ctx, int mask) · 84 unmodified lines
166154 n = ctx->major;
167155
168156 switch (audit_classify_syscall(ctx->arch, n)) {
169− case 0: /* native */
157+ case AUDITSC_NATIVE:
170158 if ((mask & AUDIT_PERM_WRITE) &&
171159 audit_match_class(AUDIT_CLASS_WRITE, n))
172160 return 1;
@@ -177,7 +165,7 @@ static int audit_match_perm(struct audit_context *ctx, int mask) · 4 unmodified lines
177165 audit_match_class(AUDIT_CLASS_CHATTR, n))
178166 return 1;
179167 return 0;
180− case 1: /* 32bit on biarch */
168+ case AUDITSC_COMPAT: /* 32bit on biarch */
181169 if ((mask & AUDIT_PERM_WRITE) &&
182170 audit_match_class(AUDIT_CLASS_WRITE_32, n))
183171 return 1;
@@ -188,14 +176,16 @@ static int audit_match_perm(struct audit_context *ctx, int mask) · 4 unmodified lines
188176 audit_match_class(AUDIT_CLASS_CHATTR_32, n))
189177 return 1;
190178 return 0;
191− case 2: /* open */
179+ case AUDITSC_OPEN:
192180 return mask & ACC_MODE(ctx->argv[1]);
193− case 3: /* openat */
181+ case AUDITSC_OPENAT:
194182 return mask & ACC_MODE(ctx->argv[2]);
195− case 4: /* socketcall */
183+ case AUDITSC_SOCKETCALL:
196184 return ((mask & AUDIT_PERM_WRITE) && ctx->argv[0] == SYS_BIND);
197− case 5: /* execve */
185+ case AUDITSC_EXECVE:
198186 return mask & AUDIT_PERM_EXEC;
187+ case AUDITSC_OPENAT2:
188+ return mask & ACC_MODE((u32)((struct open_how *)ctx->argv[2])->flags);
199189 default:
200190 return 0;
201191 }
@@ -480,6 +470,9 @@ static int audit_filter_rules(struct task_struct *tsk, · 278 unmodified lines
480470 u32 sid;
481471 unsigned int sessionid;
482472
473+ if (ctx && rule->prio <= ctx->prio)
474+ return 0;
475+
483476 cred = rcu_dereference_check(tsk->cred, tsk == current || task_creation);
484477
485478 for (i = 0; i < rule->field_count; i++) {
@@ -747,8 +740,6 @@ static int audit_filter_rules(struct task_struct *tsk, · 261 unmodified lines
747740 }
748741
749742 if (ctx) {
750− if (rule->prio <= ctx->prio)
751− return 0;
752743 if (rule->filterkey) {
753744 kfree(ctx->filterkey);
754745 ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC);
@@ -1437,6 +1428,12 @@ static void show_special(struct audit_context *context, int *call_panic) · 682 unmodified lines
14371428 audit_log_format(ab, "fd=%d flags=0x%x", context->mmap.fd,
14381429 context->mmap.flags);
14391430 break;
1431+ case AUDIT_OPENAT2:
1432+ audit_log_format(ab, "oflag=0%llo mode=0%llo resolve=0x%llx",
1433+ context->openat2.flags,
1434+ context->openat2.mode,
1435+ context->openat2.resolve);
1436+ break;
14401437 case AUDIT_EXECVE:
14411438 audit_log_execve_info(context, &ab);
14421439 break;
@@ -2815,6 +2812,16 @@ void __audit_mmap_fd(int fd, int flags) · 1372 unmodified lines
28152812 context->type = AUDIT_MMAP;
28162813 }
28172814
2815+void __audit_openat2_how(struct open_how *how)
2816+{
2817+ struct audit_context *context = audit_context();
2818+
2819+ context->openat2.flags = how->flags;
2820+ context->openat2.mode = how->mode;
2821+ context->openat2.resolve = how->resolve;
2822+ context->type = AUDIT_OPENAT2;
2823+}
2824+
28182825 void __audit_log_kern_module(char *name)
28192826 {
28202827 struct audit_context *context = audit_context();
lib/audit.c+9−5
@@ -45,23 +45,27 @@ int audit_classify_syscall(int abi, unsigned syscall) · 44 unmodified lines
4545 switch(syscall) {
4646 #ifdef __NR_open
4747 case __NR_open:
48− return 2;
48+ return AUDITSC_OPEN;
4949 #endif
5050 #ifdef __NR_openat
5151 case __NR_openat:
52− return 3;
52+ return AUDITSC_OPENAT;
5353 #endif
5454 #ifdef __NR_socketcall
5555 case __NR_socketcall:
56− return 4;
56+ return AUDITSC_SOCKETCALL;
5757 #endif
5858 #ifdef __NR_execveat
5959 case __NR_execveat:
6060 #endif
6161 case __NR_execve:
62− return 5;
62+ return AUDITSC_EXECVE;
63+#ifdef __NR_openat2
64+ case __NR_openat2:
65+ return AUDITSC_OPENAT2;
66+#endif
6367 default:
64− return 0;
68+ return AUDITSC_NATIVE;
6569 }
6670 }
6771
lib/compat_audit.c+10−5
@@ -1,6 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <linux/init.h>
33 #include <linux/types.h>
4+#include <linux/audit_arch.h>
45 #include <asm/unistd32.h>
56
67 unsigned compat_dir_class[] = {
@@ -33,19 +34,23 @@ int audit_classify_compat_syscall(int abi, unsigned syscall) · 26 unmodified lines
3334 switch (syscall) {
3435 #ifdef __NR_open
3536 case __NR_open:
36− return 2;
37+ return AUDITSC_OPEN;
3738 #endif
3839 #ifdef __NR_openat
3940 case __NR_openat:
40− return 3;
41+ return AUDITSC_OPENAT;
4142 #endif
4243 #ifdef __NR_socketcall
4344 case __NR_socketcall:
44− return 4;
45+ return AUDITSC_SOCKETCALL;
4546 #endif
4647 case __NR_execve:
47− return 5;
48+ return AUDITSC_EXECVE;
49+#ifdef __NR_openat2
50+ case __NR_openat2:
51+ return AUDITSC_OPENAT2;
52+#endif
4853 default:
49− return 1;
54+ return AUDITSC_COMPAT;
5055 }
5156 }
security/lsm_audit.c+1−1
@@ -224,7 +224,7 @@ static void dump_common_audit_data(struct audit_buffer *ab, · 223 unmodified lines
224224 case LSM_AUDIT_DATA_NONE:
225225 return;
226226 case LSM_AUDIT_DATA_IPC:
227− audit_log_format(ab, " key=%d ", a->u.ipc_id);
227+ audit_log_format(ab, " ipc_key=%d ", a->u.ipc_id);
228228 break;
229229 case LSM_AUDIT_DATA_CAP:
230230 audit_log_format(ab, " capability=%d ", a->u.cap);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t