diff options
author | Will Drewry <wad@chromium.org> | 2012-04-12 17:47:56 -0400 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2012-04-13 21:13:20 -0400 |
commit | b7456536cf9466b402b540c5588d79a4177c723a (patch) | |
tree | 3d955990f59de9c5ae316772dda7d8acb655093a | |
parent | 07bd18d00d5dcf84eb22f8120f47f09c3d8fe27d (diff) |
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>
-rw-r--r-- | arch/x86/include/asm/syscall.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index 386b78686c4d..1ace47b62592 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h | |||
@@ -13,9 +13,11 @@ | |||
13 | #ifndef _ASM_X86_SYSCALL_H | 13 | #ifndef _ASM_X86_SYSCALL_H |
14 | #define _ASM_X86_SYSCALL_H | 14 | #define _ASM_X86_SYSCALL_H |
15 | 15 | ||
16 | #include <linux/audit.h> | ||
16 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
17 | #include <linux/err.h> | 18 | #include <linux/err.h> |
18 | #include <asm/asm-offsets.h> /* For NR_syscalls */ | 19 | #include <asm/asm-offsets.h> /* For NR_syscalls */ |
20 | #include <asm/thread_info.h> /* for TS_COMPAT */ | ||
19 | #include <asm/unistd.h> | 21 | #include <asm/unistd.h> |
20 | 22 | ||
21 | extern const unsigned long sys_call_table[]; | 23 | extern const unsigned long sys_call_table[]; |
@@ -88,6 +90,12 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
88 | memcpy(®s->bx + i, args, n * sizeof(args[0])); | 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 | #else /* CONFIG_X86_64 */ | 99 | #else /* CONFIG_X86_64 */ |
92 | 100 | ||
93 | static inline void syscall_get_arguments(struct task_struct *task, | 101 | static inline void syscall_get_arguments(struct task_struct *task, |
@@ -212,6 +220,25 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
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 | #endif /* CONFIG_X86_32 */ | 242 | #endif /* CONFIG_X86_32 */ |
216 | 243 | ||
217 | #endif /* _ASM_X86_SYSCALL_H */ | 244 | #endif /* _ASM_X86_SYSCALL_H */ |