Commit b7456536cf9466b402b540c5588d79a4177c723a
Committed by
James Morris
1 parent
07bd18d00d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
arch/x86: add syscall_get_arch to syscall.h
Add syscall_get_arch() to export the current AUDIT_ARCH_* based on system call entry path. Signed-off-by: Will Drewry <wad@chromium.org> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Reviewed-by: H. Peter Anvin <hpa@zytor.com> Acked-by: Eric Paris <eparis@redhat.com> Reviewed-by: Kees Cook <keescook@chromium.org> v18: - update comment about x32 tasks - rebase to v3.4-rc2 v17: rebase and reviewed-by v14: rebase/nochanges v13: rebase on to 88ebdda6159ffc15699f204c33feb3e431bf9bdc Signed-off-by: James Morris <james.l.morris@oracle.com>
Showing 1 changed file with 27 additions and 0 deletions Side-by-side Diff
arch/x86/include/asm/syscall.h
... | ... | @@ -13,9 +13,11 @@ |
13 | 13 | #ifndef _ASM_X86_SYSCALL_H |
14 | 14 | #define _ASM_X86_SYSCALL_H |
15 | 15 | |
16 | +#include <linux/audit.h> | |
16 | 17 | #include <linux/sched.h> |
17 | 18 | #include <linux/err.h> |
18 | 19 | #include <asm/asm-offsets.h> /* For NR_syscalls */ |
20 | +#include <asm/thread_info.h> /* for TS_COMPAT */ | |
19 | 21 | #include <asm/unistd.h> |
20 | 22 | |
21 | 23 | extern const unsigned long sys_call_table[]; |
... | ... | @@ -88,6 +90,12 @@ |
88 | 90 | memcpy(®s->bx + i, args, n * sizeof(args[0])); |
89 | 91 | } |
90 | 92 | |
93 | +static inline int syscall_get_arch(struct task_struct *task, | |
94 | + struct pt_regs *regs) | |
95 | +{ | |
96 | + return AUDIT_ARCH_I386; | |
97 | +} | |
98 | + | |
91 | 99 | #else /* CONFIG_X86_64 */ |
92 | 100 | |
93 | 101 | static inline void syscall_get_arguments(struct task_struct *task, |
... | ... | @@ -212,6 +220,25 @@ |
212 | 220 | } |
213 | 221 | } |
214 | 222 | |
223 | +static inline int syscall_get_arch(struct task_struct *task, | |
224 | + struct pt_regs *regs) | |
225 | +{ | |
226 | +#ifdef CONFIG_IA32_EMULATION | |
227 | + /* | |
228 | + * TS_COMPAT is set for 32-bit syscall entry and then | |
229 | + * remains set until we return to user mode. | |
230 | + * | |
231 | + * TIF_IA32 tasks should always have TS_COMPAT set at | |
232 | + * system call time. | |
233 | + * | |
234 | + * x32 tasks should be considered AUDIT_ARCH_X86_64. | |
235 | + */ | |
236 | + if (task_thread_info(task)->status & TS_COMPAT) | |
237 | + return AUDIT_ARCH_I386; | |
238 | +#endif | |
239 | + /* Both x32 and x86_64 are considered "64-bit". */ | |
240 | + return AUDIT_ARCH_X86_64; | |
241 | +} | |
215 | 242 | #endif /* CONFIG_X86_32 */ |
216 | 243 | |
217 | 244 | #endif /* _ASM_X86_SYSCALL_H */ |