linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] syscalls: Restore address limit after a syscall
@ 2017-02-09 18:33 Thomas Garnier
       [not found] ` <20170209183358.103094-1-thgarnie-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Garnier @ 2017-02-09 18:33 UTC (permalink / raw)
  To: Dave Hansen, Arnd Bergmann, René Nyffenegger, Stephen Bates,
	Jeff Moyer, Milosz Tanski, Thomas Garnier
  Cc: linux-api, linux-kernel, kernel-hardening

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

Signed-off-by: Thomas Garnier <thgarnie@google.com>
---
Based on next-20170209
---
 include/linux/syscalls.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 91a740f6b884..a1b6a62a9849 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -198,7 +198,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__))	\
 	{								\
-		long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__));	\
+		long ret;						\
+		mm_segment_t fs = get_fs();				\
+		ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__));	\
+		set_fs(fs);						\
 		__MAP(x,__SC_TEST,__VA_ARGS__);				\
 		__PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__));	\
 		return ret;						\
-- 
2.11.0.483.g087da7b7c-goog

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-02-10 21:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-09 18:33 [RFC] syscalls: Restore address limit after a syscall Thomas Garnier
     [not found] ` <20170209183358.103094-1-thgarnie-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-02-09 19:31   ` Kees Cook
2017-02-09 23:05     ` Andy Lutomirski
2017-02-09 23:41       ` Thomas Garnier
2017-02-10  2:42         ` Andy Lutomirski
2017-02-10 19:22           ` Russell King - ARM Linux
2017-02-10 20:49             ` Kees Cook
     [not found]               ` <CAGXu5jJf5z5f0O=T4awfF98OR7+kaQaFFJu3kXXa402vq-Mj2Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-10 21:49                 ` Russell King - ARM Linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).