glibc/sysdeps
H.J. Lu 0f9afc265a x32: Handle displacement overflow in PLT rewrite [BZ #31218]
PLT rewrite calculated displacement with

ElfW(Addr) disp = value - branch_start - JMP32_INSN_SIZE;

On x32, displacement from 0xf7fbe060 to 0x401030 was calculated as

unsigned int disp = 0x401030 - 0xf7fbe060 - 5;

with disp == 0x8442fcb and caused displacement overflow. The PLT entry
was changed to:

0xf7fbe060 <+0>:	e9 cb 2f 44 08     	jmp    0x401030
0xf7fbe065 <+5>:	cc                 	int3
0xf7fbe066 <+6>:	cc                 	int3
0xf7fbe067 <+7>:	cc                 	int3
0xf7fbe068 <+8>:	cc                 	int3
0xf7fbe069 <+9>:	cc                 	int3
0xf7fbe06a <+10>:	cc                 	int3
0xf7fbe06b <+11>:	cc                 	int3
0xf7fbe06c <+12>:	cc                 	int3
0xf7fbe06d <+13>:	cc                 	int3
0xf7fbe06e <+14>:	cc                 	int3
0xf7fbe06f <+15>:	cc                 	int3

x32 has 32-bit address range, but it doesn't wrap address around at 4GB,
JMP target was changed to 0x100401030 (0xf7fbe060LL + 0x8442fcbLL + 5),
which is above 4GB.

Always use uint64_t to calculate displacement.  This fixes BZ #31218.
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2024-01-06 14:25:49 -08:00
..
aarch64 aarch64: Make cpu-features definitions not Linux-specific 2024-01-04 23:48:54 +01:00
alpha Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
arc Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
arm Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
csky Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
generic Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
gnu Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
hppa Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
htl Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
hurd Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
i386 i386: Ignore --enable-cet 2024-01-04 06:08:55 -08:00
ia64 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
ieee754 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
loongarch Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
m68k Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
mach hurd: Initializy _dl_pagesize early in static builds 2024-01-04 23:48:36 +01:00
microblaze Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
mips Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
nios2 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
nptl Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
or1k Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
posix Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
powerpc Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
pthread Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
riscv Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
s390 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sh Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
sparc Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
unix x86: Fixup some nits in longjmp asm implementation 2024-01-05 18:00:38 -08:00
wordsize-32 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
wordsize-64 Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
x86 elf: Add ELF_DYNAMIC_AFTER_RELOC to rewrite PLT 2024-01-05 05:49:49 -08:00
x86_64 x32: Handle displacement overflow in PLT rewrite [BZ #31218] 2024-01-06 14:25:49 -08:00