rseq: Introduce feature size and alignment ELF auxiliary vector entries
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 22 Nov 2022 20:39:04 +0000 (15:39 -0500)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 27 Dec 2022 11:52:10 +0000 (12:52 +0100)
Export the rseq feature size supported by the kernel as well as the
required allocation alignment for the rseq per-thread area to user-space
through ELF auxiliary vector entries.

This is part of the extensible rseq ABI.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20221122203932.231377-3-mathieu.desnoyers@efficios.com
fs/binfmt_elf.c
include/uapi/linux/auxvec.h
include/uapi/linux/rseq.h

index de63572a94044ac954b76b96bd0cc669e45d3075..0ba86f0b147721c06e6e3db713ced3c42fb9dc62 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/cred.h>
 #include <linux/dax.h>
 #include <linux/uaccess.h>
+#include <linux/rseq.h>
 #include <asm/param.h>
 #include <asm/page.h>
 
@@ -288,6 +289,10 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec,
        if (bprm->have_execfd) {
                NEW_AUX_ENT(AT_EXECFD, bprm->execfd);
        }
+#ifdef CONFIG_RSEQ
+       NEW_AUX_ENT(AT_RSEQ_FEATURE_SIZE, offsetof(struct rseq, end));
+       NEW_AUX_ENT(AT_RSEQ_ALIGN, __alignof__(struct rseq));
+#endif
 #undef NEW_AUX_ENT
        /* AT_NULL is zero; clear the rest too */
        memset(elf_info, 0, (char *)mm->saved_auxv +
index c7e502bf5a6fadaed33107127ece5c0e4e5125f1..6991c4b8ab189d25f2cda92661f7da4a8a558a94 100644 (file)
@@ -30,6 +30,8 @@
                                 * differ from AT_PLATFORM. */
 #define AT_RANDOM 25   /* address of 16 random bytes */
 #define AT_HWCAP2 26   /* extension of AT_HWCAP */
+#define AT_RSEQ_FEATURE_SIZE   27      /* rseq supported feature size */
+#define AT_RSEQ_ALIGN          28      /* rseq allocation alignment */
 
 #define AT_EXECFN  31  /* filename of program */
 
index 77ee207623a9bfaeb151c92be753e667d5f1810e..05d3c4cdeb40e6e7544d24f46e2564b20037f4cf 100644 (file)
@@ -130,6 +130,11 @@ struct rseq {
         *     this thread.
         */
        __u32 flags;
+
+       /*
+        * Flexible array member at end of structure, after last feature field.
+        */
+       char end[];
 } __attribute__((aligned(4 * sizeof(__u64))));
 
 #endif /* _UAPI_LINUX_RSEQ_H */