* [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
* Re: [PATCH v2 2/2] apparmor: mediate file-generated signals
2026-11-23 12:13 ` [PATCH v2 2/2] apparmor: mediate file-generated signals Shi Lecun
@ 2026-11-23 12:23 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-23 12:23 UTC (permalink / raw)
Cc: linux-security-module
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] apparmor: nonexistent fown->cred access in
apparmor_file_send_sigiotask()
--
commit adb1f63ac0d010cf15636cb43e53dd9299246228
Author: Shi Lecun <shilc2025@mail.sustech.edu.cn>
apparmor: mediate file-generated signals
This commit adds a file_send_sigiotask hook to AppArmor to mediate
file-generated SIGIO and SIGURG notifications.
Link: https://lore.kernel.org/all/20261120-unrentabel-bambus-genuss-0db3576a8f57@brauner/
> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> index d502ad0ac26f5..1a6e49bd50311 100644
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
[ ... ]
> @@ -1047,6 +1044,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);
> +}
[Severity: High]
Does this compile when CONFIG_SECURITY_APPARMOR is enabled?
struct fown_struct has no cred member; __f_setown() only records uid and
euid on f_owner and calls security_file_set_fowner(filp) so LSMs can store
the file owner context in their file security blob via fown->file.
--
Sashiko AI review · https://sashiko.dev/#/patchset/54EBCABD3ACBF0A5+9d780112081161e2f99fe501c2c38f1614a68a42.1795434950.git.shilc2025@mail.sustech.edu.cn?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] fcntl: recheck signal permissions before falling back to SIGIO
2026-11-23 12:13 ` [PATCH v2 1/2] fcntl: recheck signal permissions before falling back to SIGIO Shi Lecun
@ 2026-11-23 12:23 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-23 12:23 UTC (permalink / raw)
Cc: linux-security-module
Sashiko has finished reviewing this 2-patch series:
- Patch 1: no issues found.
- Patch 2 ("apparmor: mediate file-generated signals"): 1 potential
issue (1 High)
A detailed review has been sent as a separate reply to patch 2.
--
Sashiko AI review · https://sashiko.dev/#/patchset/54EBCABD3ACBF0A5+9d780112081161e2f99fe501c2c38f1614a68a42.1795434950.git.shilc2025@mail.sustech.edu.cn
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 12:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[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:23 ` sashiko-bot
2026-11-23 12:13 ` [PATCH v2 2/2] apparmor: mediate file-generated signals Shi Lecun
2026-11-23 12:23 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox