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 <[email protected]>
Signed-off-by: Shi Lecun <[email protected]>
---
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