Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rseq: Introduce feature size and alignment ELF auxiliary vector entries

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

authored by

Mathieu Desnoyers and committed by
Peter Zijlstra
317c8194 4842dadf

+12
+5
fs/binfmt_elf.c
··· 46 46 #include <linux/cred.h> 47 47 #include <linux/dax.h> 48 48 #include <linux/uaccess.h> 49 + #include <linux/rseq.h> 49 50 #include <asm/param.h> 50 51 #include <asm/page.h> 51 52 ··· 289 288 if (bprm->have_execfd) { 290 289 NEW_AUX_ENT(AT_EXECFD, bprm->execfd); 291 290 } 291 + #ifdef CONFIG_RSEQ 292 + NEW_AUX_ENT(AT_RSEQ_FEATURE_SIZE, offsetof(struct rseq, end)); 293 + NEW_AUX_ENT(AT_RSEQ_ALIGN, __alignof__(struct rseq)); 294 + #endif 292 295 #undef NEW_AUX_ENT 293 296 /* AT_NULL is zero; clear the rest too */ 294 297 memset(elf_info, 0, (char *)mm->saved_auxv +
+2
include/uapi/linux/auxvec.h
··· 30 30 * differ from AT_PLATFORM. */ 31 31 #define AT_RANDOM 25 /* address of 16 random bytes */ 32 32 #define AT_HWCAP2 26 /* extension of AT_HWCAP */ 33 + #define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size */ 34 + #define AT_RSEQ_ALIGN 28 /* rseq allocation alignment */ 33 35 34 36 #define AT_EXECFN 31 /* filename of program */ 35 37
+5
include/uapi/linux/rseq.h
··· 130 130 * this thread. 131 131 */ 132 132 __u32 flags; 133 + 134 + /* 135 + * Flexible array member at end of structure, after last feature field. 136 + */ 137 + char end[]; 133 138 } __attribute__((aligned(4 * sizeof(__u64)))); 134 139 135 140 #endif /* _UAPI_LINUX_RSEQ_H */