fs/binfmt_elf.c | 5 +++++ include/linux/mm.h | 10 ++++++++++ mm/mseal.c | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-)
From: Jeff Xu <jeffxu@chromium.org> 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(-) -- 2.46.0.rc2.264.g509ed76dc8-goog
On Tue, 06 Aug 2024 21:49:26 +0000, jeffxu@chromium.org wrote: > From: Jeff Xu <jeffxu@chromium.org> > > 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. */ > > [...] I added the cover letter details to the commit log and changed pr_warn() to pr_warn_ratelimited(), but otherwise, looked good. Applied to for-next/execve, thanks! [1/1] binfmt_elf: mseal address zero https://git.kernel.org/kees/c/44f65d900698 Take care, -- Kees Cook
On Wed, Aug 14, 2024 at 09:59:47AM -0700, Kees Cook wrote: > On Tue, 06 Aug 2024 21:49:26 +0000, jeffxu@chromium.org wrote: > > From: Jeff Xu <jeffxu@chromium.org> > > > > 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. */ > > > > [...] > > I added the cover letter details to the commit log and changed pr_warn() > to pr_warn_ratelimited(), but otherwise, looked good. > > Applied to for-next/execve, thanks! > > [1/1] binfmt_elf: mseal address zero > https://git.kernel.org/kees/c/44f65d900698 > > Take care, > > -- > Kees Cook > > Hi Kees, Reproducing diffstat here: fs/binfmt_elf.c | 5 +++++ include/linux/mm.h | 10 ++++++++++ mm/mseal.c | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) It seems that in commit 44f65d9006982 ("binfmt_elf: mseal address zero") you took a patch that makes changes to mm code without any review/ack from any mm maintainer. While I realise this was a small change, in future can you make sure to ensure you have that? I know linux-mm was cc'd but clearly it was missed. Thanks, Lorenzo
Sorry for the delay in my reply -- I've been trying to catch up on stuff after 2 weeks off. On Tue, Dec 03, 2024 at 02:13:45PM +0000, Lorenzo Stoakes wrote: > On Wed, Aug 14, 2024 at 09:59:47AM -0700, Kees Cook wrote: > > On Tue, 06 Aug 2024 21:49:26 +0000, jeffxu@chromium.org wrote: > > > From: Jeff Xu <jeffxu@chromium.org> > > > > > > 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. */ > > > > > > [...] > > > > I added the cover letter details to the commit log and changed pr_warn() > > to pr_warn_ratelimited(), but otherwise, looked good. > > > > Applied to for-next/execve, thanks! > > > > [1/1] binfmt_elf: mseal address zero > > https://git.kernel.org/kees/c/44f65d900698 > > > > Take care, > > > > -- > > Kees Cook > > > > > > Hi Kees, > > Reproducing diffstat here: > > fs/binfmt_elf.c | 5 +++++ > include/linux/mm.h | 10 ++++++++++ > mm/mseal.c | 2 +- > 3 files changed, 16 insertions(+), 1 deletion(-) > > It seems that in commit 44f65d9006982 ("binfmt_elf: mseal address zero") > you took a patch that makes changes to mm code without any review/ack from > any mm maintainer. > > While I realise this was a small change, in future can you make sure to > ensure you have that? Oh, yes! I can do that. As you say, it was a very small change and almost entirely "standard" boilerplate. But sure, I will be poke people more directly if anything touches mm in the future. -Kees -- Kees Cook
© 2016 - 2025 Red Hat, Inc.