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

Configure Feed

Select the types of activity you want to include in your feed.

do_notify_parent: sanitize the valid_signal() checks

Now that kernel_clone() checks valid_signal(args->exit_signal), the "sig"
argument of do_notify_parent() must always be valid or we have a bug.

However, do_notify_parent() only checks that sig != -1 at the start, then
it does another valid_signal() check before __send_signal_locked().

This is confusing. Change do_notify_parent() to WARN and return early if
valid_signal(sig) is false.

Link: https://lkml.kernel.org/r/abld-ilvMEZ7VgMw@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Deepanshu Kartikey <Kartikey406@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Andrew Morton
0f8e38ee 4580900f

+3 -2
+3 -2
kernel/signal.c
··· 2171 2171 bool autoreap = false; 2172 2172 u64 utime, stime; 2173 2173 2174 - WARN_ON_ONCE(sig == -1); 2174 + if (WARN_ON_ONCE(!valid_signal(sig))) 2175 + return false; 2175 2176 2176 2177 /* do_notify_parent_cldstop should have been called instead. */ 2177 2178 WARN_ON_ONCE(task_is_stopped_or_traced(tsk)); ··· 2253 2252 * Send with __send_signal as si_pid and si_uid are in the 2254 2253 * parent's namespaces. 2255 2254 */ 2256 - if (valid_signal(sig) && sig) 2255 + if (sig) 2257 2256 __send_signal_locked(sig, &info, tsk->parent, PIDTYPE_TGID, false); 2258 2257 __wake_up_parent(tsk, tsk->parent); 2259 2258 spin_unlock_irqrestore(&psig->siglock, flags);