hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/x86/include/asm/elf.h
....@@ -10,6 +10,7 @@
1010 #include <asm/ptrace.h>
1111 #include <asm/user.h>
1212 #include <asm/auxvec.h>
13
+#include <asm/fsgsbase.h>
1314
1415 typedef unsigned long elf_greg_t;
1516
....@@ -19,8 +20,6 @@
1920 typedef struct user_i387_struct elf_fpregset_t;
2021
2122 #ifdef __i386__
22
-
23
-typedef struct user_fxsr_struct elf_fpxregset_t;
2423
2524 #define R_386_NONE 0
2625 #define R_386_32 1
....@@ -62,8 +61,7 @@
6261 #define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
6362 #define R_X86_64_8 14 /* Direct 8 bit sign extended */
6463 #define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
65
-
66
-#define R_X86_64_NUM 16
64
+#define R_X86_64_PC64 24 /* Place relative 64-bit signed */
6765
6866 /*
6967 * These are used to set parameters in the core dumps.
....@@ -205,7 +203,6 @@
205203
206204 #define ELF_CORE_COPY_REGS(pr_reg, regs) \
207205 do { \
208
- unsigned long base; \
209206 unsigned v; \
210207 (pr_reg)[0] = (regs)->r15; \
211208 (pr_reg)[1] = (regs)->r14; \
....@@ -228,8 +225,8 @@
228225 (pr_reg)[18] = (regs)->flags; \
229226 (pr_reg)[19] = (regs)->sp; \
230227 (pr_reg)[20] = (regs)->ss; \
231
- rdmsrl(MSR_FS_BASE, base); (pr_reg)[21] = base; \
232
- rdmsrl(MSR_KERNEL_GS_BASE, base); (pr_reg)[22] = base; \
228
+ (pr_reg)[21] = x86_fsbase_read_cpu(); \
229
+ (pr_reg)[22] = x86_gsbase_read_cpu_inactive(); \
233230 asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v; \
234231 asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \
235232 asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \
....@@ -282,9 +279,29 @@
282279 /*
283280 * An executable for which elf_read_implies_exec() returns TRUE will
284281 * have the READ_IMPLIES_EXEC personality flag set automatically.
282
+ *
283
+ * The decision process for determining the results are:
284
+ *
285
+ *              CPU: | lacks NX*  | has NX, ia32     | has NX, x86_64 |
286
+ * ELF:              |            |                  |                |
287
+ * ---------------------|------------|------------------|----------------|
288
+ * missing PT_GNU_STACK | exec-all   | exec-all         | exec-none      |
289
+ * PT_GNU_STACK == RWX  | exec-stack | exec-stack       | exec-stack     |
290
+ * PT_GNU_STACK == RW   | exec-none  | exec-none        | exec-none      |
291
+ *
292
+ * exec-all : all PROT_READ user mappings are executable, except when
293
+ * backed by files on a noexec-filesystem.
294
+ * exec-none : only PROT_EXEC user mappings are executable.
295
+ * exec-stack: only the stack and PROT_EXEC user mappings are executable.
296
+ *
297
+ * *this column has no architectural effect: NX markings are ignored by
298
+ * hardware, but may have behavioral effects when "wants X" collides with
299
+ * "cannot be X" constraints in memory permission flags, as in
300
+ * https://lkml.kernel.org/r/20190418055759.GA3155@mellanox.com
301
+ *
285302 */
286303 #define elf_read_implies_exec(ex, executable_stack) \
287
- (executable_stack != EXSTACK_DISABLE_X)
304
+ (mmap_is_ia32() && executable_stack == EXSTACK_DEFAULT)
288305
289306 struct task_struct;
290307