[patch v4 02/27] signal: Prevent user space from setting si_sys_private

From: Thomas Gleixner
Date: Fri Sep 27 2024 - 04:49:15 EST


From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

The si_sys_private member of siginfo is used to handle posix-timer rearming
from the signal delivery path. Prevent user space from setting it as that
creates inconsistent state.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

---
kernel/signal.c | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/kernel/signal.c b/kernel/signal.c
index a83ea99f9389..7706cd304785 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3354,6 +3354,14 @@ int copy_siginfo_to_user(siginfo_t __user *to, const kernel_siginfo_t *from)
static int post_copy_siginfo_from_user(kernel_siginfo_t *info,
const siginfo_t __user *from)
{
+ /*
+ * Clear the si_sys_private field for timer signals as that's the
+ * indicator for rearming a posix timer. User space submitted
+ * signals are not allowed to inject that.
+ */
+ if (info->si_code == SI_TIMER)
+ info->si_sys_private = 0;
+
if (unlikely(!known_siginfo_layout(info->si_signo, info->si_code))) {
char __user *expansion = si_expansion(from);
char buf[SI_EXPANSION_SIZE];