From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 0434D405869 for ; Wed, 3 Jun 2026 10:07:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481224; cv=none; b=OToztJWYvgDxntPHXB2ce8WG3tm20yJ3inI4oBrJWAwLRcVfY4pYRP/5alSb7EOMMHfL3soo1a8mOO3hKzYMCfayHD6T2iBnixoNGSGx9gq6mBAxYPmuxjHxhhPQexRWfUg4dOv9abPlBICRYGJTSairT45IynIAK8KBaOUYaug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780481224; c=relaxed/simple; bh=pzojEPZdo7Hqwl5lrcbPDejqAbHuBiv1S3wzPlbXfkI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H1KloYeU+rNzk9ncx4514IAwuIrcmRZgTuBko4WIo3XozP7XE/Zkxk7Tmh5tg2ecymY5i9yQLS9b6j4Dr5M/AK5/LRlpyNgB/whok1+37n42OwyiWfpzpiBfq4QShMpwmoACiqWQTeNsQ144aShABJ5RHdxTEy665akoT5B+qow= 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=aRGb5CG6; arc=none smtp.client-ip=209.85.128.47 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="aRGb5CG6" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-490b211ee6aso15243915e9.3 for ; Wed, 03 Jun 2026 03:07:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780481221; x=1781086021; 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=Zcl87izflKZq7l6r393qSQQZdR+yaripAx2x4UTraDY=; b=aRGb5CG6W06Mrb3jsFPBYOkaZneos4mHGs4thuVxCPY7qV+Kx/yQcChrpxUqN79IPW hZlH2QKZuw+hInGrFrWfjZxhnmugM80SGu9xmC+Eg5z+Noboistcsp/JZa6FD8fO3u5+ fUZdriomYG/rPJMYUgz54u/f0H9McBQZrLp2IfmamG0iVtcy2SQffjaVQTX+YwNdiKlV n9icFKS9FrzthL3SdVm4k3ucY5UlU0FihGdzij/QdNnKMrzmVSN2D9QjZ/qCBij82EA6 m7J2twsIM2IdX+r4aGVxDazsT3GXcBPb65s3IdWRuITIvguAGqYml9MFF9dDN3wvWLXf F3vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780481221; x=1781086021; 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=Zcl87izflKZq7l6r393qSQQZdR+yaripAx2x4UTraDY=; b=TdIxHaope8mMQG26Lc0NRDZx4aEWbn+bfG/upDT0tehLrUVz9tIdO8naD+s8wfUsCk Wy0mKeo4vVqYquTVepn40aJD72a0F2WO0mf0pTaLHYIpacVTxo5eUOXs2R2R9wGYmmtk kgID/7GL/m/j75L/ijxDIvKwdrWHTjMOKYzogShuVwp4Dg7yPoYKoNrADgmEgkAYJH5p l6xV03y1GY8hvI1F/bNEUzgG+NVZIBAZ23iPxTclF1wU/CJod+dD9vFECWiBv9pODA6l 6g2gkkImm6SM0NQGbDBWLFZVNdwEzy1ep3uRCS4v7KGY+LoJV1Fgn1vWXTMLTmHzEpCc F9Ow== X-Forwarded-Encrypted: i=1; AFNElJ/X+OoiYVqO9GRRglI27BEe0Wx1GmxwGIynuPJcF7XZ0R7RxsIRQ8G6z+UaQkXRk8+H8EWvQoQznDEzj3c=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5QEQMS4+ScNBA9NIHQI4zfSYcFy70NUjT3MEEdRvbGWXNrk0D x1e0df84aKW4eAi8scdKQXXJOz4MtYNP4DwYujvm5IRl1Y/bcNZVwb20 X-Gm-Gg: Acq92OHqBHrVgq1gcaq+u3QZIMbstpSaNoq7Mtr1xcDCdv1Zd77DayJeQQ3kmFyhI7s wbu6HdlzvhqsUz24OlnV78mEu0mxnbyIqhT2igaiXUdi4yIEQiwkNCM24avqeOsR/xgm7xGpOwB 2C1OZXihC668BpWZmmlvrYGfGlbyShEte8v0gVf1G3zUECmCtBOA6YVsQQOY3266tQ1YeswLi9q UcDy+57f2xc0j/rjkM3zfSQMlzBJueFcevaAqG7J/EGeApMxSPD5W7doxyg7Yr6OrQc0MxZ4f/V YRV7fgKdrFiVAbyPS6jFMqglqmk23J4/3Go1UrYZqwRR8eizST5eRqLZkwaa3Z1zmPiGuZPH5y1 RB9IeY4xcOR4y0oOMG/HAU1WIsPsYaGt4DuSHWgmac45TztT+lYMHKZ9ocN/VMGTlwTS8qYVi4T y+1kyXXZHLVv6SxrsciSDw5wE1RmJ8DKfuvXlWFGH6P/zHi9Dl2wCOIYjBjGte1NtB2ZgGo2Y= X-Received: by 2002:a05:600c:470e:b0:485:4388:3492 with SMTP id 5b1f17b1804b1-490b5e73d8cmr43982455e9.11.1780481221253; Wed, 03 Jun 2026 03:07:01 -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-490b0e2b4e5sm143149775e9.7.2026.06.03.03.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 03:07:00 -0700 (PDT) Date: Wed, 3 Jun 2026 11:06:59 +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: <20260603110659.05095118@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: 7bit On Fri, 15 May 2026 22:44:46 +0200 Arnd Bergmann wrote: > 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. Just FYI: Without -fsanitize=alignment fat_clus_to_blknr() is almost certainly inlined (as expected) and then 'sbi' is completely optimised away. -- David > > 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, > };