Skip to content

binfmt_elf: seal address zero

[email protected] linux-hardening linux-mm lkml 2 versions – Applied

Status from this message: Applied to for-next/execve, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest1 patch 5 repliesApplied
  2. v1 RFC1 patch 4 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/1binfmt_elf: mseal address zerofs/binfmt_elf.c include/linux/mm.h mm/mseal.c+16 -12 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/1] binfmt_elf: seal address zero

From: Jeff Xu <[email protected]>

In load_elf_binary as part of the execve(), when the current task’s personality has MMAP_PAGE_ZERO set, the kernel allocates one page at address 0. According to the comment:

/* Why this, you ask??? Well SVr4 maps page 0 as read-only,
and some applications "depend" upon this behavior. Since we do not have the power to recompile these, we
emulate the SVr4 behavior. Sigh. */

At one point, Linus suggested removing this [1].

Code search in debian didn't see much use of MMAP_PAGE_ZERO [2], it exists in util and test (rr).

Sealing this is probably safe, the comment doesn’t say the app ever wanting to change the mapping to rwx. Sealing also ensures that never happens.

[1] https://lore.kernel.org/lkml/CAHk-=whVa=nm_GW=NVfPHqcxDbWt4JjjK1YWb0cLjO4ZSGyiDA@mail.gmail.com/
[2] https://codesearch.debian.net/search?q=MMAP_PAGE_ZERO&literal=1&perpkg=1&page=1

Jeff Xu (1):
binfmt_elf: mseal address zero

 fs/binfmt_elf.c    |  5 +++++
 include/linux/mm.h | 10 ++++++++++
 mm/mseal.c         |  2 +-
 3 files changed, 16 insertions(+), 1 deletion(-)
Signature · 1 line
2.46.0.rc2.264.g509ed76dc8-goog