#1016718 binfmt_elf: May fail to load executable with no static data next to BSS

Package:
src:linux
Source:
src:linux
Submitter:
Ben Hutchings
Date:
2025-09-18 00:23:01 UTC
Severity:
normal
Tags:
#1016718#5
Date:
2022-08-05 23:11:55 UTC
From:
To:
I'm doing some test builds of klibc
<https://git.kernel.org/pub/scm/libs/klibc/klibc.git> and found a
regression for arm64.  What changed is binutils, and I've reported
bug #1016717 there, but it seems to be triggering an existing bug in
the kernel.

Loading some of klibc's test programs (getoptlong.shared,
malloctest2.shared, setjmptest.shared, sigint.shared) fails, with
execve() returning EFAULT.  This happens past the point of no return,
so the kernel kills the process with SIGSEGV.

The reason for this seems to be that:

1. All of these programs have a BSS section but not a data section.
2. The BSS section is not page-aligned (it now starts at 0xffe8).
3. binfmt_elf assumes that a non-page-aligned BSS section is placed
   immediately after a writable data section in memory, and tries to
   clear memory from the start of the BSS section up to the page
   boundary.
4. In this case, there is no data section and no file mapping before
   the BSS, so this results in an EFAULT.  This happens past the point
   of no return, so the kernel kills the process.

With older versions of binutils, the BSS section was still misaligned
on arm64 but started within the same 4K page as another section.

binfmt_elf should check whether it created a mapping before a non-
aligned BSS section; if not then it should round down the start of the
zero mapping instead of trying to clear part of a mapping that's not
there.

Ben.

#1016718#10
Date:
2025-05-01 15:12:16 UTC
From:
To:
Hi Ben,

Is this still an issue?

Regards,
Salvatore

#1016718#21
Date:
2025-07-12 15:55:35 UTC
From:
To:
On Thu, 1 May 2025 17:12:16 +0200 Salvatore Bonaccorso <carnil@debian.org> wrote:
[...]
negative.

This appears to have been fixed by:

commit 585a018627b4d7ed37387211f667916840b5c5ea
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Thu Sep 28 20:24:29 2023 -0700

    binfmt_elf: Support segments with 0 filesz and misaligned starts

which went into 6.7 and was backported to 6.1.140.

To check this, I:

- Reverted the workaround in klibc
- Built the test programs on arm64
- Ran the affected test programs on amdahl (which is running 6.1.140-1)

Ben.

#1016718#28
Date:
2025-09-18 00:21:23 UTC
From:
To:
*你好!*

家人们,存钱这事儿看起来简单,实则暗藏玄机。

银行表面上笑脸相迎,其实最怕咱掌握这3招存钱法,用了这些方法,利息能多拿不少,要是还不知道,那可就亏大了!

以下是文章的主要内容:

https://simpleurl.link/zhe-3-zhao-cun-qian

感谢你阅读这篇文章!
--- 追寻真相,是对良知最好的尊重