Skip to content

Commit fd75a33

Browse files
jcowgillralfbaechle
authored andcommitted
MIPS: ELF: fix loading o32 binaries on 64-bit kernels
Commit 90cee75 ("MIPS: ELF: Set FP mode according to .MIPS.abiflags") introduced checking of the .MIPS.abiflags ELF section but did so through the native sized "elfhdr" and "elf_phdr" structures regardless whether the ELF was actually 32-bit or 64-bit. This produces wrong results when trying to use a 64-bit kernel to load o32 ELF files. Change the uses of the generic elf structures to their 32-bit versions. Since the code bails out on any 64-bit cases, this is OK until they are implemented. Fixes: 90cee75 ("MIPS: ELF: Set FP mode according to .MIPS.abiflags") Signed-off-by: James Cowgill <James.Cowgill@imgtec.com> Cc: linux-mips@linux-mips.org Cc: Paul Burton <paul.burton@imgtec.com> Reviewed-by: Maciej W. Rozycki <macro@linux-mips.org> Patchwork: https://patchwork.linux-mips.org/patch/8932/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 5008392 commit fd75a33

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/mips/kernel/elf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ enum {
1919
int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,
2020
bool is_interp, struct arch_elf_state *state)
2121
{
22-
struct elfhdr *ehdr = _ehdr;
23-
struct elf_phdr *phdr = _phdr;
22+
struct elf32_hdr *ehdr = _ehdr;
23+
struct elf32_phdr *phdr = _phdr;
2424
struct mips_elf_abiflags_v0 abiflags;
2525
int ret;
2626

@@ -48,7 +48,7 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,
4848
return 0;
4949
}
5050

51-
static inline unsigned get_fp_abi(struct elfhdr *ehdr, int in_abi)
51+
static inline unsigned get_fp_abi(struct elf32_hdr *ehdr, int in_abi)
5252
{
5353
/* If the ABI requirement is provided, simply return that */
5454
if (in_abi != -1)
@@ -65,7 +65,7 @@ static inline unsigned get_fp_abi(struct elfhdr *ehdr, int in_abi)
6565
int arch_check_elf(void *_ehdr, bool has_interpreter,
6666
struct arch_elf_state *state)
6767
{
68-
struct elfhdr *ehdr = _ehdr;
68+
struct elf32_hdr *ehdr = _ehdr;
6969
unsigned fp_abi, interp_fp_abi, abi0, abi1;
7070

7171
/* Ignore non-O32 binaries */

0 commit comments

Comments
 (0)