From: sashiko-bot@kernel.org
To: "Konstantin Khorenko" <khorenko@virtuozzo.com>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>, "Kees Cook" <kees@kernel.org>,
"Paul Burton" <paulburton@kernel.org>,
"Shuah Khan" <shuah@kernel.org>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH v2 1/2] binfmt_elf: return the real error when program headers cannot be loaded
Date: Sat, 07 Nov 2026 20:58:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-203336@kernel.org> (raw)
In-Reply-To: <20261106-b4-prep-vstor-149847-binfmt_elf-enomem-load-elf-phdrs-v2-1-1c8b7b1dae5c@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] binfmt_elf: missing Fixes trailer for load_elf_phdrs() error
return
--
commit 46b1e6b996d116acfe43305abc30c04627bdcd95
Author: Konstantin Khorenko <khorenko@virtuozzo.com>
> binfmt_elf: return the real error when program headers cannot be loaded
>
> load_elf_phdrs() returns NULL on any failure, and load_elf_binary()
> turns that into -ENOEXEC for the executable and -ELIBBAD for its
> interpreter. So a failed allocation or read of the program headers
> makes glibc's execvp() run the ELF file with /bin/sh, and for the
> interpreter reports a healthy ld.so as a corrupted shared library.
>
> Return an ERR_PTR instead:
>
> +------------+------------------------------------------------------+
> | error | when |
> +------------+------------------------------------------------------+
> | -ENOEXEC | bad e_phentsize, e_phnum or e_phoff, or a short read |
> | -ENOMEM | the allocation fails |
> | read error | kernel_read() fails |
> +------------+------------------------------------------------------+
>
> Malformed files and short reads keep getting -ENOEXEC and -ELIBBAD.
> The table is read with kernel_read() directly, as elf_read() turns a
> short read into -EIO. An e_phoff past LLONG_MAX - size is rejected up
> front, so that rw_verify_area() does not turn it into -EINVAL.
>
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
[Severity: Low]
Prior to 6a8d38945cf4 ("binfmt_elf: Hoist ELF program header loading to a
function"), load_elf_binary() propagated -ENOMEM and negative read errors
when loading program headers. Should this include:
Fixes: 6a8d38945cf4 ("binfmt_elf: Hoist ELF program header loading to a function")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-b4-prep-vstor-149847-binfmt_elf-enomem-load-elf-phdrs-v2-0-1c8b7b1dae5c@virtuozzo.com?part=1
next prev parent reply other threads:[~2026-11-07 20:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 20:57 [PATCH v2 0/2] binfmt_elf: return the real error when program headers cannot be loaded Konstantin Khorenko
2026-11-06 20:57 ` [PATCH v2 1/2] " Konstantin Khorenko
2026-11-07 20:58 ` sashiko-bot [this message]
2026-11-06 20:57 ` [PATCH v2 2/2] selftests/exec: check the errors of an unloadable program header table Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-203336@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=khorenko@virtuozzo.com \
--cc=linux-mm@kvack.org \
--cc=paulburton@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shuah@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox