]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rseq: Don't advertise time slice extensions if disabled
authorThomas Gleixner <tglx@kernel.org>
Tue, 28 Apr 2026 07:34:45 +0000 (09:34 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 1 May 2026 19:32:20 +0000 (21:32 +0200)
If time slice extensions have been disabled on the kernel command line,
then advertising them in RSEQ flags is wrong.

Adjust the conditionals to reflect reality, fixup the misleading comments
about the gap of these flags and the rseq::flags field.

Fixes: d6200245c75e ("rseq: Allow registering RSEQ with slice extension")
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Link: https://patch.msgid.link/20260428224427.437059375%40kernel.org
Cc: stable@vger.kernel.org
include/uapi/linux/rseq.h
kernel/rseq.c

index f69344fe6c0863252b9eebf06dd0b7dc88cdfafa..ca6fe1f9d05e7ee50f58629b8a9062f988908d84 100644 (file)
@@ -28,7 +28,7 @@ enum rseq_cs_flags_bit {
        RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT  = 0,
        RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT   = 1,
        RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT  = 2,
-       /* (3) Intentional gap to put new bits into a separate byte */
+       /* (3) Intentional gap to keep new bits separate */
 
        /* User read only feature flags */
        RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE_BIT    = 4,
@@ -161,6 +161,9 @@ struct rseq {
         *      - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT
         *      - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL
         *      - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE
+        *
+        * It is now used for feature status advertisement by the kernel.
+        * See: enum rseq_cs_flags_bit for further information.
         */
        __u32 flags;
 
index b9f11931ef785256c2b86e80fb1ae3a71769a89c..586f58f652c6e7b1ed0cf654170d75761c061b69 100644 (file)
@@ -462,10 +462,11 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, int, flags, u32
                return -EFAULT;
 
        if (IS_ENABLED(CONFIG_RSEQ_SLICE_EXTENSION)) {
-               rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE;
-               if (rseq_slice_extension_enabled() &&
-                   (flags & RSEQ_FLAG_SLICE_EXT_DEFAULT_ON))
-                       rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
+               if (rseq_slice_extension_enabled()) {
+                       rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE;
+                       if (flags & RSEQ_FLAG_SLICE_EXT_DEFAULT_ON)
+                               rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
+               }
        }
 
        scoped_user_write_access(rseq, efault) {