diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-07 22:06:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-07 22:06:04 -0400 |
commit | 02aff8db6438ce29371fd9cd54c57213f4bb4536 (patch) | |
tree | 283941483dbe579bf413d3a03b0538ff7bdc336d | |
parent | f72dae20891d7bcc43e9263ab206960b6ae5209f (diff) | |
parent | 70c4cf17e445264453bc5323db3e50aa0ac9e81f (diff) |
Merge tag 'audit-pr-20190507' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit
Pull audit updates from Paul Moore:
"We've got a reasonably broad set of audit patches for the v5.2 merge
window, the highlights are below:
- The biggest change, and the source of all the arch/* changes, is
the patchset from Dmitry to help enable some of the work he is
doing around PTRACE_GET_SYSCALL_INFO.
To be honest, including this in the audit tree is a bit of a
stretch, but it does help move audit a little further along towards
proper syscall auditing for all arches, and everyone else seemed to
agree that audit was a "good" spot for this to land (or maybe they
just didn't want to merge it? dunno.).
- We can now audit time/NTP adjustments.
- We continue the work to connect associated audit records into a
single event"
* tag 'audit-pr-20190507' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: (21 commits)
audit: fix a memory leak bug
ntp: Audit NTP parameters adjustment
timekeeping: Audit clock adjustments
audit: purge unnecessary list_empty calls
audit: link integrity evm_write_xattrs record to syscall event
syscall_get_arch: add "struct task_struct *" argument
unicore32: define syscall_get_arch()
Move EM_UNICORE to uapi/linux/elf-em.h
nios2: define syscall_get_arch()
nds32: define syscall_get_arch()
Move EM_NDS32 to uapi/linux/elf-em.h
m68k: define syscall_get_arch()
hexagon: define syscall_get_arch()
Move EM_HEXAGON to uapi/linux/elf-em.h
h8300: define syscall_get_arch()
c6x: define syscall_get_arch()
arc: define syscall_get_arch()
Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
audit: Make audit_log_cap and audit_copy_inode static
audit: connect LOGIN record to its syscall record
...
43 files changed, 331 insertions, 107 deletions
diff --git a/arch/alpha/include/asm/syscall.h b/arch/alpha/include/asm/syscall.h index d73a6fcb519c..11c688c1d7ec 100644 --- a/arch/alpha/include/asm/syscall.h +++ b/arch/alpha/include/asm/syscall.h | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | #include <uapi/linux/audit.h> | 5 | #include <uapi/linux/audit.h> |
6 | 6 | ||
7 | static inline int syscall_get_arch(void) | 7 | static inline int syscall_get_arch(struct task_struct *task) |
8 | { | 8 | { |
9 | return AUDIT_ARCH_ALPHA; | 9 | return AUDIT_ARCH_ALPHA; |
10 | } | 10 | } |
diff --git a/arch/arc/include/asm/elf.h b/arch/arc/include/asm/elf.h index aa2d6da9d187..2b80c184c9c8 100644 --- a/arch/arc/include/asm/elf.h +++ b/arch/arc/include/asm/elf.h | |||
@@ -10,13 +10,9 @@ | |||
10 | #define __ASM_ARC_ELF_H | 10 | #define __ASM_ARC_ELF_H |
11 | 11 | ||
12 | #include <linux/types.h> | 12 | #include <linux/types.h> |
13 | #include <linux/elf-em.h> | ||
13 | #include <uapi/asm/elf.h> | 14 | #include <uapi/asm/elf.h> |
14 | 15 | ||
15 | /* These ELF defines belong to uapi but libc elf.h already defines them */ | ||
16 | #define EM_ARCOMPACT 93 | ||
17 | |||
18 | #define EM_ARCV2 195 /* ARCv2 Cores */ | ||
19 | |||
20 | #define EM_ARC_INUSE (IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \ | 16 | #define EM_ARC_INUSE (IS_ENABLED(CONFIG_ISA_ARCOMPACT) ? \ |
21 | EM_ARCOMPACT : EM_ARCV2) | 17 | EM_ARCOMPACT : EM_ARCV2) |
22 | 18 | ||
diff --git a/arch/arc/include/asm/syscall.h b/arch/arc/include/asm/syscall.h index c7a4201ed62b..9cac959ca4e8 100644 --- a/arch/arc/include/asm/syscall.h +++ b/arch/arc/include/asm/syscall.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #ifndef _ASM_ARC_SYSCALL_H | 9 | #ifndef _ASM_ARC_SYSCALL_H |
10 | #define _ASM_ARC_SYSCALL_H 1 | 10 | #define _ASM_ARC_SYSCALL_H 1 |
11 | 11 | ||
12 | #include <uapi/linux/audit.h> | ||
12 | #include <linux/err.h> | 13 | #include <linux/err.h> |
13 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
14 | #include <asm/unistd.h> | 15 | #include <asm/unistd.h> |
@@ -67,4 +68,14 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, | |||
67 | } | 68 | } |
68 | } | 69 | } |
69 | 70 | ||
71 | static inline int | ||
72 | syscall_get_arch(struct task_struct *task) | ||
73 | { | ||
74 | return IS_ENABLED(CONFIG_ISA_ARCOMPACT) | ||
75 | ? (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) | ||
76 | ? AUDIT_ARCH_ARCOMPACTBE : AUDIT_ARCH_ARCOMPACT) | ||
77 | : (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) | ||
78 | ? AUDIT_ARCH_ARCV2BE : AUDIT_ARCH_ARCV2); | ||
79 | } | ||
80 | |||
70 | #endif | 81 | #endif |
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h index 080ce70cab12..fd02761ba06c 100644 --- a/arch/arm/include/asm/syscall.h +++ b/arch/arm/include/asm/syscall.h | |||
@@ -73,7 +73,7 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
73 | memcpy(®s->ARM_r0 + 1, args, 5 * sizeof(args[0])); | 73 | memcpy(®s->ARM_r0 + 1, args, 5 * sizeof(args[0])); |
74 | } | 74 | } |
75 | 75 | ||
76 | static inline int syscall_get_arch(void) | 76 | static inline int syscall_get_arch(struct task_struct *task) |
77 | { | 77 | { |
78 | /* ARM tasks don't change audit architectures on the fly. */ | 78 | /* ARM tasks don't change audit architectures on the fly. */ |
79 | return AUDIT_ARCH_ARM; | 79 | return AUDIT_ARCH_ARM; |
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h index a179df3674a1..a65167f5cded 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h | |||
@@ -87,9 +87,9 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
87 | * We don't care about endianness (__AUDIT_ARCH_LE bit) here because | 87 | * We don't care about endianness (__AUDIT_ARCH_LE bit) here because |
88 | * AArch64 has the same system calls both on little- and big- endian. | 88 | * AArch64 has the same system calls both on little- and big- endian. |
89 | */ | 89 | */ |
90 | static inline int syscall_get_arch(void) | 90 | static inline int syscall_get_arch(struct task_struct *task) |
91 | { | 91 | { |
92 | if (is_compat_task()) | 92 | if (is_compat_thread(task_thread_info(task))) |
93 | return AUDIT_ARCH_ARM; | 93 | return AUDIT_ARCH_ARM; |
94 | 94 | ||
95 | return AUDIT_ARCH_AARCH64; | 95 | return AUDIT_ARCH_AARCH64; |
diff --git a/arch/c6x/include/asm/syscall.h b/arch/c6x/include/asm/syscall.h index 15ba8599858e..5bcdcb651b19 100644 --- a/arch/c6x/include/asm/syscall.h +++ b/arch/c6x/include/asm/syscall.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #ifndef __ASM_C6X_SYSCALL_H | 11 | #ifndef __ASM_C6X_SYSCALL_H |
12 | #define __ASM_C6X_SYSCALL_H | 12 | #define __ASM_C6X_SYSCALL_H |
13 | 13 | ||
14 | #include <uapi/linux/audit.h> | ||
14 | #include <linux/err.h> | 15 | #include <linux/err.h> |
15 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
16 | 17 | ||
@@ -69,4 +70,10 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
69 | regs->a9 = *args; | 70 | regs->a9 = *args; |
70 | } | 71 | } |
71 | 72 | ||
73 | static inline int syscall_get_arch(struct task_struct *task) | ||
74 | { | ||
75 | return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) | ||
76 | ? AUDIT_ARCH_C6XBE : AUDIT_ARCH_C6X; | ||
77 | } | ||
78 | |||
72 | #endif /* __ASM_C6X_SYSCALLS_H */ | 79 | #endif /* __ASM_C6X_SYSCALLS_H */ |
diff --git a/arch/csky/include/asm/syscall.h b/arch/csky/include/asm/syscall.h index bda0a446c63e..bc0d8717d28b 100644 --- a/arch/csky/include/asm/syscall.h +++ b/arch/csky/include/asm/syscall.h | |||
@@ -60,7 +60,7 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, | |||
60 | } | 60 | } |
61 | 61 | ||
62 | static inline int | 62 | static inline int |
63 | syscall_get_arch(void) | 63 | syscall_get_arch(struct task_struct *task) |
64 | { | 64 | { |
65 | return AUDIT_ARCH_CSKY; | 65 | return AUDIT_ARCH_CSKY; |
66 | } | 66 | } |
diff --git a/arch/h8300/include/asm/syscall.h b/arch/h8300/include/asm/syscall.h index ddd483c6ca95..01666b8bb263 100644 --- a/arch/h8300/include/asm/syscall.h +++ b/arch/h8300/include/asm/syscall.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/linkage.h> | 8 | #include <linux/linkage.h> |
9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <linux/ptrace.h> | 10 | #include <linux/ptrace.h> |
11 | #include <uapi/linux/audit.h> | ||
11 | 12 | ||
12 | static inline int | 13 | static inline int |
13 | syscall_get_nr(struct task_struct *task, struct pt_regs *regs) | 14 | syscall_get_nr(struct task_struct *task, struct pt_regs *regs) |
@@ -27,6 +28,11 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, | |||
27 | *args = regs->er6; | 28 | *args = regs->er6; |
28 | } | 29 | } |
29 | 30 | ||
31 | static inline int | ||
32 | syscall_get_arch(struct task_struct *task) | ||
33 | { | ||
34 | return AUDIT_ARCH_H8300; | ||
35 | } | ||
30 | 36 | ||
31 | 37 | ||
32 | /* Misc syscall related bits */ | 38 | /* Misc syscall related bits */ |
diff --git a/arch/hexagon/include/asm/elf.h b/arch/hexagon/include/asm/elf.h index 80311e7b8ca6..d10fbd54ae51 100644 --- a/arch/hexagon/include/asm/elf.h +++ b/arch/hexagon/include/asm/elf.h | |||
@@ -23,11 +23,7 @@ | |||
23 | 23 | ||
24 | #include <asm/ptrace.h> | 24 | #include <asm/ptrace.h> |
25 | #include <asm/user.h> | 25 | #include <asm/user.h> |
26 | 26 | #include <linux/elf-em.h> | |
27 | /* | ||
28 | * This should really be in linux/elf-em.h. | ||
29 | */ | ||
30 | #define EM_HEXAGON 164 /* QUALCOMM Hexagon */ | ||
31 | 27 | ||
32 | struct elf32_hdr; | 28 | struct elf32_hdr; |
33 | 29 | ||
diff --git a/arch/hexagon/include/asm/syscall.h b/arch/hexagon/include/asm/syscall.h index ae3a1e24fabd..dab26a71f577 100644 --- a/arch/hexagon/include/asm/syscall.h +++ b/arch/hexagon/include/asm/syscall.h | |||
@@ -21,6 +21,8 @@ | |||
21 | #ifndef _ASM_HEXAGON_SYSCALL_H | 21 | #ifndef _ASM_HEXAGON_SYSCALL_H |
22 | #define _ASM_HEXAGON_SYSCALL_H | 22 | #define _ASM_HEXAGON_SYSCALL_H |
23 | 23 | ||
24 | #include <uapi/linux/audit.h> | ||
25 | |||
24 | typedef long (*syscall_fn)(unsigned long, unsigned long, | 26 | typedef long (*syscall_fn)(unsigned long, unsigned long, |
25 | unsigned long, unsigned long, | 27 | unsigned long, unsigned long, |
26 | unsigned long, unsigned long); | 28 | unsigned long, unsigned long); |
@@ -41,4 +43,10 @@ static inline void syscall_get_arguments(struct task_struct *task, | |||
41 | { | 43 | { |
42 | memcpy(args, &(®s->r00)[0], 6 * sizeof(args[0])); | 44 | memcpy(args, &(®s->r00)[0], 6 * sizeof(args[0])); |
43 | } | 45 | } |
46 | |||
47 | static inline int syscall_get_arch(struct task_struct *task) | ||
48 | { | ||
49 | return AUDIT_ARCH_HEXAGON; | ||
50 | } | ||
51 | |||
44 | #endif | 52 | #endif |
diff --git a/arch/ia64/include/asm/syscall.h b/arch/ia64/include/asm/syscall.h index 0d9e7fab4a79..da108cd45174 100644 --- a/arch/ia64/include/asm/syscall.h +++ b/arch/ia64/include/asm/syscall.h | |||
@@ -74,7 +74,7 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
74 | ia64_syscall_get_set_arguments(task, regs, args, 1); | 74 | ia64_syscall_get_set_arguments(task, regs, args, 1); |
75 | } | 75 | } |
76 | 76 | ||
77 | static inline int syscall_get_arch(void) | 77 | static inline int syscall_get_arch(struct task_struct *task) |
78 | { | 78 | { |
79 | return AUDIT_ARCH_IA64; | 79 | return AUDIT_ARCH_IA64; |
80 | } | 80 | } |
diff --git a/arch/m68k/include/asm/syscall.h b/arch/m68k/include/asm/syscall.h new file mode 100644 index 000000000000..465ac039be09 --- /dev/null +++ b/arch/m68k/include/asm/syscall.h | |||
@@ -0,0 +1,12 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | #ifndef _ASM_M68K_SYSCALL_H | ||
3 | #define _ASM_M68K_SYSCALL_H | ||
4 | |||
5 | #include <uapi/linux/audit.h> | ||
6 | |||
7 | static inline int syscall_get_arch(struct task_struct *task) | ||
8 | { | ||
9 | return AUDIT_ARCH_M68K; | ||
10 | } | ||
11 | |||
12 | #endif /* _ASM_M68K_SYSCALL_H */ | ||
diff --git a/arch/microblaze/include/asm/syscall.h b/arch/microblaze/include/asm/syscall.h index 833d3a53dab3..3a6924f3cbde 100644 --- a/arch/microblaze/include/asm/syscall.h +++ b/arch/microblaze/include/asm/syscall.h | |||
@@ -105,7 +105,7 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
105 | asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs); | 105 | asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs); |
106 | asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); | 106 | asmlinkage void do_syscall_trace_leave(struct pt_regs *regs); |
107 | 107 | ||
108 | static inline int syscall_get_arch(void) | 108 | static inline int syscall_get_arch(struct task_struct *task) |
109 | { | 109 | { |
110 | return AUDIT_ARCH_MICROBLAZE; | 110 | return AUDIT_ARCH_MICROBLAZE; |
111 | } | 111 | } |
diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h index a2b4748655df..acf80ae0a430 100644 --- a/arch/mips/include/asm/syscall.h +++ b/arch/mips/include/asm/syscall.h | |||
@@ -141,14 +141,14 @@ extern const unsigned long sys_call_table[]; | |||
141 | extern const unsigned long sys32_call_table[]; | 141 | extern const unsigned long sys32_call_table[]; |
142 | extern const unsigned long sysn32_call_table[]; | 142 | extern const unsigned long sysn32_call_table[]; |
143 | 143 | ||
144 | static inline int syscall_get_arch(void) | 144 | static inline int syscall_get_arch(struct task_struct *task) |
145 | { | 145 | { |
146 | int arch = AUDIT_ARCH_MIPS; | 146 | int arch = AUDIT_ARCH_MIPS; |
147 | #ifdef CONFIG_64BIT | 147 | #ifdef CONFIG_64BIT |
148 | if (!test_thread_flag(TIF_32BIT_REGS)) { | 148 | if (!test_tsk_thread_flag(task, TIF_32BIT_REGS)) { |
149 | arch |= __AUDIT_ARCH_64BIT; | 149 | arch |= __AUDIT_ARCH_64BIT; |
150 | /* N32 sets only TIF_32BIT_ADDR */ | 150 | /* N32 sets only TIF_32BIT_ADDR */ |
151 | if (test_thread_flag(TIF_32BIT_ADDR)) | 151 | if (test_tsk_thread_flag(task, TIF_32BIT_ADDR)) |
152 | arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32; | 152 | arch |= __AUDIT_ARCH_CONVENTION_MIPS64_N32; |
153 | } | 153 | } |
154 | #endif | 154 | #endif |
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 3a62f80958e1..414b6e9c900b 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
@@ -1418,7 +1418,7 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall) | |||
1418 | unsigned long args[6]; | 1418 | unsigned long args[6]; |
1419 | 1419 | ||
1420 | sd.nr = syscall; | 1420 | sd.nr = syscall; |
1421 | sd.arch = syscall_get_arch(); | 1421 | sd.arch = syscall_get_arch(current); |
1422 | syscall_get_arguments(current, regs, args); | 1422 | syscall_get_arguments(current, regs, args); |
1423 | for (i = 0; i < 6; i++) | 1423 | for (i = 0; i < 6; i++) |
1424 | sd.args[i] = args[i]; | 1424 | sd.args[i] = args[i]; |
diff --git a/arch/nds32/include/asm/elf.h b/arch/nds32/include/asm/elf.h index 95f3ea253e4c..02250626b9f0 100644 --- a/arch/nds32/include/asm/elf.h +++ b/arch/nds32/include/asm/elf.h | |||
@@ -10,14 +10,13 @@ | |||
10 | 10 | ||
11 | #include <asm/ptrace.h> | 11 | #include <asm/ptrace.h> |
12 | #include <asm/fpu.h> | 12 | #include <asm/fpu.h> |
13 | #include <linux/elf-em.h> | ||
13 | 14 | ||
14 | typedef unsigned long elf_greg_t; | 15 | typedef unsigned long elf_greg_t; |
15 | typedef unsigned long elf_freg_t[3]; | 16 | typedef unsigned long elf_freg_t[3]; |
16 | 17 | ||
17 | extern unsigned int elf_hwcap; | 18 | extern unsigned int elf_hwcap; |
18 | 19 | ||
19 | #define EM_NDS32 167 | ||
20 | |||
21 | #define R_NDS32_NONE 0 | 20 | #define R_NDS32_NONE 0 |
22 | #define R_NDS32_16_RELA 19 | 21 | #define R_NDS32_16_RELA 19 |
23 | #define R_NDS32_32_RELA 20 | 22 | #define R_NDS32_32_RELA 20 |
diff --git a/arch/nds32/include/asm/syscall.h b/arch/nds32/include/asm/syscall.h index 671ebd357496..174b8571d362 100644 --- a/arch/nds32/include/asm/syscall.h +++ b/arch/nds32/include/asm/syscall.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #ifndef _ASM_NDS32_SYSCALL_H | 5 | #ifndef _ASM_NDS32_SYSCALL_H |
6 | #define _ASM_NDS32_SYSCALL_H 1 | 6 | #define _ASM_NDS32_SYSCALL_H 1 |
7 | 7 | ||
8 | #include <uapi/linux/audit.h> | ||
8 | #include <linux/err.h> | 9 | #include <linux/err.h> |
9 | struct task_struct; | 10 | struct task_struct; |
10 | struct pt_regs; | 11 | struct pt_regs; |
@@ -145,4 +146,12 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, | |||
145 | 146 | ||
146 | memcpy(®s->uregs[0] + 1, args, 5 * sizeof(args[0])); | 147 | memcpy(®s->uregs[0] + 1, args, 5 * sizeof(args[0])); |
147 | } | 148 | } |
149 | |||
150 | static inline int | ||
151 | syscall_get_arch(struct task_struct *task) | ||
152 | { | ||
153 | return IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) | ||
154 | ? AUDIT_ARCH_NDS32BE : AUDIT_ARCH_NDS32; | ||
155 | } | ||
156 | |||
148 | #endif /* _ASM_NDS32_SYSCALL_H */ | 157 | #endif /* _ASM_NDS32_SYSCALL_H */ |
diff --git a/arch/nios2/include/asm/syscall.h b/arch/nios2/include/asm/syscall.h index d7624ed06efb..c4f3f8b86f28 100644 --- a/arch/nios2/include/asm/syscall.h +++ b/arch/nios2/include/asm/syscall.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #ifndef __ASM_NIOS2_SYSCALL_H__ | 17 | #ifndef __ASM_NIOS2_SYSCALL_H__ |
18 | #define __ASM_NIOS2_SYSCALL_H__ | 18 | #define __ASM_NIOS2_SYSCALL_H__ |
19 | 19 | ||
20 | #include <uapi/linux/audit.h> | ||
20 | #include <linux/err.h> | 21 | #include <linux/err.h> |
21 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
22 | 23 | ||
@@ -79,4 +80,9 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
79 | regs->r9 = *args; | 80 | regs->r9 = *args; |
80 | } | 81 | } |
81 | 82 | ||
83 | static inline int syscall_get_arch(struct task_struct *task) | ||
84 | { | ||
85 | return AUDIT_ARCH_NIOS2; | ||
86 | } | ||
87 | |||
82 | #endif | 88 | #endif |
diff --git a/arch/openrisc/include/asm/syscall.h b/arch/openrisc/include/asm/syscall.h index b4ff07c1baed..61de227f53a1 100644 --- a/arch/openrisc/include/asm/syscall.h +++ b/arch/openrisc/include/asm/syscall.h | |||
@@ -68,7 +68,7 @@ syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, | |||
68 | memcpy(®s->gpr[3], args, 6 * sizeof(args[0])); | 68 | memcpy(®s->gpr[3], args, 6 * sizeof(args[0])); |
69 | } | 69 | } |
70 | 70 | ||
71 | static inline int syscall_get_arch(void) | 71 | static inline int syscall_get_arch(struct task_struct *task) |
72 | { | 72 | { |
73 | return AUDIT_ARCH_OPENRISC; | 73 | return AUDIT_ARCH_OPENRISC; |
74 | } | 74 | } |
diff --git a/arch/parisc/include/asm/syscall.h b/arch/parisc/include/asm/syscall.h index 62a6d477fae0..80757e43cf2c 100644 --- a/arch/parisc/include/asm/syscall.h +++ b/arch/parisc/include/asm/syscall.h | |||
@@ -48,11 +48,11 @@ static inline void syscall_rollback(struct task_struct *task, | |||
48 | /* do nothing */ | 48 | /* do nothing */ |
49 | } | 49 | } |
50 | 50 | ||
51 | static inline int syscall_get_arch(void) | 51 | static inline int syscall_get_arch(struct task_struct *task) |
52 | { | 52 | { |
53 | int arch = AUDIT_ARCH_PARISC; | 53 | int arch = AUDIT_ARCH_PARISC; |
54 | #ifdef CONFIG_64BIT | 54 | #ifdef CONFIG_64BIT |
55 | if (!is_compat_task()) | 55 | if (!__is_compat_task(task)) |
56 | arch = AUDIT_ARCH_PARISC64; | 56 | arch = AUDIT_ARCH_PARISC64; |
57 | #endif | 57 | #endif |
58 | return arch; | 58 | return arch; |
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h index 1243045bad2d..a048fed0722f 100644 --- a/arch/powerpc/include/asm/syscall.h +++ b/arch/powerpc/include/asm/syscall.h | |||
@@ -94,9 +94,15 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
94 | regs->orig_gpr3 = args[0]; | 94 | regs->orig_gpr3 = args[0]; |
95 | } | 95 | } |
96 | 96 | ||
97 | static inline int syscall_get_arch(void) | 97 | static inline int syscall_get_arch(struct task_struct *task) |
98 | { | 98 | { |
99 | int arch = is_32bit_task() ? AUDIT_ARCH_PPC : AUDIT_ARCH_PPC64; | 99 | int arch; |
100 | |||
101 | if (IS_ENABLED(CONFIG_PPC64) && !test_tsk_thread_flag(task, TIF_32BIT)) | ||
102 | arch = AUDIT_ARCH_PPC64; | ||
103 | else | ||
104 | arch = AUDIT_ARCH_PPC; | ||
105 | |||
100 | #ifdef __LITTLE_ENDIAN__ | 106 | #ifdef __LITTLE_ENDIAN__ |
101 | arch |= __AUDIT_ARCH_LE; | 107 | arch |= __AUDIT_ARCH_LE; |
102 | #endif | 108 | #endif |
diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h index a3d5273ded7c..0f2fe1794c8f 100644 --- a/arch/riscv/include/asm/syscall.h +++ b/arch/riscv/include/asm/syscall.h | |||
@@ -88,7 +88,7 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
88 | memcpy(®s->a1, args, 5 * sizeof(regs->a1)); | 88 | memcpy(®s->a1, args, 5 * sizeof(regs->a1)); |
89 | } | 89 | } |
90 | 90 | ||
91 | static inline int syscall_get_arch(void) | 91 | static inline int syscall_get_arch(struct task_struct *task) |
92 | { | 92 | { |
93 | #ifdef CONFIG_64BIT | 93 | #ifdef CONFIG_64BIT |
94 | return AUDIT_ARCH_RISCV64; | 94 | return AUDIT_ARCH_RISCV64; |
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h index ab3407aa4fd8..f073292e9fdb 100644 --- a/arch/s390/include/asm/syscall.h +++ b/arch/s390/include/asm/syscall.h | |||
@@ -79,10 +79,10 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
79 | regs->orig_gpr2 = args[0]; | 79 | regs->orig_gpr2 = args[0]; |
80 | } | 80 | } |
81 | 81 | ||
82 | static inline int syscall_get_arch(void) | 82 | static inline int syscall_get_arch(struct task_struct *task) |
83 | { | 83 | { |
84 | #ifdef CONFIG_COMPAT | 84 | #ifdef CONFIG_COMPAT |
85 | if (test_tsk_thread_flag(current, TIF_31BIT)) | 85 | if (test_tsk_thread_flag(task, TIF_31BIT)) |
86 | return AUDIT_ARCH_S390; | 86 | return AUDIT_ARCH_S390; |
87 | #endif | 87 | #endif |
88 | return AUDIT_ARCH_S390X; | 88 | return AUDIT_ARCH_S390X; |
diff --git a/arch/sh/include/asm/syscall_32.h b/arch/sh/include/asm/syscall_32.h index 8c9d7e5e5dcc..0b5b8e75edac 100644 --- a/arch/sh/include/asm/syscall_32.h +++ b/arch/sh/include/asm/syscall_32.h | |||
@@ -72,7 +72,7 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
72 | regs->regs[4] = args[0]; | 72 | regs->regs[4] = args[0]; |
73 | } | 73 | } |
74 | 74 | ||
75 | static inline int syscall_get_arch(void) | 75 | static inline int syscall_get_arch(struct task_struct *task) |
76 | { | 76 | { |
77 | int arch = AUDIT_ARCH_SH; | 77 | int arch = AUDIT_ARCH_SH; |
78 | 78 | ||
diff --git a/arch/sh/include/asm/syscall_64.h b/arch/sh/include/asm/syscall_64.h index 22fad97da066..72efcbc76f91 100644 --- a/arch/sh/include/asm/syscall_64.h +++ b/arch/sh/include/asm/syscall_64.h | |||
@@ -59,7 +59,7 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
59 | memcpy(®s->regs[2], args, 6 * sizeof(args[0])); | 59 | memcpy(®s->regs[2], args, 6 * sizeof(args[0])); |
60 | } | 60 | } |
61 | 61 | ||
62 | static inline int syscall_get_arch(void) | 62 | static inline int syscall_get_arch(struct task_struct *task) |
63 | { | 63 | { |
64 | int arch = AUDIT_ARCH_SH; | 64 | int arch = AUDIT_ARCH_SH; |
65 | 65 | ||
diff --git a/arch/sparc/include/asm/syscall.h b/arch/sparc/include/asm/syscall.h index 4d075434e816..62a5a78804c4 100644 --- a/arch/sparc/include/asm/syscall.h +++ b/arch/sparc/include/asm/syscall.h | |||
@@ -127,10 +127,11 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
127 | regs->u_regs[UREG_I0 + i] = args[i]; | 127 | regs->u_regs[UREG_I0 + i] = args[i]; |
128 | } | 128 | } |
129 | 129 | ||
130 | static inline int syscall_get_arch(void) | 130 | static inline int syscall_get_arch(struct task_struct *task) |
131 | { | 131 | { |
132 | #if defined(CONFIG_SPARC64) && defined(CONFIG_COMPAT) | 132 | #if defined(CONFIG_SPARC64) && defined(CONFIG_COMPAT) |
133 | return in_compat_syscall() ? AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC64; | 133 | return test_tsk_thread_flag(task, TIF_32BIT) |
134 | ? AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC64; | ||
134 | #elif defined(CONFIG_SPARC64) | 135 | #elif defined(CONFIG_SPARC64) |
135 | return AUDIT_ARCH_SPARC64; | 136 | return AUDIT_ARCH_SPARC64; |
136 | #else | 137 | #else |
diff --git a/arch/unicore32/include/asm/elf.h b/arch/unicore32/include/asm/elf.h index 829042d07722..ae66dc1be49e 100644 --- a/arch/unicore32/include/asm/elf.h +++ b/arch/unicore32/include/asm/elf.h | |||
@@ -19,6 +19,7 @@ | |||
19 | * ELF register definitions.. | 19 | * ELF register definitions.. |
20 | */ | 20 | */ |
21 | #include <asm/ptrace.h> | 21 | #include <asm/ptrace.h> |
22 | #include <linux/elf-em.h> | ||
22 | 23 | ||
23 | typedef unsigned long elf_greg_t; | 24 | typedef unsigned long elf_greg_t; |
24 | typedef unsigned long elf_freg_t[3]; | 25 | typedef unsigned long elf_freg_t[3]; |
@@ -28,8 +29,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG]; | |||
28 | 29 | ||
29 | typedef struct fp_state elf_fpregset_t; | 30 | typedef struct fp_state elf_fpregset_t; |
30 | 31 | ||
31 | #define EM_UNICORE 110 | ||
32 | |||
33 | #define R_UNICORE_NONE 0 | 32 | #define R_UNICORE_NONE 0 |
34 | #define R_UNICORE_PC24 1 | 33 | #define R_UNICORE_PC24 1 |
35 | #define R_UNICORE_ABS32 2 | 34 | #define R_UNICORE_ABS32 2 |
diff --git a/arch/unicore32/include/asm/syscall.h b/arch/unicore32/include/asm/syscall.h new file mode 100644 index 000000000000..607961797fff --- /dev/null +++ b/arch/unicore32/include/asm/syscall.h | |||
@@ -0,0 +1,12 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | #ifndef _ASM_UNICORE_SYSCALL_H | ||
3 | #define _ASM_UNICORE_SYSCALL_H | ||
4 | |||
5 | #include <uapi/linux/audit.h> | ||
6 | |||
7 | static inline int syscall_get_arch(struct task_struct *task) | ||
8 | { | ||
9 | return AUDIT_ARCH_UNICORE; | ||
10 | } | ||
11 | |||
12 | #endif /* _ASM_UNICORE_SYSCALL_H */ | ||
diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index 4c305471ec33..b05ad16174e5 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h | |||
@@ -105,7 +105,7 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
105 | memcpy(®s->bx + i, args, n * sizeof(args[0])); | 105 | memcpy(®s->bx + i, args, n * sizeof(args[0])); |
106 | } | 106 | } |
107 | 107 | ||
108 | static inline int syscall_get_arch(void) | 108 | static inline int syscall_get_arch(struct task_struct *task) |
109 | { | 109 | { |
110 | return AUDIT_ARCH_I386; | 110 | return AUDIT_ARCH_I386; |
111 | } | 111 | } |
@@ -160,10 +160,12 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | static inline int syscall_get_arch(void) | 163 | static inline int syscall_get_arch(struct task_struct *task) |
164 | { | 164 | { |
165 | /* x32 tasks should be considered AUDIT_ARCH_X86_64. */ | 165 | /* x32 tasks should be considered AUDIT_ARCH_X86_64. */ |
166 | return in_ia32_syscall() ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64; | 166 | return (IS_ENABLED(CONFIG_IA32_EMULATION) && |
167 | task->thread_info.status & TS_COMPAT) | ||
168 | ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64; | ||
167 | } | 169 | } |
168 | #endif /* CONFIG_X86_32 */ | 170 | #endif /* CONFIG_X86_32 */ |
169 | 171 | ||
diff --git a/arch/x86/um/asm/syscall.h b/arch/x86/um/asm/syscall.h index ef898af102d1..56a2f0913e3c 100644 --- a/arch/x86/um/asm/syscall.h +++ b/arch/x86/um/asm/syscall.h | |||
@@ -9,7 +9,7 @@ typedef asmlinkage long (*sys_call_ptr_t)(unsigned long, unsigned long, | |||
9 | unsigned long, unsigned long, | 9 | unsigned long, unsigned long, |
10 | unsigned long, unsigned long); | 10 | unsigned long, unsigned long); |
11 | 11 | ||
12 | static inline int syscall_get_arch(void) | 12 | static inline int syscall_get_arch(struct task_struct *task) |
13 | { | 13 | { |
14 | #ifdef CONFIG_X86_32 | 14 | #ifdef CONFIG_X86_32 |
15 | return AUDIT_ARCH_I386; | 15 | return AUDIT_ARCH_I386; |
diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h index 91dc06d58060..359ab40e935a 100644 --- a/arch/xtensa/include/asm/syscall.h +++ b/arch/xtensa/include/asm/syscall.h | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <asm/ptrace.h> | 14 | #include <asm/ptrace.h> |
15 | #include <uapi/linux/audit.h> | 15 | #include <uapi/linux/audit.h> |
16 | 16 | ||
17 | static inline int syscall_get_arch(void) | 17 | static inline int syscall_get_arch(struct task_struct *task) |
18 | { | 18 | { |
19 | return AUDIT_ARCH_XTENSA; | 19 | return AUDIT_ARCH_XTENSA; |
20 | } | 20 | } |
diff --git a/include/asm-generic/syscall.h b/include/asm-generic/syscall.h index b88239e9efe4..e06b468a0ebe 100644 --- a/include/asm-generic/syscall.h +++ b/include/asm-generic/syscall.h | |||
@@ -133,14 +133,15 @@ void syscall_set_arguments(struct task_struct *task, struct pt_regs *regs, | |||
133 | 133 | ||
134 | /** | 134 | /** |
135 | * syscall_get_arch - return the AUDIT_ARCH for the current system call | 135 | * syscall_get_arch - return the AUDIT_ARCH for the current system call |
136 | * @task: task of interest, must be blocked | ||
136 | * | 137 | * |
137 | * Returns the AUDIT_ARCH_* based on the system call convention in use. | 138 | * Returns the AUDIT_ARCH_* based on the system call convention in use. |
138 | * | 139 | * |
139 | * It's only valid to call this when current is stopped on entry to a system | 140 | * It's only valid to call this when @task is stopped on entry to a system |
140 | * call, due to %TIF_SYSCALL_TRACE, %TIF_SYSCALL_AUDIT, or %TIF_SECCOMP. | 141 | * call, due to %TIF_SYSCALL_TRACE, %TIF_SYSCALL_AUDIT, or %TIF_SECCOMP. |
141 | * | 142 | * |
142 | * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must | 143 | * Architectures which permit CONFIG_HAVE_ARCH_SECCOMP_FILTER must |
143 | * provide an implementation of this. | 144 | * provide an implementation of this. |
144 | */ | 145 | */ |
145 | int syscall_get_arch(void); | 146 | int syscall_get_arch(struct task_struct *task); |
146 | #endif /* _ASM_SYSCALL_H */ | 147 | #endif /* _ASM_SYSCALL_H */ |
diff --git a/include/linux/audit.h b/include/linux/audit.h index 1e69d9fe16da..43a23e28ba23 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -86,6 +86,29 @@ struct audit_field { | |||
86 | u32 op; | 86 | u32 op; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | enum audit_ntp_type { | ||
90 | AUDIT_NTP_OFFSET, | ||
91 | AUDIT_NTP_FREQ, | ||
92 | AUDIT_NTP_STATUS, | ||
93 | AUDIT_NTP_TAI, | ||
94 | AUDIT_NTP_TICK, | ||
95 | AUDIT_NTP_ADJUST, | ||
96 | |||
97 | AUDIT_NTP_NVALS /* count */ | ||
98 | }; | ||
99 | |||
100 | #ifdef CONFIG_AUDITSYSCALL | ||
101 | struct audit_ntp_val { | ||
102 | long long oldval, newval; | ||
103 | }; | ||
104 | |||
105 | struct audit_ntp_data { | ||
106 | struct audit_ntp_val vals[AUDIT_NTP_NVALS]; | ||
107 | }; | ||
108 | #else | ||
109 | struct audit_ntp_data {}; | ||
110 | #endif | ||
111 | |||
89 | extern int is_audit_feature_set(int which); | 112 | extern int is_audit_feature_set(int which); |
90 | 113 | ||
91 | extern int __init audit_register_class(int class, unsigned *list); | 114 | extern int __init audit_register_class(int class, unsigned *list); |
@@ -365,6 +388,8 @@ extern void __audit_log_capset(const struct cred *new, const struct cred *old); | |||
365 | extern void __audit_mmap_fd(int fd, int flags); | 388 | extern void __audit_mmap_fd(int fd, int flags); |
366 | extern void __audit_log_kern_module(char *name); | 389 | extern void __audit_log_kern_module(char *name); |
367 | extern void __audit_fanotify(unsigned int response); | 390 | extern void __audit_fanotify(unsigned int response); |
391 | extern void __audit_tk_injoffset(struct timespec64 offset); | ||
392 | extern void __audit_ntp_log(const struct audit_ntp_data *ad); | ||
368 | 393 | ||
369 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) | 394 | static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) |
370 | { | 395 | { |
@@ -467,6 +492,39 @@ static inline void audit_fanotify(unsigned int response) | |||
467 | __audit_fanotify(response); | 492 | __audit_fanotify(response); |
468 | } | 493 | } |
469 | 494 | ||
495 | static inline void audit_tk_injoffset(struct timespec64 offset) | ||
496 | { | ||
497 | /* ignore no-op events */ | ||
498 | if (offset.tv_sec == 0 && offset.tv_nsec == 0) | ||
499 | return; | ||
500 | |||
501 | if (!audit_dummy_context()) | ||
502 | __audit_tk_injoffset(offset); | ||
503 | } | ||
504 | |||
505 | static inline void audit_ntp_init(struct audit_ntp_data *ad) | ||
506 | { | ||
507 | memset(ad, 0, sizeof(*ad)); | ||
508 | } | ||
509 | |||
510 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, | ||
511 | enum audit_ntp_type type, long long val) | ||
512 | { | ||
513 | ad->vals[type].oldval = val; | ||
514 | } | ||
515 | |||
516 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, | ||
517 | enum audit_ntp_type type, long long val) | ||
518 | { | ||
519 | ad->vals[type].newval = val; | ||
520 | } | ||
521 | |||
522 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) | ||
523 | { | ||
524 | if (!audit_dummy_context()) | ||
525 | __audit_ntp_log(ad); | ||
526 | } | ||
527 | |||
470 | extern int audit_n_rules; | 528 | extern int audit_n_rules; |
471 | extern int audit_signals; | 529 | extern int audit_signals; |
472 | #else /* CONFIG_AUDITSYSCALL */ | 530 | #else /* CONFIG_AUDITSYSCALL */ |
@@ -580,6 +638,23 @@ static inline void audit_log_kern_module(char *name) | |||
580 | static inline void audit_fanotify(unsigned int response) | 638 | static inline void audit_fanotify(unsigned int response) |
581 | { } | 639 | { } |
582 | 640 | ||
641 | static inline void audit_tk_injoffset(struct timespec64 offset) | ||
642 | { } | ||
643 | |||
644 | static inline void audit_ntp_init(struct audit_ntp_data *ad) | ||
645 | { } | ||
646 | |||
647 | static inline void audit_ntp_set_old(struct audit_ntp_data *ad, | ||
648 | enum audit_ntp_type type, long long val) | ||
649 | { } | ||
650 | |||
651 | static inline void audit_ntp_set_new(struct audit_ntp_data *ad, | ||
652 | enum audit_ntp_type type, long long val) | ||
653 | { } | ||
654 | |||
655 | static inline void audit_ntp_log(const struct audit_ntp_data *ad) | ||
656 | { } | ||
657 | |||
583 | static inline void audit_ptrace(struct task_struct *t) | 658 | static inline void audit_ptrace(struct task_struct *t) |
584 | { } | 659 | { } |
585 | #define audit_n_rules 0 | 660 | #define audit_n_rules 0 |
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index f28acd952d03..a1280af20336 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h | |||
@@ -114,6 +114,8 @@ | |||
114 | #define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */ | 114 | #define AUDIT_REPLACE 1329 /* Replace auditd if this packet unanswerd */ |
115 | #define AUDIT_KERN_MODULE 1330 /* Kernel Module events */ | 115 | #define AUDIT_KERN_MODULE 1330 /* Kernel Module events */ |
116 | #define AUDIT_FANOTIFY 1331 /* Fanotify access decision */ | 116 | #define AUDIT_FANOTIFY 1331 /* Fanotify access decision */ |
117 | #define AUDIT_TIME_INJOFFSET 1332 /* Timekeeping offset injected */ | ||
118 | #define AUDIT_TIME_ADJNTPVAL 1333 /* NTP value adjustment */ | ||
117 | 119 | ||
118 | #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ | 120 | #define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ |
119 | #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ | 121 | #define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ |
@@ -375,11 +377,19 @@ enum { | |||
375 | 377 | ||
376 | #define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 378 | #define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
377 | #define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 379 | #define AUDIT_ARCH_ALPHA (EM_ALPHA|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
380 | #define AUDIT_ARCH_ARCOMPACT (EM_ARCOMPACT|__AUDIT_ARCH_LE) | ||
381 | #define AUDIT_ARCH_ARCOMPACTBE (EM_ARCOMPACT) | ||
382 | #define AUDIT_ARCH_ARCV2 (EM_ARCV2|__AUDIT_ARCH_LE) | ||
383 | #define AUDIT_ARCH_ARCV2BE (EM_ARCV2) | ||
378 | #define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE) | 384 | #define AUDIT_ARCH_ARM (EM_ARM|__AUDIT_ARCH_LE) |
379 | #define AUDIT_ARCH_ARMEB (EM_ARM) | 385 | #define AUDIT_ARCH_ARMEB (EM_ARM) |
386 | #define AUDIT_ARCH_C6X (EM_TI_C6000|__AUDIT_ARCH_LE) | ||
387 | #define AUDIT_ARCH_C6XBE (EM_TI_C6000) | ||
380 | #define AUDIT_ARCH_CRIS (EM_CRIS|__AUDIT_ARCH_LE) | 388 | #define AUDIT_ARCH_CRIS (EM_CRIS|__AUDIT_ARCH_LE) |
381 | #define AUDIT_ARCH_CSKY (EM_CSKY|__AUDIT_ARCH_LE) | 389 | #define AUDIT_ARCH_CSKY (EM_CSKY|__AUDIT_ARCH_LE) |
382 | #define AUDIT_ARCH_FRV (EM_FRV) | 390 | #define AUDIT_ARCH_FRV (EM_FRV) |
391 | #define AUDIT_ARCH_H8300 (EM_H8_300) | ||
392 | #define AUDIT_ARCH_HEXAGON (EM_HEXAGON) | ||
383 | #define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE) | 393 | #define AUDIT_ARCH_I386 (EM_386|__AUDIT_ARCH_LE) |
384 | #define AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 394 | #define AUDIT_ARCH_IA64 (EM_IA_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
385 | #define AUDIT_ARCH_M32R (EM_M32R) | 395 | #define AUDIT_ARCH_M32R (EM_M32R) |
@@ -393,6 +403,9 @@ enum { | |||
393 | #define AUDIT_ARCH_MIPSEL64 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 403 | #define AUDIT_ARCH_MIPSEL64 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
394 | #define AUDIT_ARCH_MIPSEL64N32 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|\ | 404 | #define AUDIT_ARCH_MIPSEL64N32 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|\ |
395 | __AUDIT_ARCH_CONVENTION_MIPS64_N32) | 405 | __AUDIT_ARCH_CONVENTION_MIPS64_N32) |
406 | #define AUDIT_ARCH_NDS32 (EM_NDS32|__AUDIT_ARCH_LE) | ||
407 | #define AUDIT_ARCH_NDS32BE (EM_NDS32) | ||
408 | #define AUDIT_ARCH_NIOS2 (EM_ALTERA_NIOS2|__AUDIT_ARCH_LE) | ||
396 | #define AUDIT_ARCH_OPENRISC (EM_OPENRISC) | 409 | #define AUDIT_ARCH_OPENRISC (EM_OPENRISC) |
397 | #define AUDIT_ARCH_PARISC (EM_PARISC) | 410 | #define AUDIT_ARCH_PARISC (EM_PARISC) |
398 | #define AUDIT_ARCH_PARISC64 (EM_PARISC|__AUDIT_ARCH_64BIT) | 411 | #define AUDIT_ARCH_PARISC64 (EM_PARISC|__AUDIT_ARCH_64BIT) |
@@ -413,6 +426,7 @@ enum { | |||
413 | #define AUDIT_ARCH_TILEGX (EM_TILEGX|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 426 | #define AUDIT_ARCH_TILEGX (EM_TILEGX|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
414 | #define AUDIT_ARCH_TILEGX32 (EM_TILEGX|__AUDIT_ARCH_LE) | 427 | #define AUDIT_ARCH_TILEGX32 (EM_TILEGX|__AUDIT_ARCH_LE) |
415 | #define AUDIT_ARCH_TILEPRO (EM_TILEPRO|__AUDIT_ARCH_LE) | 428 | #define AUDIT_ARCH_TILEPRO (EM_TILEPRO|__AUDIT_ARCH_LE) |
429 | #define AUDIT_ARCH_UNICORE (EM_UNICORE|__AUDIT_ARCH_LE) | ||
416 | #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) | 430 | #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) |
417 | #define AUDIT_ARCH_XTENSA (EM_XTENSA) | 431 | #define AUDIT_ARCH_XTENSA (EM_XTENSA) |
418 | 432 | ||
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h index 0c3000faedba..f47e853546fa 100644 --- a/include/uapi/linux/elf-em.h +++ b/include/uapi/linux/elf-em.h | |||
@@ -34,14 +34,20 @@ | |||
34 | #define EM_M32R 88 /* Renesas M32R */ | 34 | #define EM_M32R 88 /* Renesas M32R */ |
35 | #define EM_MN10300 89 /* Panasonic/MEI MN10300, AM33 */ | 35 | #define EM_MN10300 89 /* Panasonic/MEI MN10300, AM33 */ |
36 | #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ | 36 | #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ |
37 | #define EM_ARCOMPACT 93 /* ARCompact processor */ | ||
37 | #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ | 38 | #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ |
38 | #define EM_BLACKFIN 106 /* ADI Blackfin Processor */ | 39 | #define EM_BLACKFIN 106 /* ADI Blackfin Processor */ |
40 | #define EM_UNICORE 110 /* UniCore-32 */ | ||
39 | #define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ | 41 | #define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ |
40 | #define EM_TI_C6000 140 /* TI C6X DSPs */ | 42 | #define EM_TI_C6000 140 /* TI C6X DSPs */ |
43 | #define EM_HEXAGON 164 /* QUALCOMM Hexagon */ | ||
44 | #define EM_NDS32 167 /* Andes Technology compact code size | ||
45 | embedded RISC processor family */ | ||
41 | #define EM_AARCH64 183 /* ARM 64 bit */ | 46 | #define EM_AARCH64 183 /* ARM 64 bit */ |
42 | #define EM_TILEPRO 188 /* Tilera TILEPro */ | 47 | #define EM_TILEPRO 188 /* Tilera TILEPro */ |
43 | #define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */ | 48 | #define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */ |
44 | #define EM_TILEGX 191 /* Tilera TILE-Gx */ | 49 | #define EM_TILEGX 191 /* Tilera TILE-Gx */ |
50 | #define EM_ARCV2 195 /* ARCv2 Cores */ | ||
45 | #define EM_RISCV 243 /* RISC-V */ | 51 | #define EM_RISCV 243 /* RISC-V */ |
46 | #define EM_BPF 247 /* Linux BPF - in-kernel virtual machine */ | 52 | #define EM_BPF 247 /* Linux BPF - in-kernel virtual machine */ |
47 | #define EM_CSKY 252 /* C-SKY */ | 53 | #define EM_CSKY 252 /* C-SKY */ |
diff --git a/kernel/audit.c b/kernel/audit.c index c89ea48c70a6..b96bf69183f4 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -2220,7 +2220,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid, | |||
2220 | if (!audit_enabled) | 2220 | if (!audit_enabled) |
2221 | return; | 2221 | return; |
2222 | 2222 | ||
2223 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); | 2223 | ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_LOGIN); |
2224 | if (!ab) | 2224 | if (!ab) |
2225 | return; | 2225 | return; |
2226 | 2226 | ||
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index 63f8b3f26fab..1bc6410413e6 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -1114,22 +1114,24 @@ int audit_rule_change(int type, int seq, void *data, size_t datasz) | |||
1114 | int err = 0; | 1114 | int err = 0; |
1115 | struct audit_entry *entry; | 1115 | struct audit_entry *entry; |
1116 | 1116 | ||
1117 | entry = audit_data_to_entry(data, datasz); | ||
1118 | if (IS_ERR(entry)) | ||
1119 | return PTR_ERR(entry); | ||
1120 | |||
1121 | switch (type) { | 1117 | switch (type) { |
1122 | case AUDIT_ADD_RULE: | 1118 | case AUDIT_ADD_RULE: |
1119 | entry = audit_data_to_entry(data, datasz); | ||
1120 | if (IS_ERR(entry)) | ||
1121 | return PTR_ERR(entry); | ||
1123 | err = audit_add_rule(entry); | 1122 | err = audit_add_rule(entry); |
1124 | audit_log_rule_change("add_rule", &entry->rule, !err); | 1123 | audit_log_rule_change("add_rule", &entry->rule, !err); |
1125 | break; | 1124 | break; |
1126 | case AUDIT_DEL_RULE: | 1125 | case AUDIT_DEL_RULE: |
1126 | entry = audit_data_to_entry(data, datasz); | ||
1127 | if (IS_ERR(entry)) | ||
1128 | return PTR_ERR(entry); | ||
1127 | err = audit_del_rule(entry); | 1129 | err = audit_del_rule(entry); |
1128 | audit_log_rule_change("remove_rule", &entry->rule, !err); | 1130 | audit_log_rule_change("remove_rule", &entry->rule, !err); |
1129 | break; | 1131 | break; |
1130 | default: | 1132 | default: |
1131 | err = -EINVAL; | ||
1132 | WARN_ON(1); | 1133 | WARN_ON(1); |
1134 | return -EINVAL; | ||
1133 | } | 1135 | } |
1134 | 1136 | ||
1135 | if (err || type == AUDIT_DEL_RULE) { | 1137 | if (err || type == AUDIT_DEL_RULE) { |
@@ -1315,8 +1317,6 @@ int audit_filter(int msgtype, unsigned int listtype) | |||
1315 | int ret = 1; /* Audit by default */ | 1317 | int ret = 1; /* Audit by default */ |
1316 | 1318 | ||
1317 | rcu_read_lock(); | 1319 | rcu_read_lock(); |
1318 | if (list_empty(&audit_filter_list[listtype])) | ||
1319 | goto unlock_and_return; | ||
1320 | list_for_each_entry_rcu(e, &audit_filter_list[listtype], list) { | 1320 | list_for_each_entry_rcu(e, &audit_filter_list[listtype], list) { |
1321 | int i, result = 0; | 1321 | int i, result = 0; |
1322 | 1322 | ||
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index d1eab1d4a930..5371b59bde36 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -771,15 +771,13 @@ static enum audit_state audit_filter_syscall(struct task_struct *tsk, | |||
771 | return AUDIT_DISABLED; | 771 | return AUDIT_DISABLED; |
772 | 772 | ||
773 | rcu_read_lock(); | 773 | rcu_read_lock(); |
774 | if (!list_empty(list)) { | 774 | list_for_each_entry_rcu(e, list, list) { |
775 | list_for_each_entry_rcu(e, list, list) { | 775 | if (audit_in_mask(&e->rule, ctx->major) && |
776 | if (audit_in_mask(&e->rule, ctx->major) && | 776 | audit_filter_rules(tsk, &e->rule, ctx, NULL, |
777 | audit_filter_rules(tsk, &e->rule, ctx, NULL, | 777 | &state, false)) { |
778 | &state, false)) { | 778 | rcu_read_unlock(); |
779 | rcu_read_unlock(); | 779 | ctx->current_state = state; |
780 | ctx->current_state = state; | 780 | return state; |
781 | return state; | ||
782 | } | ||
783 | } | 781 | } |
784 | } | 782 | } |
785 | rcu_read_unlock(); | 783 | rcu_read_unlock(); |
@@ -798,9 +796,6 @@ static int audit_filter_inode_name(struct task_struct *tsk, | |||
798 | struct audit_entry *e; | 796 | struct audit_entry *e; |
799 | enum audit_state state; | 797 | enum audit_state state; |
800 | 798 | ||
801 | if (list_empty(list)) | ||
802 | return 0; | ||
803 | |||
804 | list_for_each_entry_rcu(e, list, list) { | 799 | list_for_each_entry_rcu(e, list, list) { |
805 | if (audit_in_mask(&e->rule, ctx->major) && | 800 | if (audit_in_mask(&e->rule, ctx->major) && |
806 | audit_filter_rules(tsk, &e->rule, ctx, n, &state, false)) { | 801 | audit_filter_rules(tsk, &e->rule, ctx, n, &state, false)) { |
@@ -808,7 +803,6 @@ static int audit_filter_inode_name(struct task_struct *tsk, | |||
808 | return 1; | 803 | return 1; |
809 | } | 804 | } |
810 | } | 805 | } |
811 | |||
812 | return 0; | 806 | return 0; |
813 | } | 807 | } |
814 | 808 | ||
@@ -840,6 +834,13 @@ static inline void audit_proctitle_free(struct audit_context *context) | |||
840 | context->proctitle.len = 0; | 834 | context->proctitle.len = 0; |
841 | } | 835 | } |
842 | 836 | ||
837 | static inline void audit_free_module(struct audit_context *context) | ||
838 | { | ||
839 | if (context->type == AUDIT_KERN_MODULE) { | ||
840 | kfree(context->module.name); | ||
841 | context->module.name = NULL; | ||
842 | } | ||
843 | } | ||
843 | static inline void audit_free_names(struct audit_context *context) | 844 | static inline void audit_free_names(struct audit_context *context) |
844 | { | 845 | { |
845 | struct audit_names *n, *next; | 846 | struct audit_names *n, *next; |
@@ -923,6 +924,7 @@ int audit_alloc(struct task_struct *tsk) | |||
923 | 924 | ||
924 | static inline void audit_free_context(struct audit_context *context) | 925 | static inline void audit_free_context(struct audit_context *context) |
925 | { | 926 | { |
927 | audit_free_module(context); | ||
926 | audit_free_names(context); | 928 | audit_free_names(context); |
927 | unroll_tree_refs(context, NULL, 0); | 929 | unroll_tree_refs(context, NULL, 0); |
928 | free_tree_refs(context); | 930 | free_tree_refs(context); |
@@ -1139,7 +1141,8 @@ out: | |||
1139 | kfree(buf_head); | 1141 | kfree(buf_head); |
1140 | } | 1142 | } |
1141 | 1143 | ||
1142 | void audit_log_cap(struct audit_buffer *ab, char *prefix, kernel_cap_t *cap) | 1144 | static void audit_log_cap(struct audit_buffer *ab, char *prefix, |
1145 | kernel_cap_t *cap) | ||
1143 | { | 1146 | { |
1144 | int i; | 1147 | int i; |
1145 | 1148 | ||
@@ -1266,7 +1269,6 @@ static void show_special(struct audit_context *context, int *call_panic) | |||
1266 | audit_log_format(ab, "name="); | 1269 | audit_log_format(ab, "name="); |
1267 | if (context->module.name) { | 1270 | if (context->module.name) { |
1268 | audit_log_untrustedstring(ab, context->module.name); | 1271 | audit_log_untrustedstring(ab, context->module.name); |
1269 | kfree(context->module.name); | ||
1270 | } else | 1272 | } else |
1271 | audit_log_format(ab, "(null)"); | 1273 | audit_log_format(ab, "(null)"); |
1272 | 1274 | ||
@@ -1628,7 +1630,7 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2, | |||
1628 | return; | 1630 | return; |
1629 | } | 1631 | } |
1630 | 1632 | ||
1631 | context->arch = syscall_get_arch(); | 1633 | context->arch = syscall_get_arch(current); |
1632 | context->major = major; | 1634 | context->major = major; |
1633 | context->argv[0] = a1; | 1635 | context->argv[0] = a1; |
1634 | context->argv[1] = a2; | 1636 | context->argv[1] = a2; |
@@ -1697,6 +1699,7 @@ void __audit_syscall_exit(int success, long return_code) | |||
1697 | context->in_syscall = 0; | 1699 | context->in_syscall = 0; |
1698 | context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0; | 1700 | context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0; |
1699 | 1701 | ||
1702 | audit_free_module(context); | ||
1700 | audit_free_names(context); | 1703 | audit_free_names(context); |
1701 | unroll_tree_refs(context, NULL, 0); | 1704 | unroll_tree_refs(context, NULL, 0); |
1702 | audit_free_aux(context); | 1705 | audit_free_aux(context); |
@@ -1897,8 +1900,9 @@ static inline int audit_copy_fcaps(struct audit_names *name, | |||
1897 | } | 1900 | } |
1898 | 1901 | ||
1899 | /* Copy inode data into an audit_names. */ | 1902 | /* Copy inode data into an audit_names. */ |
1900 | void audit_copy_inode(struct audit_names *name, const struct dentry *dentry, | 1903 | static void audit_copy_inode(struct audit_names *name, |
1901 | struct inode *inode, unsigned int flags) | 1904 | const struct dentry *dentry, |
1905 | struct inode *inode, unsigned int flags) | ||
1902 | { | 1906 | { |
1903 | name->ino = inode->i_ino; | 1907 | name->ino = inode->i_ino; |
1904 | name->dev = inode->i_sb->s_dev; | 1908 | name->dev = inode->i_sb->s_dev; |
@@ -1935,18 +1939,16 @@ void __audit_inode(struct filename *name, const struct dentry *dentry, | |||
1935 | return; | 1939 | return; |
1936 | 1940 | ||
1937 | rcu_read_lock(); | 1941 | rcu_read_lock(); |
1938 | if (!list_empty(list)) { | 1942 | list_for_each_entry_rcu(e, list, list) { |
1939 | list_for_each_entry_rcu(e, list, list) { | 1943 | for (i = 0; i < e->rule.field_count; i++) { |
1940 | for (i = 0; i < e->rule.field_count; i++) { | 1944 | struct audit_field *f = &e->rule.fields[i]; |
1941 | struct audit_field *f = &e->rule.fields[i]; | 1945 | |
1942 | 1946 | if (f->type == AUDIT_FSTYPE | |
1943 | if (f->type == AUDIT_FSTYPE | 1947 | && audit_comparator(inode->i_sb->s_magic, |
1944 | && audit_comparator(inode->i_sb->s_magic, | 1948 | f->op, f->val) |
1945 | f->op, f->val) | 1949 | && e->rule.action == AUDIT_NEVER) { |
1946 | && e->rule.action == AUDIT_NEVER) { | 1950 | rcu_read_unlock(); |
1947 | rcu_read_unlock(); | 1951 | return; |
1948 | return; | ||
1949 | } | ||
1950 | } | 1952 | } |
1951 | } | 1953 | } |
1952 | } | 1954 | } |
@@ -2055,18 +2057,16 @@ void __audit_inode_child(struct inode *parent, | |||
2055 | return; | 2057 | return; |
2056 | 2058 | ||
2057 | rcu_read_lock(); | 2059 | rcu_read_lock(); |
2058 | if (!list_empty(list)) { | 2060 | list_for_each_entry_rcu(e, list, list) { |
2059 | list_for_each_entry_rcu(e, list, list) { | 2061 | for (i = 0; i < e->rule.field_count; i++) { |
2060 | for (i = 0; i < e->rule.field_count; i++) { | 2062 | struct audit_field *f = &e->rule.fields[i]; |
2061 | struct audit_field *f = &e->rule.fields[i]; | 2063 | |
2062 | 2064 | if (f->type == AUDIT_FSTYPE | |
2063 | if (f->type == AUDIT_FSTYPE | 2065 | && audit_comparator(parent->i_sb->s_magic, |
2064 | && audit_comparator(parent->i_sb->s_magic, | 2066 | f->op, f->val) |
2065 | f->op, f->val) | 2067 | && e->rule.action == AUDIT_NEVER) { |
2066 | && e->rule.action == AUDIT_NEVER) { | 2068 | rcu_read_unlock(); |
2067 | rcu_read_unlock(); | 2069 | return; |
2068 | return; | ||
2069 | } | ||
2070 | } | 2070 | } |
2071 | } | 2071 | } |
2072 | } | 2072 | } |
@@ -2512,6 +2512,35 @@ void __audit_fanotify(unsigned int response) | |||
2512 | AUDIT_FANOTIFY, "resp=%u", response); | 2512 | AUDIT_FANOTIFY, "resp=%u", response); |
2513 | } | 2513 | } |
2514 | 2514 | ||
2515 | void __audit_tk_injoffset(struct timespec64 offset) | ||
2516 | { | ||
2517 | audit_log(audit_context(), GFP_KERNEL, AUDIT_TIME_INJOFFSET, | ||
2518 | "sec=%lli nsec=%li", | ||
2519 | (long long)offset.tv_sec, offset.tv_nsec); | ||
2520 | } | ||
2521 | |||
2522 | static void audit_log_ntp_val(const struct audit_ntp_data *ad, | ||
2523 | const char *op, enum audit_ntp_type type) | ||
2524 | { | ||
2525 | const struct audit_ntp_val *val = &ad->vals[type]; | ||
2526 | |||
2527 | if (val->newval == val->oldval) | ||
2528 | return; | ||
2529 | |||
2530 | audit_log(audit_context(), GFP_KERNEL, AUDIT_TIME_ADJNTPVAL, | ||
2531 | "op=%s old=%lli new=%lli", op, val->oldval, val->newval); | ||
2532 | } | ||
2533 | |||
2534 | void __audit_ntp_log(const struct audit_ntp_data *ad) | ||
2535 | { | ||
2536 | audit_log_ntp_val(ad, "offset", AUDIT_NTP_OFFSET); | ||
2537 | audit_log_ntp_val(ad, "freq", AUDIT_NTP_FREQ); | ||
2538 | audit_log_ntp_val(ad, "status", AUDIT_NTP_STATUS); | ||
2539 | audit_log_ntp_val(ad, "tai", AUDIT_NTP_TAI); | ||
2540 | audit_log_ntp_val(ad, "tick", AUDIT_NTP_TICK); | ||
2541 | audit_log_ntp_val(ad, "adjust", AUDIT_NTP_ADJUST); | ||
2542 | } | ||
2543 | |||
2515 | static void audit_log_task(struct audit_buffer *ab) | 2544 | static void audit_log_task(struct audit_buffer *ab) |
2516 | { | 2545 | { |
2517 | kuid_t auid, uid; | 2546 | kuid_t auid, uid; |
@@ -2580,7 +2609,7 @@ void audit_seccomp(unsigned long syscall, long signr, int code) | |||
2580 | return; | 2609 | return; |
2581 | audit_log_task(ab); | 2610 | audit_log_task(ab); |
2582 | audit_log_format(ab, " sig=%ld arch=%x syscall=%ld compat=%d ip=0x%lx code=0x%x", | 2611 | audit_log_format(ab, " sig=%ld arch=%x syscall=%ld compat=%d ip=0x%lx code=0x%x", |
2583 | signr, syscall_get_arch(), syscall, | 2612 | signr, syscall_get_arch(current), syscall, |
2584 | in_compat_syscall(), KSTK_EIP(current), code); | 2613 | in_compat_syscall(), KSTK_EIP(current), code); |
2585 | audit_log_end(ab); | 2614 | audit_log_end(ab); |
2586 | } | 2615 | } |
diff --git a/kernel/seccomp.c b/kernel/seccomp.c index a635ecba6fe2..811b4a86cdf6 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c | |||
@@ -148,7 +148,7 @@ static void populate_seccomp_data(struct seccomp_data *sd) | |||
148 | unsigned long args[6]; | 148 | unsigned long args[6]; |
149 | 149 | ||
150 | sd->nr = syscall_get_nr(task, regs); | 150 | sd->nr = syscall_get_nr(task, regs); |
151 | sd->arch = syscall_get_arch(); | 151 | sd->arch = syscall_get_arch(task); |
152 | syscall_get_arguments(task, regs, args); | 152 | syscall_get_arguments(task, regs, args); |
153 | sd->args[0] = args[0]; | 153 | sd->args[0] = args[0]; |
154 | sd->args[1] = args[1]; | 154 | sd->args[1] = args[1]; |
@@ -594,7 +594,7 @@ static void seccomp_init_siginfo(kernel_siginfo_t *info, int syscall, int reason | |||
594 | info->si_code = SYS_SECCOMP; | 594 | info->si_code = SYS_SECCOMP; |
595 | info->si_call_addr = (void __user *)KSTK_EIP(current); | 595 | info->si_call_addr = (void __user *)KSTK_EIP(current); |
596 | info->si_errno = reason; | 596 | info->si_errno = reason; |
597 | info->si_arch = syscall_get_arch(); | 597 | info->si_arch = syscall_get_arch(current); |
598 | info->si_syscall = syscall; | 598 | info->si_syscall = syscall; |
599 | } | 599 | } |
600 | 600 | ||
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 92a90014a925..ac5555e25733 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/audit.h> | ||
20 | 21 | ||
21 | #include "ntp_internal.h" | 22 | #include "ntp_internal.h" |
22 | #include "timekeeping_internal.h" | 23 | #include "timekeeping_internal.h" |
@@ -709,7 +710,7 @@ static inline void process_adjtimex_modes(const struct __kernel_timex *txc, | |||
709 | * kernel time-keeping variables. used by xntpd. | 710 | * kernel time-keeping variables. used by xntpd. |
710 | */ | 711 | */ |
711 | int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts, | 712 | int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts, |
712 | s32 *time_tai) | 713 | s32 *time_tai, struct audit_ntp_data *ad) |
713 | { | 714 | { |
714 | int result; | 715 | int result; |
715 | 716 | ||
@@ -720,14 +721,29 @@ int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts, | |||
720 | /* adjtime() is independent from ntp_adjtime() */ | 721 | /* adjtime() is independent from ntp_adjtime() */ |
721 | time_adjust = txc->offset; | 722 | time_adjust = txc->offset; |
722 | ntp_update_frequency(); | 723 | ntp_update_frequency(); |
724 | |||
725 | audit_ntp_set_old(ad, AUDIT_NTP_ADJUST, save_adjust); | ||
726 | audit_ntp_set_new(ad, AUDIT_NTP_ADJUST, time_adjust); | ||
723 | } | 727 | } |
724 | txc->offset = save_adjust; | 728 | txc->offset = save_adjust; |
725 | } else { | 729 | } else { |
726 | |||
727 | /* If there are input parameters, then process them: */ | 730 | /* If there are input parameters, then process them: */ |
728 | if (txc->modes) | 731 | if (txc->modes) { |
732 | audit_ntp_set_old(ad, AUDIT_NTP_OFFSET, time_offset); | ||
733 | audit_ntp_set_old(ad, AUDIT_NTP_FREQ, time_freq); | ||
734 | audit_ntp_set_old(ad, AUDIT_NTP_STATUS, time_status); | ||
735 | audit_ntp_set_old(ad, AUDIT_NTP_TAI, *time_tai); | ||
736 | audit_ntp_set_old(ad, AUDIT_NTP_TICK, tick_usec); | ||
737 | |||
729 | process_adjtimex_modes(txc, time_tai); | 738 | process_adjtimex_modes(txc, time_tai); |
730 | 739 | ||
740 | audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, time_offset); | ||
741 | audit_ntp_set_new(ad, AUDIT_NTP_FREQ, time_freq); | ||
742 | audit_ntp_set_new(ad, AUDIT_NTP_STATUS, time_status); | ||
743 | audit_ntp_set_new(ad, AUDIT_NTP_TAI, *time_tai); | ||
744 | audit_ntp_set_new(ad, AUDIT_NTP_TICK, tick_usec); | ||
745 | } | ||
746 | |||
731 | txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, | 747 | txc->offset = shift_right(time_offset * NTP_INTERVAL_FREQ, |
732 | NTP_SCALE_SHIFT); | 748 | NTP_SCALE_SHIFT); |
733 | if (!(time_status & STA_NANO)) | 749 | if (!(time_status & STA_NANO)) |
diff --git a/kernel/time/ntp_internal.h b/kernel/time/ntp_internal.h index 40e6122e634e..908ecaa65fc3 100644 --- a/kernel/time/ntp_internal.h +++ b/kernel/time/ntp_internal.h | |||
@@ -8,6 +8,8 @@ extern void ntp_clear(void); | |||
8 | extern u64 ntp_tick_length(void); | 8 | extern u64 ntp_tick_length(void); |
9 | extern ktime_t ntp_get_next_leap(void); | 9 | extern ktime_t ntp_get_next_leap(void); |
10 | extern int second_overflow(time64_t secs); | 10 | extern int second_overflow(time64_t secs); |
11 | extern int __do_adjtimex(struct __kernel_timex *txc, const struct timespec64 *ts, s32 *time_tai); | 11 | extern int __do_adjtimex(struct __kernel_timex *txc, |
12 | const struct timespec64 *ts, | ||
13 | s32 *time_tai, struct audit_ntp_data *ad); | ||
12 | extern void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts); | 14 | extern void __hardpps(const struct timespec64 *phase_ts, const struct timespec64 *raw_ts); |
13 | #endif /* _LINUX_NTP_INTERNAL_H */ | 15 | #endif /* _LINUX_NTP_INTERNAL_H */ |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 5716e28bfa3c..85f5912d8f70 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/stop_machine.h> | 21 | #include <linux/stop_machine.h> |
22 | #include <linux/pvclock_gtod.h> | 22 | #include <linux/pvclock_gtod.h> |
23 | #include <linux/compiler.h> | 23 | #include <linux/compiler.h> |
24 | #include <linux/audit.h> | ||
24 | 25 | ||
25 | #include "tick-internal.h" | 26 | #include "tick-internal.h" |
26 | #include "ntp_internal.h" | 27 | #include "ntp_internal.h" |
@@ -1250,6 +1251,9 @@ out: | |||
1250 | /* signal hrtimers about time change */ | 1251 | /* signal hrtimers about time change */ |
1251 | clock_was_set(); | 1252 | clock_was_set(); |
1252 | 1253 | ||
1254 | if (!ret) | ||
1255 | audit_tk_injoffset(ts_delta); | ||
1256 | |||
1253 | return ret; | 1257 | return ret; |
1254 | } | 1258 | } |
1255 | EXPORT_SYMBOL(do_settimeofday64); | 1259 | EXPORT_SYMBOL(do_settimeofday64); |
@@ -2303,6 +2307,7 @@ static int timekeeping_validate_timex(const struct __kernel_timex *txc) | |||
2303 | int do_adjtimex(struct __kernel_timex *txc) | 2307 | int do_adjtimex(struct __kernel_timex *txc) |
2304 | { | 2308 | { |
2305 | struct timekeeper *tk = &tk_core.timekeeper; | 2309 | struct timekeeper *tk = &tk_core.timekeeper; |
2310 | struct audit_ntp_data ad; | ||
2306 | unsigned long flags; | 2311 | unsigned long flags; |
2307 | struct timespec64 ts; | 2312 | struct timespec64 ts; |
2308 | s32 orig_tai, tai; | 2313 | s32 orig_tai, tai; |
@@ -2322,15 +2327,19 @@ int do_adjtimex(struct __kernel_timex *txc) | |||
2322 | ret = timekeeping_inject_offset(&delta); | 2327 | ret = timekeeping_inject_offset(&delta); |
2323 | if (ret) | 2328 | if (ret) |
2324 | return ret; | 2329 | return ret; |
2330 | |||
2331 | audit_tk_injoffset(delta); | ||
2325 | } | 2332 | } |
2326 | 2333 | ||
2334 | audit_ntp_init(&ad); | ||
2335 | |||
2327 | ktime_get_real_ts64(&ts); | 2336 | ktime_get_real_ts64(&ts); |
2328 | 2337 | ||
2329 | raw_spin_lock_irqsave(&timekeeper_lock, flags); | 2338 | raw_spin_lock_irqsave(&timekeeper_lock, flags); |
2330 | write_seqcount_begin(&tk_core.seq); | 2339 | write_seqcount_begin(&tk_core.seq); |
2331 | 2340 | ||
2332 | orig_tai = tai = tk->tai_offset; | 2341 | orig_tai = tai = tk->tai_offset; |
2333 | ret = __do_adjtimex(txc, &ts, &tai); | 2342 | ret = __do_adjtimex(txc, &ts, &tai, &ad); |
2334 | 2343 | ||
2335 | if (tai != orig_tai) { | 2344 | if (tai != orig_tai) { |
2336 | __timekeeping_set_tai_offset(tk, tai); | 2345 | __timekeeping_set_tai_offset(tk, tai); |
@@ -2341,6 +2350,8 @@ int do_adjtimex(struct __kernel_timex *txc) | |||
2341 | write_seqcount_end(&tk_core.seq); | 2350 | write_seqcount_end(&tk_core.seq); |
2342 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); | 2351 | raw_spin_unlock_irqrestore(&timekeeper_lock, flags); |
2343 | 2352 | ||
2353 | audit_ntp_log(&ad); | ||
2354 | |||
2344 | /* Update the multiplier immediately if frequency was set directly */ | 2355 | /* Update the multiplier immediately if frequency was set directly */ |
2345 | if (txc->modes & (ADJ_FREQUENCY | ADJ_TICK)) | 2356 | if (txc->modes & (ADJ_FREQUENCY | ADJ_TICK)) |
2346 | timekeeping_advance(TK_ADV_FREQ); | 2357 | timekeeping_advance(TK_ADV_FREQ); |
diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c index 015aea8fdf1e..3f7cbb238923 100644 --- a/security/integrity/evm/evm_secfs.c +++ b/security/integrity/evm/evm_secfs.c | |||
@@ -192,7 +192,8 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf, | |||
192 | if (count > XATTR_NAME_MAX) | 192 | if (count > XATTR_NAME_MAX) |
193 | return -E2BIG; | 193 | return -E2BIG; |
194 | 194 | ||
195 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_EVM_XATTR); | 195 | ab = audit_log_start(audit_context(), GFP_KERNEL, |
196 | AUDIT_INTEGRITY_EVM_XATTR); | ||
196 | if (!ab) | 197 | if (!ab) |
197 | return -ENOMEM; | 198 | return -ENOMEM; |
198 | 199 | ||
@@ -214,6 +215,9 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf, | |||
214 | if (len && xattr->name[len-1] == '\n') | 215 | if (len && xattr->name[len-1] == '\n') |
215 | xattr->name[len-1] = '\0'; | 216 | xattr->name[len-1] = '\0'; |
216 | 217 | ||
218 | audit_log_format(ab, "xattr="); | ||
219 | audit_log_untrustedstring(ab, xattr->name); | ||
220 | |||
217 | if (strcmp(xattr->name, ".") == 0) { | 221 | if (strcmp(xattr->name, ".") == 0) { |
218 | evm_xattrs_locked = 1; | 222 | evm_xattrs_locked = 1; |
219 | newattrs.ia_mode = S_IFREG | 0440; | 223 | newattrs.ia_mode = S_IFREG | 0440; |
@@ -222,15 +226,11 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf, | |||
222 | inode_lock(inode); | 226 | inode_lock(inode); |
223 | err = simple_setattr(evm_xattrs, &newattrs); | 227 | err = simple_setattr(evm_xattrs, &newattrs); |
224 | inode_unlock(inode); | 228 | inode_unlock(inode); |
225 | audit_log_format(ab, "locked"); | ||
226 | if (!err) | 229 | if (!err) |
227 | err = count; | 230 | err = count; |
228 | goto out; | 231 | goto out; |
229 | } | 232 | } |
230 | 233 | ||
231 | audit_log_format(ab, "xattr="); | ||
232 | audit_log_untrustedstring(ab, xattr->name); | ||
233 | |||
234 | if (strncmp(xattr->name, XATTR_SECURITY_PREFIX, | 234 | if (strncmp(xattr->name, XATTR_SECURITY_PREFIX, |
235 | XATTR_SECURITY_PREFIX_LEN) != 0) { | 235 | XATTR_SECURITY_PREFIX_LEN) != 0) { |
236 | err = -EINVAL; | 236 | err = -EINVAL; |