signal: break out of wait loops on kthread_stop()

This is a small tweak to kthread_stop so it breaks out of
 interruptible waits, that don't explicitly test for kthread_stop.
 These interruptible waits occassionaly occur in kernel threads do to
 code sharing.
 
 Jason A. Donenfeld (1):
       signal: break out of wait loops on kthread_stop()
 
  kernel/kthread.c | 1 +
  1 file changed, 1 insertion(+)
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEgjlraLDcwBA2B+6cC/v6Eiajj0AFAmM7U4sACgkQC/v6Eiaj
 j0Di4Q/+KVI0l+QyKXK9tFnZnH0NEMzv1UsexkwmBIz0mKTCzmfeNIqBerxNBD0q
 YJ1xE2SvZB93w1KKZ2U5R+7ktRx7KDYUnko9voB0zK+2Tk1julKtfUyY0ly3GQTS
 GOMwJG3N/bxzxJjXlNNPOL8dILua0RPtD3vmkUpybDu3OJycNXVL0AVL8I4frkpH
 myMCdckXWWDkKGI87i6Pjn6nuEhN4z8CpjZBeEWPpLLyqD10CKN9B4zbHhAbFinB
 BkDu4TB+CPSXc4YOMTyLgvMnD4FyyI7SroxIaF1O8GhDztEYTbqKpRpVyLfhiIbi
 YAdAFJFJpCKvNTNzYcMYiZ9uCWLnmyPo6LpZNEgLfMyVIr0dRUS9bd/KzoLTz8KE
 gK3B2OfzorSqHjTPt0kcs9hTepSjqcMfeuvGDSz/8bCiTRRBlKay16F3v+sSAVQ0
 0bknG7bPsQQzkkdgBqu78kP2lt182z8dGI9DXmrp6/FFsD1SgFcG9AEPPFkLCRL8
 TmKRgnFDuwJuQ5zC6ITOgsH53F5xDVEVImnMwNbmjx0oSQoUsf0CgBfyM03UKwX0
 OOQbIK+eE8cj0lC4R7iMg2M6ATj7qQf65AEx480+cgX/kpJMzwCTvf20sRKes02L
 HQEIn8nz+IBvR4v031IjhjWTGbrT4dPh4G7gTHRaPc7UzqzshB8=
 =tVlW
 -----END PGP SIGNATURE-----

Merge tag 'interrupting_kthread_stop-for-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace

Pull kthread update from Eric Biederman:
 "Break out of wait loops on kthread_stop()

  This is a small tweak to kthread_stop so it breaks out of
  interruptible waits, that don't explicitly test for kthread_stop.

  These interruptible waits occassionaly occur in kernel threads do to
  code sharing"

* tag 'interrupting_kthread_stop-for-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  signal: break out of wait loops on kthread_stop()
This commit is contained in:
Linus Torvalds 2022-10-09 16:01:59 -07:00
commit c71370bde7

View File

@ -704,6 +704,7 @@ int kthread_stop(struct task_struct *k)
kthread = to_kthread(k);
set_bit(KTHREAD_SHOULD_STOP, &kthread->flags);
kthread_unpark(k);
set_tsk_thread_flag(k, TIF_NOTIFY_SIGNAL);
wake_up_process(k);
wait_for_completion(&kthread->exited);
ret = kthread->result;