From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C8A1389DF0 for ; Fri, 15 May 2026 20:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778877901; cv=none; b=tltvftwb7JlvGb/yTjoY1d+H67J2YEy4XfnX7hr+zs4cqEpyqhKiFizTZ7K7g3TQnIF+FRmwjLBHqDxGrbH2xmeJfrJ7gGIt6Ez0tu20ldj3Jc75X5aJREjqLBLAdvpJAax81a95QNEvKBu/hqLB70XYNt5YXudxogEoEdyaXoQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778877901; c=relaxed/simple; bh=dKA9zfIQcMU2bTbe1CXSdM2H0pNj1SxpsOiylITrPuQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=KxS0xZFYS5kqFArZGHvkW5G/7V2Pm3W+rq+LG1h27RX6jtmZ1rTJjBqZ06ciY5RN6nCCVJReifr2RoEM8DqZj7hsbAV1IXAR+c0HkNIywxhk+Dw2c6DaTdkQG8spRfJfnkVM3uk6Cqzth8OMD3ms3dQ0LQDjXWGb4G3494pP4Ag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i/VnuT2w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i/VnuT2w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F540C2BCB0; Fri, 15 May 2026 20:44:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778877901; bh=dKA9zfIQcMU2bTbe1CXSdM2H0pNj1SxpsOiylITrPuQ=; h=From:To:Cc:Subject:Date:From; b=i/VnuT2wn7pIB/Rl3hHCRyTPa3mAb3mT9fsZb0uWczNVuudPWABiA4tf0ZYp0Nbhi 8EFAvuNRRNH7cU9Jp66m7VeY5K9Ygd7p7Hs6F+atzZBqDKRn2UPHCgfdm3cMrKT5qc LfZejI+T6yvChiF92lMoFY0NIu+NGysZAzbwS/CU8S8C2LSL3vFYuVjUiEXKjnEAV5 MvqQjeaNB3Eor5IWQBqQb8c5j1osIFWecuPUDON91a6K+zXLo1Byedj9hYM4ecPllS pqgWFMSb1gmRTZI9TX/tZeb3Dul97o2uIxRMzzUY74vOb+7I0EwFvfn+SmofO775e2 7dWF2kqVb/PVA== From: Arnd Bergmann To: OGAWA Hirofumi Cc: Arnd Bergmann , Christian Brauner , Jan Kara , avivdaum , Adi Nata , Andrew Morton , linux-kernel@vger.kernel.org Subject: [PATCH] fat: avoid stack overflow warning Date: Fri, 15 May 2026 22:44:46 +0200 Message-Id: <20260515204456.2692208-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann 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 --- fs/fat/fat.h | 4 ++-- fs/fat/fat_test.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/fat/fat.h b/fs/fat/fat.h index 5a58f0bf8ce8..52bced59abe4 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h @@ -247,13 +247,13 @@ static inline unsigned char fat_checksum(const __u8 *name) return s; } -static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus) +static inline sector_t fat_clus_to_blknr(const struct msdos_sb_info *sbi, int clus) { return ((sector_t)clus - FAT_START_ENT) * sbi->sec_per_clus + sbi->data_start; } -static inline void fat_get_blknr_offset(struct msdos_sb_info *sbi, +static inline void fat_get_blknr_offset(const struct msdos_sb_info *sbi, loff_t i_pos, sector_t *blknr, int *offset) { *blknr = i_pos >> sbi->dir_per_block_bits; diff --git a/fs/fat/fat_test.c b/fs/fat/fat_test.c index 4eeed9dca549..9583ce66dca3 100644 --- a/fs/fat/fat_test.c +++ b/fs/fat/fat_test.c @@ -22,7 +22,7 @@ static void fat_checksum_test(struct kunit *test) static void fat_clus_to_blknr_test(struct kunit *test) { - struct msdos_sb_info sbi = { + static const struct msdos_sb_info sbi = { .sec_per_clus = 4, .data_start = 100, }; @@ -34,7 +34,7 @@ static void fat_clus_to_blknr_test(struct kunit *test) static void fat_get_blknr_offset_test(struct kunit *test) { - struct msdos_sb_info sbi = { + static const struct msdos_sb_info sbi = { .dir_per_block = 16, .dir_per_block_bits = 4, }; -- 2.39.5