Re: [PATCH] module: fix validate_section_offset() overflow bug on 64-bit

From: Shuah Khan
Date: Mon Oct 18 2021 - 13:36:18 EST


On 10/15/21 3:14 PM, Luis Chamberlain wrote:
On Fri, Oct 15, 2021 at 02:57:41PM -0600, Shuah Khan wrote:
validate_section_offset() uses unsigned long local variable to
add/store shdr->sh_offset and shdr->sh_size on all platforms.
unsigned long is too short when sh_offset is Elf64_Off which
would be the case on 64bit ELF headers.

Fix the overflow problem using the right size local variable when
CONFIG_64BIT is defined.

Signed-off-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>

Thanks for doing this! I put this through the 0-day grinder.

In the meantime, since this talks about a fix, can the commit log be a
bit more descriptive about the impact of not applying the fix? In what
situation would not having this patch applied create an issue? Is this
theoretical or can an issue really happen. Has an issue gone
undiscovered for a while, and if so what could the consequences
have been all along?


I found this when I was adding an error message to print the offset and
size.

And it would seem this issue was found through code inspection, not
through a real bug, correct? If this can be clarified on the commit log
as well that would be great!


Sent v2 with updated commit log.

thanks,
-- Shuah