Skip to content
Commit 3eb3cd59 authored by Kees Cook's avatar Kees Cook
Browse files

binfmt_flat: Fix corruption when not offsetting data start

Commit 04d82a6d ("binfmt_flat: allow not offsetting data start")
introduced a RISC-V specific variant of the FLAT format which does
not allocate any space for the (obsolete) array of shared library
pointers. However, it did not disable the code which initializes the
array, resulting in the corruption of sizeof(long) bytes before the DATA
segment, generally the end of the TEXT segment.

Introduce MAX_SHARED_LIBS_UPDATE which depends on the state of
CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET to guard the initialization of
the shared library pointer region so that it will only be initialized
if space is reserved for it.

Fixes: 04d82a6d

 ("binfmt_flat: allow not offsetting data start")
Co-developed-by: default avatarStefan O'Rear <sorear@fastmail.com>
Signed-off-by: default avatarStefan O'Rear <sorear@fastmail.com>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Acked-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
Link: https://lore.kernel.org/r/20240807195119.it.782-kees@kernel.org
Signed-off-by: default avatarKees Cook <kees@kernel.org>
parent de9c2c66
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment