[patch 38/45] signal: Add task argument to flush_sigqueue_mask()

From: Thomas Gleixner
Date: Tue Jun 06 2023 - 10:41:42 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
@@ -727,11 +727,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;
@@ -869,18 +868,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;
@@ -4097,8 +4096,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);
@@ -4165,9 +4164,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);
}
}