mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] posix-timers: Require privilege to enable timer ID restore mode
@ 2026-04-09  3:27 Ashutosh Desai
  2026-04-13 18:34 ` Andrei Vagin
  0 siblings, 1 reply; 3+ messages in thread
From: Ashutosh Desai @ 2026-04-09  3:27 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Anna-Maria Behnsen, linux-kernel, Ashutosh Desai

PR_TIMER_CREATE_RESTORE_IDS_ON switches timer_create() into a mode
where the caller supplies explicit timer IDs, intended exclusively for
CRIU checkpoint/restore. The UAPI comment is explicit: "Don't use for
normal operations as the result might be undefined."

Despite that, the prctl handler has no capability check. Any unprivileged
process can enable the mode. Every comparable CRIU prctl in the kernel
gates on checkpoint_restore_ns_capable() - PR_SET_MM_MAP, PR_SET_MM_EXE_FILE,
etc. This one should too.

Add the check to the ON case only. OFF and GET are left unrestricted so a
process can always query or clear the flag without privilege.

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Ashutosh Desai <ashutoshdesai993@gmail.com>
---
 kernel/time/posix-timers.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 413e2389f..b8582416b 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -9,6 +9,7 @@
  *
  * These are all the functions necessary to implement POSIX clocks & timers
  */
+#include <linux/capability.h>
 #include <linux/compat.h>
 #include <linux/compiler.h>
 #include <linux/init.h>
@@ -380,6 +381,8 @@ long posixtimer_create_prctl(unsigned long ctrl)
 		current->signal->timer_create_restore_ids = 0;
 		return 0;
 	case PR_TIMER_CREATE_RESTORE_IDS_ON:
+		if (!checkpoint_restore_ns_capable(current_user_ns()))
+			return -EPERM;
 		current->signal->timer_create_restore_ids = 1;
 		return 0;
 	case PR_TIMER_CREATE_RESTORE_IDS_GET:
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-14  0:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-09  3:27 [PATCH] posix-timers: Require privilege to enable timer ID restore mode Ashutosh Desai
2026-04-13 18:34 ` Andrei Vagin
2026-04-14  0:22   ` Ashutosh Desai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®