* [PATCH v1 0/2] Last minute rseq fixes for 7.0
@ 2026-02-18 16:52 Mathieu Desnoyers
2026-02-18 16:52 ` [PATCH v1 1/2] rseq: Clarify rseq registration rseq_size bound check comment Mathieu Desnoyers
2026-02-18 16:52 ` [PATCH v1 2/2] rseq: slice ext: Ensure rseq feature size differs from original rseq size Mathieu Desnoyers
0 siblings, 2 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2026-02-18 16:52 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, Mathieu Desnoyers, Ingo Molnar, Thomas Gleixner,
Carlos O'Donell, Florian Weimer, Michael Jeanson
Hi,
Here are two last minute rseq fixes aiming at 7.0.
The first is a clarification of a rseq registration comment to match the
rseq_size range checks.
The second ensures that the new scheduler slice extension field don't
end up exposing a rseq feature size equal to the original rseq size,
which would make life harder than it needs to be for userspace.
Thanks,
Mathieu
CC: Peter Zijlstra (Intel) <peterz@infradead.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Thomas Gleixner <tglx@kernel.org>
CC: Carlos O'Donell <carlos@redhat.com>
CC: Florian Weimer <fweimer@redhat.com>
CC: Michael Jeanson <mjeanson@efficios.com>
Mathieu Desnoyers (2):
rseq: Clarify rseq registration rseq_size bound check comment
rseq: slice ext: Ensure rseq feature size differs from original rseq
size
include/uapi/linux/rseq.h | 13 ++++++++++++-
kernel/rseq.c | 5 +++--
2 files changed, 15 insertions(+), 3 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 1/2] rseq: Clarify rseq registration rseq_size bound check comment
2026-02-18 16:52 [PATCH v1 0/2] Last minute rseq fixes for 7.0 Mathieu Desnoyers
@ 2026-02-18 16:52 ` Mathieu Desnoyers
2026-02-18 16:52 ` [PATCH v1 2/2] rseq: slice ext: Ensure rseq feature size differs from original rseq size Mathieu Desnoyers
1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2026-02-18 16:52 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, Mathieu Desnoyers, Ingo Molnar, Thomas Gleixner,
Carlos O'Donell, Florian Weimer, Michael Jeanson
The rseq registration validates that the rseq_size argument is greater
or equal to 32 (the original rseq size), but the comment associated with
this check does not clearly state this.
Clarify the comment to that effect.
Fixes: ee3e3ac05c26 ("rseq: Introduce extensible rseq ABI")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Peter Zijlstra (Intel) <peterz@infradead.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Thomas Gleixner <tglx@kernel.org>
---
kernel/rseq.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/rseq.c b/kernel/rseq.c
index b0973d19f366..e349f86cc945 100644
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -449,8 +449,9 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, int, flags, u32
* auxiliary vector AT_RSEQ_ALIGN. If rseq_len is the original rseq
* size, the required alignment is the original struct rseq alignment.
*
- * In order to be valid, rseq_len is either the original rseq size, or
- * large enough to contain all supported fields, as communicated to
+ * The rseq_len is required to be greater or equal to the original rseq
+ * size. In order to be valid, rseq_len is either the original rseq size,
+ * or large enough to contain all supported fields, as communicated to
* user-space through the ELF auxiliary vector AT_RSEQ_FEATURE_SIZE.
*/
if (rseq_len < ORIG_RSEQ_SIZE ||
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] rseq: slice ext: Ensure rseq feature size differs from original rseq size
2026-02-18 16:52 [PATCH v1 0/2] Last minute rseq fixes for 7.0 Mathieu Desnoyers
2026-02-18 16:52 ` [PATCH v1 1/2] rseq: Clarify rseq registration rseq_size bound check comment Mathieu Desnoyers
@ 2026-02-18 16:52 ` Mathieu Desnoyers
2026-02-18 19:01 ` Mathieu Desnoyers
1 sibling, 1 reply; 4+ messages in thread
From: Mathieu Desnoyers @ 2026-02-18 16:52 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, Mathieu Desnoyers, Ingo Molnar, Thomas Gleixner,
Carlos O'Donell, Florian Weimer, Michael Jeanson
Before rseq became extensible, its original size was 32 bytes even
though the active rseq area was only 20 bytes. This had the following
impact in terms of userspace ecosystem evolution:
* The GNU libc between 2.35 and 2.39 expose a __rseq_size symbol set
to 32, even though the size of the active rseq area is really 20.
* The GNU libc 2.40 changes this __rseq_size to 20, thus making it
express the active rseq area.
* Starting from glibc 2.41, __rseq_size corresponds to the
AT_RSEQ_FEATURE_SIZE from getauxval(3).
This means that users of __rseq_size can always expect it to
correspond to the active rseq area, except for the value 32, for
which the active rseq area is 20 bytes.
Exposing a 32 bytes feature size would make life needlessly painful
for userspace. Therefore, add a reserved field at the end of the
rseq area to bump the feature size to 33 bytes. This reserved field
is expected to be replaced with whatever field will come next,
expecting that this field will be larger than 1 byte.
The effect of this change is to increase the size and alignment of
the rseq area from 32 to 64 bytes before we actually have fields using
that memory.
This will minimize the amount of ABI corner-cases we need to document
and require userspace to play games with. The rule stays simple when
__rseq_size != 32:
#define rseq_field_available(field) (__rseq_size >= offsetofend(struct rseq_abi, field))
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Peter Zijlstra (Intel) <peterz@infradead.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Thomas Gleixner <tglx@kernel.org>
CC: Carlos O'Donell <carlos@redhat.com>
CC: Florian Weimer <fweimer@redhat.com>
CC: Michael Jeanson <mjeanson@efficios.com>
---
include/uapi/linux/rseq.h | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h
index 863c4a00a66b..281edb85a5f5 100644
--- a/include/uapi/linux/rseq.h
+++ b/include/uapi/linux/rseq.h
@@ -180,10 +180,21 @@ struct rseq {
*/
struct rseq_slice_ctrl slice_ctrl;
+ /*
+ * Before rseq became extensible, its original size was 32 bytes even
+ * though the active rseq area was only 20 bytes.
+ * Exposing a 32 bytes feature size would make life needlessly painful
+ * for userspace. Therefore, add a reserved byte after byte 32
+ * to bump the rseq feature size from 32 to 33.
+ * The next field to be added to the rseq area will be larger
+ * than one byte, and will replace this reserved byte.
+ */
+ __u8 __reserved;
+
/*
* Flexible array member at end of structure, after last feature field.
*/
char end[];
-} __attribute__((aligned(4 * sizeof(__u64))));
+} __attribute__((aligned(8 * sizeof(__u64))));
#endif /* _UAPI_LINUX_RSEQ_H */
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 2/2] rseq: slice ext: Ensure rseq feature size differs from original rseq size
2026-02-18 16:52 ` [PATCH v1 2/2] rseq: slice ext: Ensure rseq feature size differs from original rseq size Mathieu Desnoyers
@ 2026-02-18 19:01 ` Mathieu Desnoyers
0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2026-02-18 19:01 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, Ingo Molnar, Thomas Gleixner, Carlos O'Donell,
Florian Weimer, Michael Jeanson
On 2026-02-18 11:52, Mathieu Desnoyers wrote:
[...]
>
> The effect of this change is to increase the size and alignment of
> the rseq area from 32 to 64 bytes before we actually have fields using
> that memory.
>
[...]
> -} __attribute__((aligned(4 * sizeof(__u64))));
> +} __attribute__((aligned(8 * sizeof(__u64))));
Actually bumping the alignment from 32 to 64 is not correct here,
because the kernel still has to deal with legacy userspace which
align struct rseq on 32 bytes only.
What I can do instead is change the value returned by
getauxval(AT_RSEQ_ALIGN) from 32 to 64, thus requesting
that newer userspace align its allocation on 64-byte.
I'll prepare an updated patch series.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-18 19:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-18 16:52 [PATCH v1 0/2] Last minute rseq fixes for 7.0 Mathieu Desnoyers
2026-02-18 16:52 ` [PATCH v1 1/2] rseq: Clarify rseq registration rseq_size bound check comment Mathieu Desnoyers
2026-02-18 16:52 ` [PATCH v1 2/2] rseq: slice ext: Ensure rseq feature size differs from original rseq size Mathieu Desnoyers
2026-02-18 19:01 ` Mathieu Desnoyers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome