From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE5C5385D9A for ; Thu, 21 May 2026 12:36:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779366970; cv=none; b=UqKpEcu+z55RqnTvemzi9YAY4xMkMu4KJlNlZo0J9+gqpGszI3N967WLpX6sOGGem4WrxyPFAe7Nn2qb8GFy51j6YZHz0wej9LCagMiAiFYsk1+AeDQw27BMCKSf3jCfY1Sj0P0yY1XkEtKolgzBWajH6syi0UMscQiTa9D2UY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779366970; c=relaxed/simple; bh=Txu+oyQzK3BgRyNhst4Vgpv3MsVd+2UUhvNtVoHZ624=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pr2PBBGmB/g49PUIavgHqCbuOGSRe2r73Fdp9U+GstV8JyLwPAf52pgZy2xo4EEYLb+n8VsobNWbdr+Q6Qlq/udo5SARdbUNTeXFQzKqV89ctgHJK4zTbaDiIUj2OMXSyarPjXZSFK28dhyKLhJe5OvSGeADxi7jrP7bObLOQWE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K2HqkZMv; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K2HqkZMv" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4896c22fcbaso50886335e9.0 for ; Thu, 21 May 2026 05:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779366967; x=1779971767; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=yFIZXtVvBZRqTePlpCyJOVeNwW4Mqn3yIZBmkFVt5RA=; b=K2HqkZMv03l9IzXxqF03KafU19ZrFw5SBR3IHFHBrfu0VkJAwMWdBteRcI+EBdu9pt QOae2sXewJu5p0sqO671MwWN9+IuGTS87pcVv1J0mxDy7oU/ujefYb8y6i3opX4SDhh7 j9hRvQzhcPEnnuhpxHGcs0ykiNIY+Eax1iuaajR00tdFlZi+8dygtiOgti+oCiLOcdl6 ltd+OQqCEZKlo0zYm6/84ShVB9iQZA0UgALQ6L/fqYt2GAuDao8YT2jYGXOvqqiYJxU3 g7QCerxQsiqXFqUKhEGMH1qoHc4VdqTQoGdcuUMAC8TXGzxCZIYY3vMtyeJyj6YuexCN 87vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779366967; x=1779971767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yFIZXtVvBZRqTePlpCyJOVeNwW4Mqn3yIZBmkFVt5RA=; b=YKXCJgqFppt/72uJ1p4Kc2yZpySeauJjRIsjz9XKC4Yv16V8zZYMEWQrfxl/AmeAj0 PuFsf2EZPVJqxF7WaBxgnj8KMcDendA6Y/fsH5AyAbOyjKXrjZahZJA4e5jTyIcA/wFz cF5KMTnUzAVd913vY9Kg0PtoxwjrGTQbv0LeAsOE9k0MT6KagHdZRtwhFOLQHmNdOcwC go7j/FdGA+Cx9xoecczN7OpTvh8KXif8yQqii7z8b90TBX7T2isKZgr17P7ilFU2xYux VngwcITlf87lnuxLh63D9ld0ZdB/eZbkrZ1cMDNvsz/49sOusFhaY+l39PLtVdmbqw6n jIvg== X-Forwarded-Encrypted: i=1; AFNElJ9aQAb7Cf16NaWcx8lhJvmT/Umxc7oGZgdDGtEMWC3p4k7ho38BocKvD1q3sZnz+X/oYorf6U17EF2POcU=@vger.kernel.org X-Gm-Message-State: AOJu0YxlwnF2sE9fzonZ/L7UbLLAxD6EY1GquvuVrBqdDrz15K2GLY88 2jDTzw9S0JJ62SaCFtXJRkaRbhr1zxfl9Rjmv5KuFKjc7YnA9XLrV97f8JTQY1IiUxI= X-Gm-Gg: Acq92OGIvBhuCEeMAG9cacsBFkZDc+W2Pamf8k3Yw+XpsUbg22UCZghs1yILJkcs+Oq ghJOXI4h/Z4Xwhd1wOw2OUD+5QQS7NgEL59clrF7Tpb/uKBOL0eZUszTmp7DCYVn3+5wmLq5yAw NiGYnlIMnj/ZvSsl6ZVWNYQMZTcNNQ3T0dBQBK4YbDNMS25D/9QRhsZQ0JpHGL/a47ZobJoP3z/ 6l7W/TSRRBMo+YB67dkyAwRkw5HRQtM/NB9GbSdsiTHOf7cD7hxSUT2Q2rHFzorp+04OriSySQF ApdVCAIppWiO7S7yrZpDb0Kv+QjqK1GMKPCks9yPOvHZSuVF/44J0WySKGMOIP9wMYZqgKrCX1i 9tpftfWjbqjaEIGa35yMVH4JymHbsjEAKggaVLIuNOWrg+HSlc3Fy3hu/VFn16d1XQ9t7niUQ4s IONUhxJcNyGC1eYbrrR4RAPRZTap3GyUGPo+X7fd0WqFkmnPaj/mA8zcScXIoTsh67 X-Received: by 2002:a05:600c:3513:b0:48a:906a:9050 with SMTP id 5b1f17b1804b1-4903605f4f4mr40314525e9.10.1779366966742; Thu, 21 May 2026 05:36:06 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4903c996295sm22493515e9.1.2026.05.21.05.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 05:36:06 -0700 (PDT) Date: Thu, 21 May 2026 13:36:05 +0100 From: David Laight To: Arnd Bergmann Cc: OGAWA Hirofumi , Arnd Bergmann , Christian Brauner , Jan Kara , avivdaum , Adi Nata , Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] fat: avoid stack overflow warning Message-ID: <20260521133605.56d09a61@pumpkin> In-Reply-To: <20260515204456.2692208-1-arnd@kernel.org> References: <20260515204456.2692208-1-arnd@kernel.org> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 15 May 2026 22:44:46 +0200 Arnd Bergmann wrote: > From: Arnd Bergmann >=20 > Building the fat kunit tests on with -fsanitize=3Dalignment > reveals some rather excessive stack usage: What on earth is -fsanitize=3Dalignment doing here? (Or even what do it do in general!) =46rom a 'testing the kernel' point of view I don't think you'd ever want to copy a structure that might be misaligned. (Quite how it does that in the general case when the address of something in the structure might get passed to passed to code that knows the address by other means is anybodies guess.) The most you might want for 'kernel hardening' is a software check that run-time errors misaligned structures. -- David >=20 > 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 tha= n 1536 bytes [-Werror=3Dframe-larger-than=3D] > 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 tha= n 1536 bytes [-Werror=3Dframe-larger-than=3D] >=20 > 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. >=20 > Signed-off-by: Arnd Bergmann > --- > fs/fat/fat.h | 4 ++-- > fs/fat/fat_test.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) >=20 > 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; > } > =20 > -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; > } > =20 > -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 =3D 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) > =20 > static void fat_clus_to_blknr_test(struct kunit *test) > { > - struct msdos_sb_info sbi =3D { > + static const struct msdos_sb_info sbi =3D { > .sec_per_clus =3D 4, > .data_start =3D 100, > }; > @@ -34,7 +34,7 @@ static void fat_clus_to_blknr_test(struct kunit *test) > =20 > static void fat_get_blknr_offset_test(struct kunit *test) > { > - struct msdos_sb_info sbi =3D { > + static const struct msdos_sb_info sbi =3D { > .dir_per_block =3D 16, > .dir_per_block_bits =3D 4, > };