summaryrefslogtreecommitdiff
path: root/target
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2023-09-06 13:46:57 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2023-09-06 13:46:57 +0200
commit8dd54349bf5ffd4f94ea738ef0059802c046ed7b (patch)
treea05c7f4c147d24458d742fb56d82223eff4c1327 /target
parent9b99fa1ce137523da25aabc309725d58039f0822 (diff)
linux: update arm noMMU patches for FDPIC
Diffstat (limited to 'target')
-rw-r--r--target/linux/patches/6.1.49/armnommu-fix-elf-fdpic-personality.patch39
-rw-r--r--target/linux/patches/6.4.12/armnommu-fix-elf-fdpic-personality.patch39
2 files changed, 48 insertions, 30 deletions
diff --git a/target/linux/patches/6.1.49/armnommu-fix-elf-fdpic-personality.patch b/target/linux/patches/6.1.49/armnommu-fix-elf-fdpic-personality.patch
index c7037f4f8..78b1a10ff 100644
--- a/target/linux/patches/6.1.49/armnommu-fix-elf-fdpic-personality.patch
+++ b/target/linux/patches/6.1.49/armnommu-fix-elf-fdpic-personality.patch
@@ -1,42 +1,51 @@
From ab7647c2b04501297c50ce7cdb6f6895b9582d22 Mon Sep 17 00:00:00 2001
From: Greg Ungerer <gerg@kernel.org>
Date: Fri, 21 Apr 2023 00:21:38 +1000
-Subject: [PATCH] fs: binfmt_elf_efpic: fix personality for non-fdpic ELF
+Subject: [PATCH] fs: binfmt_elf_efpic: fix personality for fdpic ELF
The elf-fdpic loader hard sets the process personality to either
PER_LINUX_FDPIC for true elf-fdpic binaries or to PER_LINUX for
normal ELF binaries (in this case they would be constant displacement
compiled with -pie for example). The problem with that is that it
will lose any other bits that may be in the ELF header personality
-("the "bug emulation" bits).
+(such as the "bug emulation" bits).
On the ARM architecture the ADDR_LIMIT_32BIT flag is used to signify
a normal 32bit binary - as opposed to a legacy 26bit address binary.
This matters since start_thread() will set the ARM CPSR register as
-required based on this flag. If the elf-fdpic loader has lost this
-bit the process will be mis-configured and crash out pretty quickly.
+required based on this flag. If the elf-fdpic loader loses this bit
+the process will be mis-configured and crash out pretty quickly.
-Modify elf-fdpic loaders personality setting for ELF binaries so that
-it preserves the upper three bytes by using the SET_PERSONALITY macro
-to set it. This macro in the generic case sets PER_LINUX but and
-preserves the upper bytes. Architectures can override this for their
-specific use case, and ARM does exactly this.
+Modify elf-fdpic loaders personality setting binaries so that it
+preserves the upper three bytes by using the SET_PERSONALITY macro
+to set it. This macro in the generic case sets PER_LINUX and preserves
+the upper bytes. Architectures can override this for their specific
+use case, and ARM does exactly this.
+
+The problem shows up quite easily runing under qemu, but not necessarily
+on all types of real ARM hardware. If the underlying ARM processor does
+not support the legacy 26-bit addressing mode then everyting will work
+as expected.
Signed-off-by: Greg Ungerer <gerg@kernel.org>
---
- fs/binfmt_elf_fdpic.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ fs/binfmt_elf_fdpic.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index a05eafcacfb2..f29ae1d96fd7 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
-@@ -348,7 +348,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
+@@ -345,10 +345,9 @@
+ /* there's now no turning back... the old userspace image is dead,
+ * defunct, deceased, etc.
+ */
++ SET_PERSONALITY(exec_params.hdr);
if (elf_check_fdpic(&exec_params.hdr))
- set_personality(PER_LINUX_FDPIC);
- else
+- set_personality(PER_LINUX_FDPIC);
+- else
- set_personality(PER_LINUX);
-+ SET_PERSONALITY(exec_params.hdr);
++ current->personality |= PER_LINUX_FDPIC;
if (elf_read_implies_exec(&exec_params.hdr, executable_stack))
current->personality |= READ_IMPLIES_EXEC;
diff --git a/target/linux/patches/6.4.12/armnommu-fix-elf-fdpic-personality.patch b/target/linux/patches/6.4.12/armnommu-fix-elf-fdpic-personality.patch
index c7037f4f8..78b1a10ff 100644
--- a/target/linux/patches/6.4.12/armnommu-fix-elf-fdpic-personality.patch
+++ b/target/linux/patches/6.4.12/armnommu-fix-elf-fdpic-personality.patch
@@ -1,42 +1,51 @@
From ab7647c2b04501297c50ce7cdb6f6895b9582d22 Mon Sep 17 00:00:00 2001
From: Greg Ungerer <gerg@kernel.org>
Date: Fri, 21 Apr 2023 00:21:38 +1000
-Subject: [PATCH] fs: binfmt_elf_efpic: fix personality for non-fdpic ELF
+Subject: [PATCH] fs: binfmt_elf_efpic: fix personality for fdpic ELF
The elf-fdpic loader hard sets the process personality to either
PER_LINUX_FDPIC for true elf-fdpic binaries or to PER_LINUX for
normal ELF binaries (in this case they would be constant displacement
compiled with -pie for example). The problem with that is that it
will lose any other bits that may be in the ELF header personality
-("the "bug emulation" bits).
+(such as the "bug emulation" bits).
On the ARM architecture the ADDR_LIMIT_32BIT flag is used to signify
a normal 32bit binary - as opposed to a legacy 26bit address binary.
This matters since start_thread() will set the ARM CPSR register as
-required based on this flag. If the elf-fdpic loader has lost this
-bit the process will be mis-configured and crash out pretty quickly.
+required based on this flag. If the elf-fdpic loader loses this bit
+the process will be mis-configured and crash out pretty quickly.
-Modify elf-fdpic loaders personality setting for ELF binaries so that
-it preserves the upper three bytes by using the SET_PERSONALITY macro
-to set it. This macro in the generic case sets PER_LINUX but and
-preserves the upper bytes. Architectures can override this for their
-specific use case, and ARM does exactly this.
+Modify elf-fdpic loaders personality setting binaries so that it
+preserves the upper three bytes by using the SET_PERSONALITY macro
+to set it. This macro in the generic case sets PER_LINUX and preserves
+the upper bytes. Architectures can override this for their specific
+use case, and ARM does exactly this.
+
+The problem shows up quite easily runing under qemu, but not necessarily
+on all types of real ARM hardware. If the underlying ARM processor does
+not support the legacy 26-bit addressing mode then everyting will work
+as expected.
Signed-off-by: Greg Ungerer <gerg@kernel.org>
---
- fs/binfmt_elf_fdpic.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ fs/binfmt_elf_fdpic.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index a05eafcacfb2..f29ae1d96fd7 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
-@@ -348,7 +348,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
+@@ -345,10 +345,9 @@
+ /* there's now no turning back... the old userspace image is dead,
+ * defunct, deceased, etc.
+ */
++ SET_PERSONALITY(exec_params.hdr);
if (elf_check_fdpic(&exec_params.hdr))
- set_personality(PER_LINUX_FDPIC);
- else
+- set_personality(PER_LINUX_FDPIC);
+- else
- set_personality(PER_LINUX);
-+ SET_PERSONALITY(exec_params.hdr);
++ current->personality |= PER_LINUX_FDPIC;
if (elf_read_implies_exec(&exec_params.hdr, executable_stack))
current->personality |= READ_IMPLIES_EXEC;