Skip to content

Commit 42f355e

Browse files
rgbriggspcmoore
authored andcommitted
audit: replace magic audit syscall class numbers with macros
Replace audit syscall class magic numbers with macros. This required putting the macros into new header file include/linux/audit_arch.h since the syscall macros were included for both 64 bit and 32 bit in any compat code, causing redefinition warnings. Link: https://lore.kernel.org/r/2300b1083a32aade7ae7efb95826e8f3f260b1df.1621363275.git.rgb@redhat.com Signed-off-by: Richard Guy Briggs <[email protected]> Acked-by: Christian Brauner <[email protected]> [PM: renamed header to audit_arch.h after consulting with Richard] Signed-off-by: Paul Moore <[email protected]>
1 parent 8e71168 commit 42f355e

File tree

18 files changed

+102
-71
lines changed

18 files changed

+102
-71
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,6 +3113,7 @@ W: https://github.com/linux-audit
31133113
T: git git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit.git
31143114
F: include/asm-generic/audit_*.h
31153115
F: include/linux/audit.h
3116+
F: include/linux/audit_arch.h
31163117
F: include/uapi/linux/audit.h
31173118
F: kernel/audit*
31183119
F: lib/*audit.c

arch/alpha/kernel/audit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ int audit_classify_syscall(int abi, unsigned syscall)
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;
4545
default:
46-
return 0;
46+
return AUDITSC_NATIVE;
4747
}
4848
}
4949

arch/ia64/kernel/audit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ int audit_classify_syscall(int abi, unsigned syscall)
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;
4646
default:
47-
return 0;
47+
return AUDITSC_NATIVE;
4848
}
4949
}
5050

arch/parisc/kernel/audit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ int audit_classify_syscall(int abi, unsigned syscall)
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;
5555
default:
56-
return 0;
56+
return AUDITSC_NATIVE;
5757
}
5858
}
5959

arch/parisc/kernel/compat_audit.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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,12 @@ int parisc32_classify_syscall(unsigned syscall)
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;
3839
default:
39-
return 1;
40+
return AUDITSC_COMPAT;
4041
}
4142
}

arch/powerpc/kernel/audit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ int audit_classify_syscall(int abi, unsigned syscall)
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;
5757
default:
58-
return 0;
58+
return AUDITSC_NATIVE;
5959
}
6060
}
6161

arch/powerpc/kernel/compat_audit.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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,14 @@ int ppc32_classify_syscall(unsigned syscall)
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;
4142
default:
42-
return 1;
43+
return AUDITSC_COMPAT;
4344
}
4445
}

arch/s390/kernel/audit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ int audit_classify_syscall(int abi, unsigned syscall)
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;
5757
default:
58-
return 0;
58+
return AUDITSC_NATIVE;
5959
}
6060
}
6161

arch/s390/kernel/compat_audit.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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,14 @@ int s390_classify_syscall(unsigned syscall)
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;
4243
default:
43-
return 1;
44+
return AUDITSC_COMPAT;
4445
}
4546
}

arch/sparc/kernel/audit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ int audit_classify_syscall(int abi, unsigned int syscall)
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;
5858
default:
59-
return 0;
59+
return AUDITSC_NATIVE;
6060
}
6161
}
6262

0 commit comments

Comments
 (0)