Thread (23 messages) flat view 23 messages, 7 authors, 2017-03-09
STALE3438d

Re: [PATCH v2 1/4] syscalls: Restore address limit after a syscall

From: Thomas Garnier <hidden>
Date: 2017-03-09 15:48:03
Also in: linux-arm-kernel

On Thu, Mar 9, 2017 at 12:42 AM, Borislav Petkov [off-list ref] wrote:
On Wed, Mar 08, 2017 at 05:24:53PM -0800, Thomas Garnier wrote:
quoted
@@ -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
This is not the kernel comments style. Use /* */ instead.
quoted
+     barrier();
+     return ret;
+}
+#else
+static inline bool has_user_ds(void) {
+     return false;
+}
+#endif
... and then you could slim down the ifdeffery a bit:

static inline bool has_user_ds(void) {
        bool ret = false;

#ifndef CONFIG_ARCH_NO_SYSCALL_VERIFY_PRE_USERMODE_STATE
        ret = segment_eq(get_fs(), USER_DS);
        /* Prevent re-ordering the call. */
        barrier();
#endif

        return ret;
}
I agree, cleaner. I will look to do this change on next iteration.
--
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.


-- 
Thomas
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help