syscalls: Restore address limit after a syscall
Subsystems (5)
PATCH 1/4 syscalls: Restore address limit after a syscall
This patch prevents a syscall to modify the address limit of the caller. The address limit is kept by the syscall wrapper and restored just after the syscall ends.
For example, it would mitigation this bug:
- https://bugs.chromium.org/p/project-zero/issues/detail?id=990
By default, this change warns if the segment is incorrect while returning to user-mode and fix it. The CONFIG_VERIFY_PRE_USERMODE_STATE_BUG option can be enabled to halt instead if needed.
The CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE option is also added so each architecture can optimize how the verify_pre_usermode_state function is called.
---
Based on next-20170308
--- include/linux/syscalls.h | 19 +++++++++++++++++++ init/Kconfig | 16 ++++++++++++++++ kernel/sys.c | 11 +++++++++++ 3 files changed, 46 insertions(+)
include/linux/syscalls.h +19 -0
@@ -191,6 +191,22 @@ extern struct trace_event_functions exit_syscall_print_funcs; SYSCALL_METADATA(sname, x, __VA_ARGS__) \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) +asmlinkage void verify_pre_usermode_state(void); + +#ifndef CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE +static inline bool has_user_ds (void ) { +bool ret =segment_eq (get_fs (),USER_DS ); +// Prevent re-ordering the call +barrier (); +return ret; +} +#else +static inline bool has_user_ds (void ) { +return false; +} +#endif + +#define __PROTECT (...) asmlinkage_protect(__VA_ARGS__)#define __SYSCALL_DEFINEx (x, name, ...) \ asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
@@ -199,7 +215,10 @@ extern struct trace_event_functions exit_syscall_print_funcs; asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ { \ + bool user_caller = has_user_ds(); \ long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ + if (user_caller) \ + verify_pre_usermode_state(); \ __MAP(x,__SC_TEST,__VA_ARGS__); \ __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ return ret; \
init/Kconfig +16 -0
@@ -1929,6 +1929,22 @@ config PROFILING config TRACEPOINTS bool +# +# Set by each architecture that want to optimize how verify_pre_usermode_state +# is called. +# +config ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE + bool + +config VERIFY_PRE_USERMODE_STATE_BUG + bool "Halt on incorrect state on returning to user-mode" + default n + help + By default a warning is logged and the state is fixed. This option + crashes the kernel instead. + + If unsure, say Y. + source "arch/Kconfig" endmenu # General setup
kernel/sys.c +11 -0
@@ -2459,3 +2459,14 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)return 0 ; }#endif /* CONFIG_COMPAT */ + +/* Called before coming back to user-mode */ +asmlinkage void verify_pre_usermode_state(void) +{ +#ifdef CONFIG_VERIFY_PRE_USERMODE_STATE_BUG +BUG_ON (!segment_eq (get_fs (),USER_DS )); +#else +if (WARN_ON (!segment_eq (get_fs (),USER_DS ))) +set_fs (USER_DS ); +#endif +}
Signature · 1 line
2.12.0.246.ga2ecc84866-goog
PATCH 2/4 x86/syscalls: Specific usage of verify_pre_usermode_state
Implement specific usage of verify_pre_usermode_state for user-mode returns for x86.
---
Based on next-20170308
--- arch/x86/Kconfig | 1 + arch/x86/entry/common.c | 3 +++ arch/x86/entry/entry_64.S | 6 ++++++ 3 files changed, 10 insertions(+)
arch/x86/Kconfig +1 -0
@@ -63,6 +63,7 @@ config X86 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARCH_SUPPORTS_ATOMIC_RMW select ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
arch/x86/entry/common.c +3 -0
@@ -22,6 +22,7 @@#include <linux/context_tracking.h> #include <linux/user-return-notifier.h> #include <linux/uprobes.h> +#include <linux/syscalls.h> #include <asm/desc.h> #include <asm/traps.h>
@@ -180,6 +181,8 @@ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs)struct thread_info *ti =current_thread_info ();u32 cached_flags; +verify_pre_usermode_state (); +if (IS_ENABLED (CONFIG_PROVE_LOCKING ) &&WARN_ON (!irqs_disabled ()))local_irq_disable ();
arch/x86/entry/entry_64.S +6 -0
@@ -201,6 +201,7 @@ entry_SYSCALL_64_fastpath: * It might end up jumping to the slow path. If it jumps, RAX * and all argument registers are clobbered. */ + call *sys_call_table(, %rax, 8) .Lentry_SYSCALL_64_after_fastpath_call:
@@ -218,6 +219,11 @@ entry_SYSCALL_64_fastpath: testl $_TIF_ALLWORK_MASK, TASK_TI_flags(%r11) jnz 1f + /* + * Check user-mode state on fast path return, the same check is done + * under the slow path through syscall_return_slowpath. + */ + call verify_pre_usermode_state LOCKDEP_SYS_EXIT TRACE_IRQS_ON /* user mode is traced as IRQs on */ movq RIP(%rsp), %rcx
Signature · 1 line
2.12.0.246.ga2ecc84866-goog
PATCH 3/4 arm/syscalls: Specific usage of verify_pre_usermode_state
In reply to Thomas GarnierImplement specific usage of verify_pre_usermode_state for user-mode returns for arm.
---
Based on next-20170308
--- arch/arm/Kconfig | 1 + arch/arm/kernel/entry-common.S | 5 +++++ 2 files changed, 6 insertions(+)
arch/arm/Kconfig +1 -0
@@ -12,6 +12,7 @@ config ARM select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_MIGHT_HAVE_PC_PARPORT + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 select ARCH_SUPPORTS_ATOMIC_RMW
arch/arm/kernel/entry-common.S +5 -0
@@ -39,6 +39,9 @@ ret_fast_syscall: UNWIND(.fnstart ) UNWIND(.cantunwind ) + push {r0} @ save returned r0 + bl verify_pre_usermode_state + pop {r0} @ restore r0 disable_irq_notrace @ disable interrupts ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
@@ -65,6 +68,7 @@ ret_fast_syscall: UNWIND(.fnstart ) UNWIND(.cantunwind ) str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 + bl verify_pre_usermode_state disable_irq_notrace @ disable interrupts ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
@@ -263,6 +267,7 @@ __sys_trace: __sys_trace_return: str r0, [sp, #S_R0 + S_OFF]! @ save returned r0 + bl verify_pre_usermode_state mov r0, sp bl syscall_trace_exit b ret_slow_syscall
Signature · 1 line
2.12.0.246.ga2ecc84866-goog
Russell King - ARM Linux
maintainerRe: [PATCH v1 3/4] arm/syscalls: Specific usage of verify_pre_usermode_state
Quoted 26 lines · Thomas Garnier
Implement specific usage of
verify_pre_usermode_statefor user-mode returns for arm.
---
Based on next-20170308--- arch/arm/Kconfig | 1 + arch/arm/kernel/entry-common.S | 5 +++++ 2 files changed, 6 insertions(+)arch/arm/Kconfig +1
-0@@ -12,6 +12,7 @@ config ARM select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_MIGHT_HAVE_PC_PARPORT + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 select ARCH_SUPPORTS_ATOMIC_RMWarch/arm/kernel/entry-common.S +0
-0
arch/arm/kernel/entry-common.S line 44
Quoted 6 lines
arch/arm/kernel/entry-common.S +3
-0@@ -39,6 +39,9 @@ ret_fast_syscall: UNWIND(.fnstart ) UNWIND(.cantunwind ) + push {r0} @ save returned r0 + bl verify_pre_usermode_state + pop {r0} @ restore r0
This really makes the fast exit utterly pointless, and we might as well rip all that out.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Re: [PATCH v1 3/4] arm/syscalls: Specific usage of verify_pre_usermode_state
In reply to Thomas GarnierQuoted 26 lines · Thomas Garnier
Implement specific usage of
verify_pre_usermode_statefor user-mode returns for arm.
---
Based on next-20170308--- arch/arm/Kconfig | 1 + arch/arm/kernel/entry-common.S | 5 +++++ 2 files changed, 6 insertions(+)arch/arm/Kconfig +1
-0@@ -12,6 +12,7 @@ config ARM select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_MIGHT_HAVE_PC_PARPORT + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 select ARCH_SUPPORTS_ATOMIC_RMWarch/arm/kernel/entry-common.S +0
-0
arch/arm/kernel/entry-common.S line 47
Quoted 9 lines
arch/arm/kernel/entry-common.S +3
-0@@ -39,6 +39,9 @@ ret_fast_syscall: UNWIND(.fnstart ) UNWIND(.cantunwind ) + push {r0} @ save returned r0 + bl verify_pre_usermode_state + pop {r0} @ restore r0 disable_irq_notrace @ disable interrupts ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
This feature is configurable, right?
Here the branch overhead is imposed even if the feature is configured out. You should consider conditionally defining a macro like some other features do.
Furthermore I think we still support old toolchains that don't know what push and pop mean. You should use the legacy syntax instead.
Nicolas
[kernel-hardening] Re: [PATCH v1 3/4] arm/syscalls: Specific usage of verify_pre_usermode_state
Make sense, as discussed on patch number one, I will write custom assembly for each architecture when BUG_ON is not required. I will try to use macros to make it easier to read.
Quoted 49 lines · Nicolas Pitre
Quoted 26 lines · Thomas Garnier
Implement specific usage of
verify_pre_usermode_statefor user-mode returns for arm.
---
Based on next-20170308--- arch/arm/Kconfig | 1 + arch/arm/kernel/entry-common.S | 5 +++++ 2 files changed, 6 insertions(+)arch/arm/Kconfig +1
-0@@ -12,6 +12,7 @@ config ARM select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_MIGHT_HAVE_PC_PARPORT + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7 select ARCH_SUPPORTS_ATOMIC_RMWarch/arm/kernel/entry-common.S +0
-0arch/arm/kernel/entry-common.S line 47
Quoted 9 lines
arch/arm/kernel/entry-common.S +3
-0@@ -39,6 +39,9 @@ ret_fast_syscall: UNWIND(.fnstart ) UNWIND(.cantunwind ) + push {r0} @ save returned r0 + bl verify_pre_usermode_state + pop {r0} @ restore r0 disable_irq_notrace @ disable interrupts ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASKThis feature is configurable, right?
Here the branch overhead is imposed even if the feature is configured out. You should consider conditionally defining a macro like some other features do.
Furthermore I think we still support old toolchains that don't know what push and pop mean. You should use the legacy syntax instead.
Nicolas
Signature · 1 line
Thomas
PATCH 4/4 arm64/syscalls: Specific usage of verify_pre_usermode_state
In reply to Thomas GarnierImplement specific usage of verify_pre_usermode_state for user-mode returns for arm64.
---
Based on next-20170308
--- arch/arm64/Kconfig | 1 + arch/arm64/kernel/entry.S | 2 ++ 2 files changed, 3 insertions(+)
arch/arm64/Kconfig +1 -0
@@ -24,6 +24,7 @@ config ARM64 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION select ARCH_WANT_FRAME_POINTERS select ARCH_HAS_UBSAN_SANITIZE_ALL + select ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE select ARM_AMBA select ARM_ARCH_TIMER select ARM_GIC
arch/arm64/kernel/entry.S +2 -0
@@ -744,6 +744,7 @@ ENDPROC(cpu_switch_to) ret_fast_syscall: disable_irq // disable interrupts str x0, [sp, #S_X0] // returned x0 + bl verify_pre_usermode_state ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing and x2, x1, #_TIF_SYSCALL_WORK cbnz x2, ret_fast_syscall_trace
@@ -771,6 +772,7 @@ work_pending: */ ret_to_user: disable_irq // disable interrupts + bl verify_pre_usermode_state ldr x1, [tsk, #TSK_TI_FLAGS] and x2, x1, #_TIF_WORK_MASK cbnz x2, work_pending
Signature · 1 line
2.12.0.246.ga2ecc84866-goog
Quoted 4 lines · Thomas Garnier
This patch prevents a syscall to modify the address limit of the caller. The address limit is kept by the syscall wrapper and restored just after the syscall ends.
Quoted 8 lines
For example, it would mitigation this bug:
- https://bugs.chromium.org/p/project-zero/issues/detail?id=990
By default, this change warns if the segment is incorrect while returning to user-mode and fix it. The
CONFIG_VERIFY_PRE_USERMODE_STATE_BUGoption can be enabled to halt instead if needed.
Instead of this new config, please reuse the CHECK_DATA_CORRUPTION test instead, which already controls very similar WARN vs BUG behavior. Example below...
Quoted 87 lines
The
CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATEoption is also added so each architecture can optimize how theverify_pre_usermode_statefunction is called.Signed-off-by Thomas Garnier <[email protected]>---
Based on next-20170308--- include/linux/syscalls.h | 19 +++++++++++++++++++ init/Kconfig | 16 ++++++++++++++++ kernel/sys.c | 11 +++++++++++ 3 files changed, 46 insertions(+)include/linux/syscalls.h +19
-0@@ -191,6 +191,22 @@ extern struct trace_event_functions exit_syscall_print_funcs; SYSCALL_METADATA(sname, x, __VA_ARGS__) \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) +asmlinkage void verify_pre_usermode_state(void); + +#ifndef CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE +static inline bool has_user_ds (void ) { +bool ret =segment_eq (get_fs (),USER_DS ); +// Prevent re-ordering the call +barrier (); +return ret; +} +#else +static inline bool has_user_ds (void ) { +return false; +} +#endif + +#define __PROTECT (...) asmlinkage_protect(__VA_ARGS__)#define __SYSCALL_DEFINEx (x, name, ...) \ asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \@@ -199,7 +215,10 @@ extern struct trace_event_functions exit_syscall_print_funcs; asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ { \ + bool user_caller = has_user_ds(); \ long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ + if (user_caller) \ + verify_pre_usermode_state(); \ __MAP(x,__SC_TEST,__VA_ARGS__); \ __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ return ret; \init/Kconfig +16
-0@@ -1929,6 +1929,22 @@ config PROFILING config TRACEPOINTS bool +# +# Set by each architecture that want to optimize how verify_pre_usermode_state +# is called. +# +config ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE + bool + +config VERIFY_PRE_USERMODE_STATE_BUG + bool "Halt on incorrect state on returning to user-mode" + default n + help + By default a warning is logged and the state is fixed. This option + crashes the kernel instead. + + If unsure, say Y. + source "arch/Kconfig" endmenu # General setupkernel/sys.c +0
-0@@ -2459,3 +2459,14 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info) return 0; }#endif /* CONFIG_COMPAT */
kernel/sys.c COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info) · line 2471
Quoted 10 lines
kernel/sys.c +10
-0+ +/* Called before coming back to user-mode */ +asmlinkage void verify_pre_usermode_state(void) +{ +#ifdef CONFIG_VERIFY_PRE_USERMODE_STATE_BUG +BUG_ON (!segment_eq (get_fs (),USER_DS )); +#else +if (WARN_ON (!segment_eq (get_fs (),USER_DS ))) +set_fs (USER_DS ); +#endif
I would just make this:
if (CHECK_DATA_CORRUPTION(!segment_eq(get_fs(), USER_DS))
set_fs(USER_DS);
-Kees
Signature · 2 lines
Kees Cook Pixel Security
Quoted 118 lines · Kees Cook
Quoted 4 lines · Thomas Garnier
This patch prevents a syscall to modify the address limit of the caller. The address limit is kept by the syscall wrapper and restored just after the syscall ends.
Quoted 8 lines
For example, it would mitigation this bug:
- https://bugs.chromium.org/p/project-zero/issues/detail?id=990
By default, this change warns if the segment is incorrect while returning to user-mode and fix it. The
CONFIG_VERIFY_PRE_USERMODE_STATE_BUGoption can be enabled to halt instead if needed.Instead of this new config, please reuse the
CHECK_DATA_CORRUPTIONtest instead, which already controls very similar WARN vs BUG behavior. Example below...Quoted 87 lines
The
CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATEoption is also added so each architecture can optimize how theverify_pre_usermode_statefunction is called.Signed-off-by Thomas Garnier <[email protected]>---
Based on next-20170308--- include/linux/syscalls.h | 19 +++++++++++++++++++ init/Kconfig | 16 ++++++++++++++++ kernel/sys.c | 11 +++++++++++ 3 files changed, 46 insertions(+)include/linux/syscalls.h +19
-0@@ -191,6 +191,22 @@ extern struct trace_event_functions exit_syscall_print_funcs; SYSCALL_METADATA(sname, x, __VA_ARGS__) \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) +asmlinkage void verify_pre_usermode_state(void); + +#ifndef CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE +static inline bool has_user_ds (void ) { +bool ret =segment_eq (get_fs (),USER_DS ); +// Prevent re-ordering the call +barrier (); +return ret; +} +#else +static inline bool has_user_ds (void ) { +return false; +} +#endif + +#define __PROTECT (...) asmlinkage_protect(__VA_ARGS__)#define __SYSCALL_DEFINEx (x, name, ...) \ asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \@@ -199,7 +215,10 @@ extern struct trace_event_functions exit_syscall_print_funcs; asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ { \ + bool user_caller = has_user_ds(); \ long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ + if (user_caller) \ + verify_pre_usermode_state(); \ __MAP(x,__SC_TEST,__VA_ARGS__); \ __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ return ret; \init/Kconfig +16
-0@@ -1929,6 +1929,22 @@ config PROFILING config TRACEPOINTS bool +# +# Set by each architecture that want to optimize how verify_pre_usermode_state +# is called. +# +config ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE + bool + +config VERIFY_PRE_USERMODE_STATE_BUG + bool "Halt on incorrect state on returning to user-mode" + default n + help + By default a warning is logged and the state is fixed. This option + crashes the kernel instead. + + If unsure, say Y. + source "arch/Kconfig" endmenu # General setupkernel/sys.c +0
-0@@ -2459,3 +2459,14 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info) return 0; }#endif /* CONFIG_COMPAT */ kernel/sys.c COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info) · line 2471
Quoted 10 lines
kernel/sys.c +10
-0+ +/* Called before coming back to user-mode */ +asmlinkage void verify_pre_usermode_state(void) +{ +#ifdef CONFIG_VERIFY_PRE_USERMODE_STATE_BUG +BUG_ON (!segment_eq (get_fs (),USER_DS )); +#else +if (WARN_ON (!segment_eq (get_fs (),USER_DS ))) +set_fs (USER_DS ); +#endif I would just make this:
Quoted 3 lines
if (
CHECK_DATA_CORRUPTION(!segment_eq(get_fs(), USER_DS))set_fs(USER_DS);
Make sense, I will remove my custom CONFIG and use that one instead (still doing inline assembly if not set).
Quoted 6 lines
-Kees
--
Kees Cook
Pixel Security
Signature · 1 line
Thomas
Russell King - ARM Linux
maintainerQuoted 3 lines · Thomas Garnier
This patch prevents a syscall to modify the address limit of the caller. The address limit is kept by the syscall wrapper and restored just after the syscall ends.
I would much rather architectures were given the opportunity to code up checks like this efficiently (iow, inline in the exit path assembly), rather than having to unconditionally call an additional function on every syscall, with its register saving overheads.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Quoted 10 lines · Russell King - ARM Linux
Quoted 3 lines · Thomas Garnier
This patch prevents a syscall to modify the address limit of the caller. The address limit is kept by the syscall wrapper and restored just after the syscall ends.
I would much rather architectures were given the opportunity to code up checks like this efficiently (iow, inline in the exit path assembly), rather than having to unconditionally call an additional function on every syscall, with its register saving overheads.
Me too. I think the two config choices should be:
(a) BUG_ON(!segment_eq(...));
(b) No generic check at all -- arch code will handle it
--Andy
That make sense. I will optimize each architecture to not require a call.
Quoted 20 lines · Andy Lutomirski
Quoted 10 lines · Russell King - ARM Linux
Quoted 3 lines · Thomas Garnier
This patch prevents a syscall to modify the address limit of the caller. The address limit is kept by the syscall wrapper and restored just after the syscall ends.
I would much rather architectures were given the opportunity to code up checks like this efficiently (iow, inline in the exit path assembly), rather than having to unconditionally call an additional function on every syscall, with its register saving overheads.
Me too. I think the two config choices should be:
(a) BUG_ON(!segment_eq(...));
(b) No generic check at all -- arch code will handle it
--Andy
Signature · 1 line
Thomas