Skip to content

Commit b833460

Browse files
Thomas Gleixnergregkh
authored andcommitted
rseq: Don't advertise time slice extensions if disabled
commit 010b772 upstream. 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: d620024 ("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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6c180bb commit b833460

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

include/uapi/linux/rseq.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum rseq_cs_flags_bit {
2828
RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT_BIT = 0,
2929
RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL_BIT = 1,
3030
RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE_BIT = 2,
31-
/* (3) Intentional gap to put new bits into a separate byte */
31+
/* (3) Intentional gap to keep new bits separate */
3232

3333
/* User read only feature flags */
3434
RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE_BIT = 4,
@@ -161,6 +161,9 @@ struct rseq {
161161
* - RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT
162162
* - RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL
163163
* - RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE
164+
*
165+
* It is now used for feature status advertisement by the kernel.
166+
* See: enum rseq_cs_flags_bit for further information.
164167
*/
165168
__u32 flags;
166169

kernel/rseq.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,11 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, int, flags, u32
462462
return -EFAULT;
463463

464464
if (IS_ENABLED(CONFIG_RSEQ_SLICE_EXTENSION)) {
465-
rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE;
466-
if (rseq_slice_extension_enabled() &&
467-
(flags & RSEQ_FLAG_SLICE_EXT_DEFAULT_ON))
468-
rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
465+
if (rseq_slice_extension_enabled()) {
466+
rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_AVAILABLE;
467+
if (flags & RSEQ_FLAG_SLICE_EXT_DEFAULT_ON)
468+
rseqfl |= RSEQ_CS_FLAG_SLICE_EXT_ENABLED;
469+
}
469470
}
470471

471472
scoped_user_write_access(rseq, efault) {

0 commit comments

Comments
 (0)