]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - kernel/signal.c
Merge tag 'mm-nonmm-stable-2024-03-14-09-36' of git://git.kernel.org/pub/scm/linux...
[thirdparty/linux.git] / kernel / signal.c
index bdca529f0f7b7aa23e377afca0bf9cc6d04a6473..7bdbcf1b78d0fa0d9f3fbde4b61e31ca5595f453 100644 (file)
@@ -2741,12 +2741,15 @@ relock:
                /* Has this task already been marked for death? */
                if ((signal->flags & SIGNAL_GROUP_EXIT) ||
                     signal->group_exec_task) {
-                       clear_siginfo(&ksig->info);
-                       ksig->info.si_signo = signr = SIGKILL;
+                       signr = SIGKILL;
                        sigdelset(&current->pending.signal, SIGKILL);
                        trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO,
-                               &sighand->action[SIGKILL - 1]);
+                                            &sighand->action[SIGKILL-1]);
                        recalc_sigpending();
+                       /*
+                        * implies do_group_exit() or return to PF_USER_WORKER,
+                        * no need to initialize ksig->info/etc.
+                        */
                        goto fatal;
                }
 
@@ -2856,7 +2859,7 @@ relock:
                                spin_lock_irq(&sighand->siglock);
                        }
 
-                       if (likely(do_signal_stop(ksig->info.si_signo))) {
+                       if (likely(do_signal_stop(signr))) {
                                /* It released the siglock.  */
                                goto relock;
                        }
@@ -2880,7 +2883,7 @@ relock:
 
                if (sig_kernel_coredump(signr)) {
                        if (print_fatal_signals)
-                               print_fatal_signal(ksig->info.si_signo);
+                               print_fatal_signal(signr);
                        proc_coredump_connector(current);
                        /*
                         * If it was able to dump core, this kills all
@@ -2895,8 +2898,9 @@ relock:
 
                /*
                 * PF_USER_WORKER threads will catch and exit on fatal signals
-                * themselves. They have cleanup that must be performed, so
-                * we cannot call do_exit() on their behalf.
+                * themselves. They have cleanup that must be performed, so we
+                * cannot call do_exit() on their behalf. Note that ksig won't
+                * be properly initialized, PF_USER_WORKER's shouldn't use it.
                 */
                if (current->flags & PF_USER_WORKER)
                        goto out;
@@ -2904,17 +2908,17 @@ relock:
                /*
                 * Death signals, no core dump.
                 */
-               do_group_exit(ksig->info.si_signo);
+               do_group_exit(signr);
                /* NOTREACHED */
        }
        spin_unlock_irq(&sighand->siglock);
-out:
+
        ksig->sig = signr;
 
-       if (!(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS))
+       if (signr && !(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS))
                hide_si_addr_tag_bits(ksig);
-
-       return ksig->sig > 0;
+out:
+       return signr > 0;
 }
 
 /**