Skip to content

Commit 55669bf

Browse files
author
Al Viro
committed
[PATCH] audit: AUDIT_PERM support
add support for AUDIT_PERM predicate Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent dc104fb commit 55669bf

13 files changed

Lines changed: 236 additions & 0 deletions

File tree

‎arch/i386/kernel/audit.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ static unsigned chattr_class[] = {
2323
~0U
2424
};
2525

26+
int audit_classify_syscall(int abi, unsigned syscall)
27+
{
28+
switch(syscall) {
29+
case __NR_open:
30+
return 2;
31+
case __NR_openat:
32+
return 3;
33+
case __NR_socketcall:
34+
return 4;
35+
case __NR_execve:
36+
return 5;
37+
default:
38+
return 0;
39+
}
40+
}
41+
2642
static int __init audit_classes_init(void)
2743
{
2844
audit_register_class(AUDIT_CLASS_WRITE, write_class);

‎arch/ia64/ia32/audit.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@ unsigned ia32_read_class[] = {
1919
#include <asm-generic/audit_read.h>
2020
~0U
2121
};
22+
23+
int ia32_classify_syscall(unsigned syscall)
24+
{
25+
switch(syscall) {
26+
case __NR_open:
27+
return 2;
28+
case __NR_openat:
29+
return 3;
30+
case __NR_socketcall:
31+
return 4;
32+
case __NR_execve:
33+
return 5;
34+
default:
35+
return 1;
36+
}
37+
}

‎arch/ia64/kernel/audit.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ static unsigned chattr_class[] = {
2323
~0U
2424
};
2525

26+
int audit_classify_syscall(int abi, unsigned syscall)
27+
{
28+
#ifdef CONFIG_IA32_SUPPORT
29+
extern int ia32_classify_syscall(unsigned);
30+
if (abi == AUDIT_ARCH_I386)
31+
return ia32_classify_syscall(syscall);
32+
#endif
33+
switch(syscall) {
34+
case __NR_open:
35+
return 2;
36+
case __NR_openat:
37+
return 3;
38+
case __NR_execve:
39+
return 5;
40+
default:
41+
return 0;
42+
}
43+
}
44+
2645
static int __init audit_classes_init(void)
2746
{
2847
#ifdef CONFIG_IA32_SUPPORT

‎arch/powerpc/kernel/audit.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ static unsigned chattr_class[] = {
2323
~0U
2424
};
2525

26+
int audit_classify_syscall(int abi, unsigned syscall)
27+
{
28+
#ifdef CONFIG_PPC64
29+
extern int ppc32_classify_syscall(unsigned);
30+
if (abi == AUDIT_ARCH_PPC)
31+
return ppc32_classify_syscall(syscall);
32+
#endif
33+
switch(syscall) {
34+
case __NR_open:
35+
return 2;
36+
case __NR_openat:
37+
return 3;
38+
case __NR_socketcall:
39+
return 4;
40+
case __NR_execve:
41+
return 5;
42+
default:
43+
return 0;
44+
}
45+
}
46+
2647
static int __init audit_classes_init(void)
2748
{
2849
#ifdef CONFIG_PPC64

‎arch/powerpc/kernel/compat_audit.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,19 @@ unsigned ppc32_read_class[] = {
2020
#include <asm-generic/audit_read.h>
2121
~0U
2222
};
23+
24+
int ppc32_classify_syscall(unsigned syscall)
25+
{
26+
switch(syscall) {
27+
case __NR_open:
28+
return 2;
29+
case __NR_openat:
30+
return 3;
31+
case __NR_socketcall:
32+
return 4;
33+
case __NR_execve:
34+
return 5;
35+
default:
36+
return 1;
37+
}
38+
}

‎arch/s390/kernel/audit.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ static unsigned chattr_class[] = {
2323
~0U
2424
};
2525

26+
int audit_classify_syscall(int abi, unsigned syscall)
27+
{
28+
#ifdef CONFIG_COMPAT
29+
extern int s390_classify_syscall(unsigned);
30+
if (abi == AUDIT_ARCH_S390)
31+
return s390_classify_syscall(syscall);
32+
#endif
33+
switch(syscall) {
34+
case __NR_open:
35+
return 2;
36+
case __NR_openat:
37+
return 3;
38+
case __NR_socketcall:
39+
return 4;
40+
case __NR_execve:
41+
return 5;
42+
default:
43+
return 0;
44+
}
45+
}
46+
2647
static int __init audit_classes_init(void)
2748
{
2849
#ifdef CONFIG_COMPAT

‎arch/s390/kernel/compat_audit.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,19 @@ unsigned s390_read_class[] = {
2020
#include <asm-generic/audit_read.h>
2121
~0U
2222
};
23+
24+
int s390_classify_syscall(unsigned syscall)
25+
{
26+
switch(syscall) {
27+
case __NR_open:
28+
return 2;
29+
case __NR_openat:
30+
return 3;
31+
case __NR_socketcall:
32+
return 4;
33+
case __NR_execve:
34+
return 5;
35+
default:
36+
return 1;
37+
}
38+
}

‎arch/x86_64/ia32/audit.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@ unsigned ia32_read_class[] = {
1919
#include <asm-generic/audit_read.h>
2020
~0U
2121
};
22+
23+
int ia32_classify_syscall(unsigned syscall)
24+
{
25+
switch(syscall) {
26+
case __NR_open:
27+
return 2;
28+
case __NR_openat:
29+
return 3;
30+
case __NR_socketcall:
31+
return 4;
32+
case __NR_execve:
33+
return 5;
34+
default:
35+
return 1;
36+
}
37+
}

‎arch/x86_64/kernel/audit.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ static unsigned chattr_class[] = {
2323
~0U
2424
};
2525

26+
int audit_classify_syscall(int abi, unsigned syscall)
27+
{
28+
#ifdef CONFIG_IA32_EMULATION
29+
extern int ia32_classify_syscall(unsigned);
30+
if (abi == AUDIT_ARCH_I386)
31+
return ia32_classify_syscall(syscall);
32+
#endif
33+
switch(syscall) {
34+
case __NR_open:
35+
return 2;
36+
case __NR_openat:
37+
return 3;
38+
case __NR_execve:
39+
return 5;
40+
default:
41+
return 0;
42+
}
43+
}
44+
2645
static int __init audit_classes_init(void)
2746
{
2847
#ifdef CONFIG_IA32_EMULATION

‎include/linux/audit.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
#define AUDIT_EXIT 103
182182
#define AUDIT_SUCCESS 104 /* exit >= 0; value ignored */
183183
#define AUDIT_WATCH 105
184+
#define AUDIT_PERM 106
184185

185186
#define AUDIT_ARG0 200
186187
#define AUDIT_ARG1 (AUDIT_ARG0+1)
@@ -256,6 +257,11 @@
256257
#define AUDIT_ARCH_V850 (EM_V850|__AUDIT_ARCH_LE)
257258
#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
258259

260+
#define AUDIT_PERM_EXEC 1
261+
#define AUDIT_PERM_WRITE 2
262+
#define AUDIT_PERM_READ 4
263+
#define AUDIT_PERM_ATTR 8
264+
259265
struct audit_status {
260266
__u32 mask; /* Bit mask for valid entries */
261267
__u32 enabled; /* 1 = enabled, 0 = disabled */
@@ -318,6 +324,7 @@ struct mqstat;
318324
#define AUDITSC_FAILURE 2
319325
#define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS )
320326
extern int __init audit_register_class(int class, unsigned *list);
327+
extern int audit_classify_syscall(int abi, unsigned syscall);
321328
#ifdef CONFIG_AUDITSYSCALL
322329
/* These are defined in auditsc.c */
323330
/* Public API */

0 commit comments

Comments
 (0)