[Devel] [PATCH hci-8.1 2/2] binfmt_elf: return the real error when program headers cannot be loaded

no-reply at sashiko.virtuozzo.com no-reply at sashiko.virtuozzo.com
Wed Oct 14 20:07:31 MSK 2026


> 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 reports a
> healthy ld.so as a corrupted shared library.
> 
> Return an ERR_PTR instead, as binfmt_elf_fdpic does:
> 
>   -ENOEXEC     bad e_phentsize, e_phnum or e_phoff, or the file ends
>                before the header table
>   -ENOMEM      the allocation fails
>   read error   kernel_read() fails
> 
> Malformed files keep getting -ENOEXEC and -ELIBBAD. kernel_read()
> returns a short count when a later page fails, so read on until the
> [ ... ]
> https://virtuozzo.atlassian.net/browse/VSTOR-150144
> 
> Feature: fix ms/exec
> Assisted-by: LLM
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261014-b4-prep-khorenko-vstor-149847-1-upstream-fixes-v1-0-7fde9ffbebe9@virtuozzo.com?part=2




More information about the Devel mailing list