Re: [PATCH] fat: avoid stack overflow warning

From: Arnd Bergmann

Date: Thu May 21 2026 - 08:10:45 EST


On Thu, May 21, 2026, at 13:41, Christian Brauner wrote:
> On Fri, May 15, 2026 at 10:44:46PM +0200, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@xxxxxxxx>
>>
>> Building the fat kunit tests on with -fsanitize=alignment
>> reveals some rather excessive stack usage:
>>
>> fs/fat/fat_test.c: In function 'fat_clus_to_blknr_test':
>> fs/fat/fat_test.c:33:1: error: the frame size of 4736 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
>> 33 | }
>> | ^
>> fs/fat/fat_test.c: In function 'fat_get_blknr_offset_test':
>> fs/fat/fat_test.c:52:1: error: the frame size of 4800 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
>>
>> The problem is clearly related to the on-stack copy of a local
>> msdos_sb_info structure. Avoid this by making that copy
>> 'static const' and changing the called functions to accept
>> a constant input.
>>
>> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
>> ---
>
> What is this based on, Arnd? I'm getting errors applying this.

I had assumed this was an old bug, as it showed up right after
I changed toolchains and ran into similar problems elsewhere.

Looking again, I see now that this just came in through
aecd952e23ee ("kunit: fat: test cluster and directory
i_pos layout helpers"), which is in the mm-nonmm-unstable
branch in current linux-next.

Maybe Andrew can just fold my fixup into that patch.

Arnd