x86/um: nommu: elf loader for fdpic

As UML supports CONFIG_MMU=n case, it has to use an alternate ELF
loader, FDPIC ELF loader.  In this commit, we added necessary
definitions in the arch, as UML has not been used so far.  It also
updates Kconfig file to use BINFMT_ELF_FDPIC under !MMU environment.

Acked-by: Kees Cook <kees@kernel.org>
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Signed-off-by: Ricardo Koller <ricarkol@google.com>
Link: https://patch.msgid.link/20260723113633.08fe0ad5320e.I3faf90e4181f92dc74500a14090b711605573e4e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Hajime Tazaki 2026-07-23 11:35:42 +02:00 committed by Johannes Berg
parent 4099191a67
commit 68885a9445
4 changed files with 18 additions and 3 deletions

View File

@ -21,6 +21,11 @@ typedef struct mm_context {
spinlock_t sync_tlb_lock;
unsigned long sync_tlb_range_from;
unsigned long sync_tlb_range_to;
#ifdef CONFIG_BINFMT_ELF_FDPIC
unsigned long exec_fdpic_loadmap;
unsigned long interp_fdpic_loadmap;
#endif
} mm_context_t;
#define INIT_MM_CONTEXT(mm) \

View File

@ -29,6 +29,12 @@ struct pt_regs {
#define PTRACE_OLDSETOPTIONS 21
#ifdef CONFIG_BINFMT_ELF_FDPIC
#define PTRACE_GETFDPIC 31
#define PTRACE_GETFDPIC_EXEC 0
#define PTRACE_GETFDPIC_INTERP 1
#endif
struct task_struct;
extern long subarch_ptrace(struct task_struct *child, long request,

View File

@ -9,6 +9,7 @@
#include <skas.h>
#define CORE_DUMP_USE_REGSET
#define ELF_FDPIC_CORE_EFLAGS 0
#ifdef CONFIG_X86_32
@ -158,8 +159,11 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
extern unsigned long um_vdso_addr;
#define AT_SYSINFO_EHDR 33
#define ARCH_DLINFO NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr)
#define ARCH_DLINFO \
do { \
NEW_AUX_ENT(AT_SYSINFO_EHDR, um_vdso_addr); \
NEW_AUX_ENT(AT_MINSIGSTKSZ, 0); \
} while (0)
#endif
typedef unsigned long elf_greg_t;

View File

@ -58,7 +58,7 @@ config ARCH_USE_GNU_PROPERTY
config BINFMT_ELF_FDPIC
bool "Kernel support for FDPIC ELF binaries"
default y if !BINFMT_ELF
depends on ARM || ((M68K || RISCV || SUPERH || XTENSA) && !MMU)
depends on ARM || ((M68K || RISCV || SUPERH || UML || XTENSA) && !MMU)
select ELFCORE
help
ELF FDPIC binaries are based on ELF, but allow the individual load