--- zzzz-none-000/linux-3.10.107/arch/mips/include/asm/elf.h 2017-06-27 09:49:32.000000000 +0000 +++ vr9-7490-729/linux-3.10.107/arch/mips/include/asm/elf.h 2021-11-10 11:53:53.000000000 +0000 @@ -36,6 +36,7 @@ #define EF_MIPS_ABI2 0x00000020 #define EF_MIPS_OPTIONS_FIRST 0x00000080 #define EF_MIPS_32BITMODE 0x00000100 +#define EF_MIPS_32BITMODE_FP64 0x00000200 #define EF_MIPS_ABI 0x0000f000 #define EF_MIPS_ARCH 0xf0000000 @@ -228,6 +229,32 @@ #endif /* CONFIG_64BIT */ /* + * Ensure we don't load the incompatible architecture lib via uselib() - + * - verify FPU model. + */ +#define elf_lib_check_arch(hdr) \ +({ \ + int __res = 1; \ + struct elfhdr *__h = (hdr); \ + \ + if (test_thread_flag(TIF_32BIT_REGS)) { \ + if ((__h->e_flags & EF_MIPS_ABI2) != 0) \ + __res = 0; \ + if (((__h->e_flags & EF_MIPS_ABI) != 0) && \ + ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32)) \ + __res = 0; \ + if (__h->e_flags & EF_MIPS_32BITMODE_FP64) \ + __res = 0; \ + } else { \ + if (((__h->e_flags & EF_MIPS_ABI) == 0) || \ + ((__h->e_flags & EF_MIPS_ABI) == EF_MIPS_ABI_O32)) \ + if (!(__h->e_flags & EF_MIPS_32BITMODE_FP64)) \ + __res = 0; \ + } \ + __res; \ +}) + +/* * These are used to set parameters in the core dumps. */ #ifdef __MIPSEB__ @@ -249,6 +276,11 @@ #define SET_PERSONALITY(ex) \ do { \ + if ((ex).e_flags & EF_MIPS_32BITMODE_FP64) \ + clear_thread_flag(TIF_32BIT_REGS); \ + else \ + set_thread_flag(TIF_32BIT_REGS); \ + \ if (personality(current->personality) != PER_LINUX) \ set_personality(PER_LINUX); \ \ @@ -262,6 +294,7 @@ #ifdef CONFIG_MIPS32_N32 #define __SET_PERSONALITY32_N32() \ do { \ + clear_thread_flag(TIF_32BIT_REGS); \ set_thread_flag(TIF_32BIT_ADDR); \ current->thread.abi = &mips_abi_n32; \ } while (0) @@ -271,14 +304,18 @@ #endif #ifdef CONFIG_MIPS32_O32 -#define __SET_PERSONALITY32_O32() \ +#define __SET_PERSONALITY32_O32(ex) \ do { \ - set_thread_flag(TIF_32BIT_REGS); \ + if ((ex).e_flags & EF_MIPS_32BITMODE_FP64) \ + clear_thread_flag(TIF_32BIT_REGS); \ + else \ + set_thread_flag(TIF_32BIT_REGS); \ + \ set_thread_flag(TIF_32BIT_ADDR); \ current->thread.abi = &mips_abi_32; \ } while (0) #else -#define __SET_PERSONALITY32_O32() \ +#define __SET_PERSONALITY32_O32(ex) \ do { } while (0) #endif @@ -289,7 +326,7 @@ ((ex).e_flags & EF_MIPS_ABI) == 0) \ __SET_PERSONALITY32_N32(); \ else \ - __SET_PERSONALITY32_O32(); \ + __SET_PERSONALITY32_O32(ex); \ } while (0) #else #define __SET_PERSONALITY32(ex) do { } while (0)