Linux Kernel Set to Remove Obscure 31-Year-Old ELF Header Limitation in Version 6.17
The Linux kernel may soon see the removal of one of its oldest and most enigmatic limitations, a constraint that has persisted since 1993. A developer from Alibaba discovered that a script generating an assembly file results in the creation of an ELF binary that fails to execute on ARM64 systems running a kernel with the standard 4 KB page size. Interestingly, the same binary executes flawlessly when the kernel is configured with a 64 KB page size.
The root cause lies in an archaic check embedded within the ELF loading code. The kernel enforces a condition that blocks execution if a certain ratio between the ELF file’s minimum alignment and the system’s page size is exceeded. For 4 KB pages, this effectively caps the number of program headers at 74—while the test binary contains 78. When using 64 KB pages, the permissible number of headers rises into the thousands, allowing the binary to execute without issue.
An engineer from Alibaba noted that simply removing this check enables the binary to function correctly even with 4 KB pages. However, the purpose of this check remained a mystery. Linux veteran Kees Cook stepped in and traced the condition back to version 0.99.15f of the Linux kernel, dated 1993. Remarkably, no documentation from that era explains why the check was introduced—it was added without comment and persisted in the codebase for three decades.
Since the ELF specification imposes no restriction on the number of program headers, a proposal has been made to eliminate this now-obsolete check. The existing 64 KB cap on the size of ELF headers remains in place and is deemed more than sufficient.
A patch has already been submitted for review as part of the execve
subsystem updates for the upcoming Linux 6.17 release. Barring any objections from Linus Torvalds, the change is expected to be merged soon. The merge window for version 6.17 is anticipated to open this coming Monday, provided version 6.16 is released as scheduled on Sunday.