]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
binfmt_flat: Fix integer overflow bug on 32 bit systems
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 4 Dec 2024 12:07:15 +0000 (15:07 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:50:24 +0000 (12:50 +0100)
commitbc8ca18b8ef4648532c001bd6c8151143b569275
treef65542d1c132512cd0a2bcb58eb05f29ed1abc33
parent20ecbadad51a79db3ff8c3f2bfe21bb7267ee0f0
binfmt_flat: Fix integer overflow bug on 32 bit systems

commit 55cf2f4b945f6a6416cc2524ba740b83cc9af25a upstream.

Most of these sizes and counts are capped at 256MB so the math doesn't
result in an integer overflow.  The "relocs" count needs to be checked
as well.  Otherwise on 32bit systems the calculation of "full_data"
could be wrong.

full_data = data_len + relocs * sizeof(unsigned long);

Fixes: c995ee28d29d ("binfmt_flat: prevent kernel dammage from corrupted executable headers")
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Nicolas Pitre <npitre@baylibre.com>
Link: https://lore.kernel.org/r/5be17f6c-5338-43be-91ef-650153b975cb@stanley.mountain
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/binfmt_flat.c