]> git.baikalelectronics.ru Git - kernel.git/commit
binfmt_elf: Don't clobber passed executable's file header
authorMaciej W. Rozycki <macro@imgtec.com>
Mon, 26 Oct 2015 15:48:19 +0000 (15:48 +0000)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 11 Nov 2015 07:18:07 +0000 (02:18 -0500)
commita9f586b9307b052e8607c403f65e81ba2b6c6005
tree0dfe5b64ffdbdaea441ee58bab03362e25df810b
parent5d48261abfac8200c1a48481f791d9d8e41bb764
binfmt_elf: Don't clobber passed executable's file header

Do not clobber the buffer space passed from `search_binary_handler' and
originally preloaded by `prepare_binprm' with the executable's file
header by overwriting it with its interpreter's file header.  Instead
keep the buffer space intact and directly use the data structure locally
allocated for the interpreter's file header, fixing a bug introduced in
2.1.14 with loadable module support (linux-mips.org commit beb11695
[Import of Linux/MIPS 2.1.14], predating kernel.org repo's history).
Adjust the amount of data read from the interpreter's file accordingly.

This was not an issue before loadable module support, because back then
`load_elf_binary' was executed only once for a given ELF executable,
whether the function succeeded or failed.

With loadable module support supported and enabled, upon a failure of
`load_elf_binary' -- which may for example be caused by architecture
code rejecting an executable due to a missing hardware feature requested
in the file header -- a module load is attempted and then the function
reexecuted by `search_binary_handler'.  With the executable's file
header replaced with its interpreter's file header the executable can
then be erroneously accepted in this subsequent attempt.

Cc: stable@vger.kernel.org # all the way back
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/binfmt_elf.c