[PATCH 02/14] signal: Factor out sig_blocked from sig_ignored

From: Eric W. Biederman

Date: Fri Jul 03 2026 - 17:37:37 EST



Add a helper that spells out the logic of why both blocked
and real_blocked need to be consulted to see if a signal
is blocked.

Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
---
kernel/signal.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 6b49bae3fce7..1a8183606dc0 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -103,6 +103,25 @@ static bool sig_task_ignored(struct task_struct *t, int sig, bool force)
return sig_handler_ignored(handler, sig);
}

+static bool sig_blocked(struct task_struct *t, int sig)
+{
+ /*
+ * Is calling the signal handler blocked?
+ *
+ * Two sigsets need to be consulted to see if the userspace
+ * signal handler can be invoked: thread->blocked and
+ * thread->real_blocked. Ordinarily thread->blocked contains
+ * all of the information and thread->real_blocked is empty.
+ *
+ * When thread->real_blocked is in use it contains the actual
+ * information on which signal handlers can not be invoked and
+ * thread->blocked has a subset of the signals contained in
+ * thread->real_blocked.
+ */
+ return sigismember(&t->blocked, sig) ||
+ sigismember(&t->real_blocked, sig);
+}
+
static bool sig_ignored(struct task_struct *t, int sig, bool force)
{
/*
@@ -110,7 +129,7 @@ static bool sig_ignored(struct task_struct *t, int sig, bool force)
* signal handler may change by the time it is
* unblocked.
*/
- if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
+ if (sig_blocked(t, sig))
return false;

/*
--
2.41.0