* [PATCH v2 1/2] fcntl: recheck signal permissions before falling back to SIGIO
[not found] <cover.1795434950.git.shilc2025@mail.sustech.edu.cn>
@ 2026-11-23 12:13 ` Shi Lecun
2026-11-23 12:23 ` sashiko-bot
2026-11-23 12:13 ` [PATCH v2 2/2] apparmor: mediate file-generated signals Shi Lecun
1 sibling, 1 reply; 4+ messages in thread
From: Shi Lecun @ 2026-11-23 12:13 UTC (permalink / raw)
To: John Johansen, Georgia Garcia, Alexander Viro, Christian Brauner
Cc: Paul Moore, James Morris, Serge E. Hallyn, Seth Arnold,
Jeff Layton, Chuck Lever, Alexander Aring, Jan Kara, apparmor,
linux-security-module, linux-fsdevel, linux-kernel, Fengwei Zhang,
Josef Bacik
F_SETSIG allows a file owner to request a signal other than SIGIO.
send_sigio_to_task() checks permission for the configured signal, but
if queuing fails, it falls back to SIGIO without checking permission
for the fallback. An LSM can grant different permissions for the two
signals.
Recheck permission before falling back from a different signal to
SIGIO. Keep the existing behavior when SIGIO itself has already been
checked.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lore.kernel.org/all/20261120-appetit-undankbar-bankraub-d2f1994e97b3@brauner/
Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Shi Lecun <shilc2025@mail.sustech.edu.cn>
---
fs/fcntl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 07fe32330bec..320cdb0c6780 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -905,6 +905,9 @@ static void send_sigio_to_task(struct task_struct *p,
si.si_fd = fd;
if (!do_send_sig_info(signum, &si, p, type))
break;
+ /* The fallback signal may have different permissions. */
+ if (signum != SIGIO && !sigio_perm(p, fown, SIGIO))
+ break;
}
fallthrough; /* fall back on the old plain SIGIO signal */
case 0:
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] apparmor: mediate file-generated signals
[not found] <cover.1795434950.git.shilc2025@mail.sustech.edu.cn>
2026-11-23 12:13 ` [PATCH v2 1/2] fcntl: recheck signal permissions before falling back to SIGIO Shi Lecun
@ 2026-11-23 12:13 ` Shi Lecun
2026-11-23 12:23 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: Shi Lecun @ 2026-11-23 12:13 UTC (permalink / raw)
To: John Johansen, Georgia Garcia, Alexander Viro, Christian Brauner
Cc: Paul Moore, James Morris, Serge E. Hallyn, Seth Arnold,
Jeff Layton, Chuck Lever, Alexander Aring, Jan Kara, apparmor,
linux-security-module, linux-fsdevel, linux-kernel, Fengwei Zhang,
Josef Bacik
File-generated SIGIO and SIGURG notifications use file_send_sigiotask
rather than task_kill. AppArmor does not implement that hook, so its
signal send and receive rules are not enforced on this path.
Implement file_send_sigiotask using the credentials of the task that
set the file owner. The VFS holds those credentials in fown->cred under
fown->lock, which is held during signal delivery. This also supplies the
sender identity when delivery runs in interrupt context.
Reuse the AppArmor signal permission check with the saved credentials
so it resolves both labels and enforces the send and receive rules.
Treat a zero signal argument as SIGIO, as specified by the hook.
Fixes: cd1dbf76b23d ("apparmor: add the ability to mediate signals")
Link: https://lore.kernel.org/all/20261120-unrentabel-bambus-genuss-0db3576a8f57@brauner/
Signed-off-by: Shi Lecun <shilc2025@mail.sustech.edu.cn>
---
security/apparmor/lsm.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index eaebc3c60c5a..c5f4abc4eab8 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -1031,9 +1031,6 @@ static int apparmor_task_kill(struct task_struct *target, struct kernel_siginfo
tc = get_task_cred(target);
tl = aa_get_newest_cred_label(tc);
if (cred) {
- /*
- * Dealing with USB IO specific behavior
- */
cl = aa_get_newest_cred_label(cred);
error = aa_may_signal(cred, cl, tc, tl, sig);
aa_put_label(cl);
@@ -1048,6 +1045,13 @@ static int apparmor_task_kill(struct task_struct *target, struct kernel_siginfo
return error;
}
+static int apparmor_file_send_sigiotask(struct task_struct *target,
+ struct fown_struct *fown, int sig)
+{
+ lockdep_assert_held(&fown->lock);
+ return apparmor_task_kill(target, NULL, sig ? sig : SIGIO, fown->cred);
+}
+
static int apparmor_userns_create(const struct cred *cred)
{
struct aa_label *label;
@@ -1810,6 +1814,7 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = {
LSM_HOOK_INIT(file_permission, apparmor_file_permission),
LSM_HOOK_INIT(file_alloc_security, apparmor_file_alloc_security),
LSM_HOOK_INIT(file_free_security, apparmor_file_free_security),
+ LSM_HOOK_INIT(file_send_sigiotask, apparmor_file_send_sigiotask),
LSM_HOOK_INIT(mmap_file, apparmor_mmap_file),
LSM_HOOK_INIT(file_mprotect, apparmor_file_mprotect),
LSM_HOOK_INIT(file_lock, apparmor_file_lock),
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread