[patch V2 43/50] signal: Add task argument to flush_sigqueue_mask()

From: Thomas Gleixner
Date: Wed Apr 10 2024 - 18:55:48 EST


To prepare for handling posix timer signals on sigaction(SIG_IGN) properly,
add a task argument to flush_sigqueue_mask() and fixup all call sites.

This argument will be used in a later step to enqueue posix timers on an
ignored list, so their signal can be requeued when SIG_IGN is lifted later
on.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---
kernel/signal.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -724,11 +724,10 @@ void signal_wake_up_state(struct task_st

/*
* Remove signals in mask from the pending set and queue.
- * Returns 1 if any signals were found.
*
* All callers must be holding the siglock.
*/
-static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
+static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s, struct task_struct *ptmr_tsk)
{
struct sigqueue *q, *n;
sigset_t m;
@@ -866,18 +865,18 @@ static bool prepare_signal(int sig, stru
* This is a stop signal. Remove SIGCONT from all queues.
*/
siginitset(&flush, sigmask(SIGCONT));
- flush_sigqueue_mask(&flush, &signal->shared_pending);
+ flush_sigqueue_mask(&flush, &signal->shared_pending, NULL);
for_each_thread(p, t)
- flush_sigqueue_mask(&flush, &t->pending);
+ flush_sigqueue_mask(&flush, &t->pending, NULL);
} else if (sig == SIGCONT) {
unsigned int why;
/*
* Remove all stop signals from all queues, wake all threads.
*/
siginitset(&flush, SIG_KERNEL_STOP_MASK);
- flush_sigqueue_mask(&flush, &signal->shared_pending);
+ flush_sigqueue_mask(&flush, &signal->shared_pending, NULL);
for_each_thread(p, t) {
- flush_sigqueue_mask(&flush, &t->pending);
+ flush_sigqueue_mask(&flush, &t->pending, NULL);
task_clear_jobctl_pending(t, JOBCTL_STOP_PENDING);
if (likely(!(t->ptrace & PT_SEIZED))) {
t->jobctl &= ~JOBCTL_STOPPED;
@@ -4155,8 +4154,8 @@ void kernel_sigaction(int sig, __sighand
sigemptyset(&mask);
sigaddset(&mask, sig);

- flush_sigqueue_mask(&mask, &current->signal->shared_pending);
- flush_sigqueue_mask(&mask, &current->pending);
+ flush_sigqueue_mask(&mask, &current->signal->shared_pending, NULL);
+ flush_sigqueue_mask(&mask, &current->pending, NULL);
recalc_sigpending();
}
spin_unlock_irq(&current->sighand->siglock);
@@ -4223,9 +4222,9 @@ int do_sigaction(int sig, struct k_sigac
if (sig_handler_ignored(sig_handler(p, sig), sig)) {
sigemptyset(&mask);
sigaddset(&mask, sig);
- flush_sigqueue_mask(&mask, &p->signal->shared_pending);
+ flush_sigqueue_mask(&mask, &p->signal->shared_pending, NULL);
for_each_thread(p, t)
- flush_sigqueue_mask(&mask, &t->pending);
+ flush_sigqueue_mask(&mask, &t->pending, NULL);
}
}