From 1c52662da875d102a79fe016038434be7b6bd82b Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 18 Apr 2024 17:39:30 +0200 Subject: linux: update to 6.6.28 --- .../6.6.28/armnommu-fix-thread-registers.patch | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 target/linux/patches/6.6.28/armnommu-fix-thread-registers.patch (limited to 'target/linux/patches/6.6.28/armnommu-fix-thread-registers.patch') diff --git a/target/linux/patches/6.6.28/armnommu-fix-thread-registers.patch b/target/linux/patches/6.6.28/armnommu-fix-thread-registers.patch new file mode 100644 index 000000000..8ab2196dc --- /dev/null +++ b/target/linux/patches/6.6.28/armnommu-fix-thread-registers.patch @@ -0,0 +1,57 @@ +From 1410ebe685f13c1699a16bf147ae1332e7fd1983 Mon Sep 17 00:00:00 2001 +From: Greg Ungerer +Date: Thu, 20 Apr 2023 09:52:08 +1000 +Subject: [PATCH] ARM: start_thread: restore registers on ELF load for noMMU + +The binfmt_elf-fdpic loader is capable of loading constant displacement +ELF format binaries (like those compiled -pie) on noMMU systems as well +as elf-fdpic format binaries. The traditional ELF loader cannot be +enabled on noMMU systems. + +Commit 5e588114329c ("ARM: start_thread(): don't always clear all regs") +fixed the start_thread() code so that it maintains the required +elf-fdpic registers through to the new process, but it only does that if +current has its personality FDPIC_FUNCPTRS bit set. That is true for +elf-fdpic format binaries but will not be true for non-fdpic ELF +binaries. + +Modify the test of the FDPIC_FUNCPTRS personality bit to also carry out +the register restore if this is a noMMU system. This is not perfect, +since it will also preserve these registers on noMMU systems for all +binary format types (could be flat format for example). That won't break +anything, but it is potentially leaking some information into the new +process. But for the noMMU case we need those start time registers set to +be able to finalize the runtime loading of the -pie style ELF binary +(carry out its segment and dynamic relocation processing). + +Unfortunately the FDPIC_FUNCPTRS flag cannot just be enabled for all +elf-fdpic loaded binaries. That personality bit is used for other things +like the controlling the changed behavior for signal handling. + +There is no change in behavior for normal ELF loading on MMU systems. +A -pie style ELF binary built for noMMU systems can be load and run using +the usual ELF loader on an MMU system (elf-fdpic loader not required in +this case). + +Signed-off-by: Greg Ungerer +--- + arch/arm/include/asm/processor.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h +index 326864f79d18..5074cc3ae4e1 100644 +--- a/arch/arm/include/asm/processor.h ++++ b/arch/arm/include/asm/processor.h +@@ -60,7 +60,8 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset, + } \ + memset(regs->uregs, 0, sizeof(regs->uregs)); \ + if (IS_ENABLED(CONFIG_BINFMT_ELF_FDPIC) && \ +- current->personality & FDPIC_FUNCPTRS) { \ ++ ((! IS_ENABLED(CONFIG_MMU)) || \ ++ current->personality & FDPIC_FUNCPTRS)) { \ + regs->ARM_r7 = r7; \ + regs->ARM_r8 = r8; \ + regs->ARM_r9 = r9; \ +-- +2.25.1 + -- cgit v1.2.3