Skip to content

Commit dd69edd

Browse files
oleg-nesterovakpm00
authored andcommitted
get_signal: hide_si_addr_tag_bits: fix the usage of uninitialized ksig
ksig->ka and ksig->info are not initialized if get_signal() returns 0 or if the caller is PF_USER_WORKER. Check signr != 0 before SA_EXPOSE_TAGBITS and move the "out" label down. The latter means that ksig->sig won't be initialized if a PF_USER_WORKER thread gets a fatal signal but this is fine, PF_USER_WORKER's don't use ksig. And there is nothing new, in this case ksig->ka and ksig-info are not initialized anyway. Add a comment. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Oleg Nesterov <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Eric W. Biederman <[email protected]> Cc: Peter Collingbourne <[email protected]> Cc: Wen Yang <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 49fd5f5 commit dd69edd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

kernel/signal.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,8 +2881,9 @@ bool get_signal(struct ksignal *ksig)
28812881

28822882
/*
28832883
* PF_USER_WORKER threads will catch and exit on fatal signals
2884-
* themselves. They have cleanup that must be performed, so
2885-
* we cannot call do_exit() on their behalf.
2884+
* themselves. They have cleanup that must be performed, so we
2885+
* cannot call do_exit() on their behalf. Note that ksig won't
2886+
* be properly initialized, PF_USER_WORKER's shouldn't use it.
28862887
*/
28872888
if (current->flags & PF_USER_WORKER)
28882889
goto out;
@@ -2894,12 +2895,12 @@ bool get_signal(struct ksignal *ksig)
28942895
/* NOTREACHED */
28952896
}
28962897
spin_unlock_irq(&sighand->siglock);
2897-
out:
2898+
28982899
ksig->sig = signr;
28992900

2900-
if (!(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS))
2901+
if (signr && !(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS))
29012902
hide_si_addr_tag_bits(ksig);
2902-
2903+
out:
29032904
return signr > 0;
29042905
}
29052906

0 commit comments

Comments
 (0)