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

signal: Move set_notify_signal and clear_notify_signal into sched/signal.h

The header tracehook.h is no place for code to live. The functions
set_notify_signal and clear_notify_signal are not about signals. They
are about interruptions that act like signals. The fundamental signal
primitives wind up calling set_notify_signal and clear_notify_signal.
Which means they need to be maintained with the signal code.

Since set_notify_signal and clear_notify_signal must be maintained
with the signal subsystem move them into sched/signal.h and claim them
as part of the signal subsystem.

Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20220309162454.123006-10-ebiederm@xmission.com
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+17 -17
+17
include/linux/sched/signal.h
··· 349 349 extern int send_sigqueue(struct sigqueue *, struct pid *, enum pid_type); 350 350 extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *); 351 351 352 + static inline void clear_notify_signal(void) 353 + { 354 + clear_thread_flag(TIF_NOTIFY_SIGNAL); 355 + smp_mb__after_atomic(); 356 + } 357 + 358 + /* 359 + * Called to break out of interruptible wait loops, and enter the 360 + * exit_to_user_mode_loop(). 361 + */ 362 + static inline void set_notify_signal(struct task_struct *task) 363 + { 364 + if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_SIGNAL) && 365 + !wake_up_state(task, TASK_INTERRUPTIBLE)) 366 + kick_process(task); 367 + } 368 + 352 369 static inline int restart_syscall(void) 353 370 { 354 371 set_tsk_thread_flag(current, TIF_SIGPENDING);
-17
include/linux/tracehook.h
··· 106 106 rseq_handle_notify_resume(NULL, regs); 107 107 } 108 108 109 - static inline void clear_notify_signal(void) 110 - { 111 - clear_thread_flag(TIF_NOTIFY_SIGNAL); 112 - smp_mb__after_atomic(); 113 - } 114 - 115 - /* 116 - * Called to break out of interruptible wait loops, and enter the 117 - * exit_to_user_mode_loop(). 118 - */ 119 - static inline void set_notify_signal(struct task_struct *task) 120 - { 121 - if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_SIGNAL) && 122 - !wake_up_state(task, TASK_INTERRUPTIBLE)) 123 - kick_process(task); 124 - } 125 - 126 109 #endif /* <linux/tracehook.h> */