Bug 215734

Summary: shared object loaded very low in memory ARM 32bit with kernel 5.17.0
Product: Platform Specific/Hardware Reporter: Jan Palus (jpalus)
Component: ARMAssignee: linux-arm-kernel (linux-arm-kernel)
Status: NEW ---    
Severity: normal CC: hjl.tools
Priority: P1    
Hardware: ARM   
OS: Linux   
Kernel Version: 5.17.0 Subsystem:
Regression: No Bisected commit-id:

Description Jan Palus 2022-03-24 10:17:02 UTC
This is a followup to https://sourceware.org/bugzilla/show_bug.cgi?id=28990 where ld.so --verify segfault was reported on binaries > 4MB.

It appears that starting with kernel 5.17.0 shared object is loaded in the begging of address space at least on 32-bit ARM:

/proc/<pid>/maps just before mmap (5.17):
00400000-00429000 r-xp 00000000 b3:02 393320     /lib/ld-linux-armhf.so.3
00439000-0043c000 rw-p 00029000 b3:02 393320     /lib/ld-linux-armhf.so.3
76ffd000-76ffe000 r-xp 00000000 00:00 0          [sigpage]
76ffe000-76fff000 r--p 00000000 00:00 0          [vvar]
76fff000-77000000 r-xp 00000000 00:00 0          [vdso]
7efdf000-7f000000 rw-p 00000000 00:00 0          [stack]
ffff0000-ffff1000 r-xp 00000000 00:00 0          [vectors]

causing segfaults when mmaping large binaries at fixed address 0x10000 (ie done by ld.so --verify used by ldd).

By comparison it is not the case for kernel 5.16.8:

/proc/<pid>/maps just before mmap (5.16):
76fc4000-76fed000 r-xp 00000000 b3:02 393320     /lib/ld-linux-armhf.so.3
76ffa000-76ffb000 r-xp 00000000 00:00 0          [sigpage]
76ffb000-76ffc000 r--p 00000000 00:00 0          [vvar]
76ffc000-76ffd000 r-xp 00000000 00:00 0          [vdso]
76ffd000-77000000 rw-p 00029000 b3:02 393320     /lib/ld-linux-armhf.so.3
7efdf000-7f000000 rw-p 00000000 00:00 0          [stack]
ffff0000-ffff1000 r-xp 00000000 00:00 0          [vectors]
Comment 1 Jan Palus 2022-03-29 22:14:12 UTC
First bad commit appears to be:

From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 19 Jan 2022 18:09:40 -0800
Subject: fs/binfmt_elf: use PT_LOAD p_align values for static PIE

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9630f0d60fec5fbcaa4435a66f75df1dc9704b66
Comment 2 Jan Palus 2022-04-12 16:45:41 UTC
ping