From: Ashutosh Desai <ashutoshdesai993@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>,
linux-kernel@vger.kernel.org,
Ashutosh Desai <ashutoshdesai993@gmail.com>
Subject: [PATCH] posix-timers: Require privilege to enable timer ID restore mode
Date: Thu, 9 Apr 2026 03:27:10 +0000 [thread overview]
Message-ID: <20260409032710.2092791-1-ashutoshdesai993@gmail.com> (raw)
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
next reply other threads:[~2026-04-09 3:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 3:27 Ashutosh Desai [this message]
2026-04-13 18:34 ` Andrei Vagin
2026-04-14 0:22 ` Ashutosh Desai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260409032710.2092791-1-ashutoshdesai993@gmail.com \
--to=ashutoshdesai993@gmail.com \
--cc=anna-maria@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®