Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: use do_futex() instead of sys_futex() in mm_release()

sys_futex() is a wrapper to do_futex() which does not modify any
values here:

- uaddr, val and val3 are kept the same

- op is masked with FUTEX_CMD_MASK, but is always set to FUTEX_WAKE.
Therefore, val2 is always 0.

- as utime is set to NULL, *timeout is NULL

This patch is part of a series which removes in-kernel calls to syscalls.
On this basis, the syscall entry path can be streamlined. For details, see
http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>

+12 -5
+10 -3
include/linux/futex.h
··· 9 9 struct mm_struct; 10 10 struct task_struct; 11 11 12 - long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, 13 - u32 __user *uaddr2, u32 val2, u32 val3); 14 - 15 12 extern int 16 13 handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi); 17 14 ··· 52 55 53 56 #ifdef CONFIG_FUTEX 54 57 extern void exit_robust_list(struct task_struct *curr); 58 + 59 + long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout, 60 + u32 __user *uaddr2, u32 val2, u32 val3); 55 61 #ifdef CONFIG_HAVE_FUTEX_CMPXCHG 56 62 #define futex_cmpxchg_enabled 1 57 63 #else ··· 63 63 #else 64 64 static inline void exit_robust_list(struct task_struct *curr) 65 65 { 66 + } 67 + 68 + static inline long do_futex(u32 __user *uaddr, int op, u32 val, 69 + ktime_t *timeout, u32 __user *uaddr2, 70 + u32 val2, u32 val3) 71 + { 72 + return -EINVAL; 66 73 } 67 74 #endif 68 75
+2 -2
kernel/fork.c
··· 1198 1198 * not set up a proper pointer then tough luck. 1199 1199 */ 1200 1200 put_user(0, tsk->clear_child_tid); 1201 - sys_futex(tsk->clear_child_tid, FUTEX_WAKE, 1202 - 1, NULL, NULL, 0); 1201 + do_futex(tsk->clear_child_tid, FUTEX_WAKE, 1202 + 1, NULL, NULL, 0, 0); 1203 1203 } 1204 1204 tsk->clear_child_tid = NULL; 1205 1205 }