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 54A8826B75B; Tue, 4 Nov 2025 15:57:53 +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=1762271873; cv=none; b=U6+nKPpHBUnBaN0Hl2ckpir2f9vtBvMp6puoBSbnW9J5GuYyJHbLDf2HdHFrGJs84JXT3t45HXj2ZhE0krs1Z7IVxa3ZLs+PD5jJtcAs0Zf5Nv2L64HqdEb14j3mjbUrOGIED9eL0bPjvB7o5M2fN/NSYHe4sbKAev9504W1XEw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762271873; c=relaxed/simple; bh=etPxiZ7rjP8VtgOg/n1V87qRxchqdEoQZ9KyI3fRorU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TUDpu0mv50tjiOPsi08K0dqR1+t0ogIVevrc4tSYhdpQ8JJPlINJp1f7ovJ/d/RAMllVzpx4P1bDdlmp0s81CmGQqGRJ8Uhv17rcSP/MLRwMW3qC+YSph2yCluHk6GxVu6LhQfPfLtNSO2QKfV17Cr9oJkkBsE1uip2OJkMn2ck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lhIYInPy; 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="lhIYInPy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB013C4CEF7; Tue, 4 Nov 2025 15:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762271872; bh=etPxiZ7rjP8VtgOg/n1V87qRxchqdEoQZ9KyI3fRorU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lhIYInPyIxnNY1EIllIQhhpfP0DP2/EeT3oIkIX3I5K0jheAHc3+3C16W4p9GJAB3 qyJM5t9DGGOR+a1d2pRYrYHVBiHtZQXvRjN4ka+q5H5I8XIcY2iBsEILKp+3dERtxH P+xsYopX8bWUApscI9kNQKLnBfb1PO/vLa3MN4DRtMFXDIAdZXGYsz/a7dosKn4puZ G3dJQHVa41HF+WK8KZDHNNW6KAldY7z6faIj6DpnHl0RaYyUe6idw2hGOYupkrm+pK NgAhPZv/mp8b3HUD/zT1TyxYt5KN5Drgy9lju8+eQ9Jid6aXAt3izazhFpqk47PmZ3 aMvhIN/ZvaIag== Date: Tue, 4 Nov 2025 07:57:52 -0800 From: "Darrick J. Wong" To: Yongpeng Yang Cc: Namjae Jeon , Sungjong Seo , OGAWA Hirofumi , Jan Kara , Carlos Maiolino , Jens Axboe , Greg Kroah-Hartman , Sasha Levin , Alexander Viro , Christian Brauner , Christoph Hellwig , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, stable@vger.kernel.org, Matthew Wilcox , Yongpeng Yang Subject: Re: [PATCH v4 5/5] block: add __must_check attribute to sb_min_blocksize() Message-ID: <20251104155752.GB196362@frogsfrogsfrogs> References: <20251103163617.151045-2-yangyongpeng.storage@gmail.com> <20251103163617.151045-6-yangyongpeng.storage@gmail.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251103163617.151045-6-yangyongpeng.storage@gmail.com> On Tue, Nov 04, 2025 at 12:36:18AM +0800, Yongpeng Yang wrote: > From: Yongpeng Yang > > When sb_min_blocksize() returns 0 and the return value is not checked, > it may lead to a situation where sb->s_blocksize is 0 when > accessing the filesystem super block. After commit a64e5a596067bd > ("bdev: add back PAGE_SIZE block size validation for > sb_set_blocksize()"), this becomes more likely to happen when the > block device’s logical_block_size is larger than PAGE_SIZE and the > filesystem is unformatted. Add the __must_check attribute to ensure > callers always check the return value. > > Suggested-by: Matthew Wilcox > Signed-off-by: Yongpeng Yang Looks good to me, Reviewed-by: "Darrick J. Wong" --D > --- > block/bdev.c | 2 +- > include/linux/fs.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/block/bdev.c b/block/bdev.c > index 810707cca970..638f0cd458ae 100644 > --- a/block/bdev.c > +++ b/block/bdev.c > @@ -231,7 +231,7 @@ int sb_set_blocksize(struct super_block *sb, int size) > > EXPORT_SYMBOL(sb_set_blocksize); > > -int sb_min_blocksize(struct super_block *sb, int size) > +int __must_check sb_min_blocksize(struct super_block *sb, int size) > { > int minsize = bdev_logical_block_size(sb->s_bdev); > if (size < minsize) > diff --git a/include/linux/fs.h b/include/linux/fs.h > index c895146c1444..26d4ca0f859a 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -3424,7 +3424,7 @@ extern void inode_sb_list_add(struct inode *inode); > extern void inode_add_lru(struct inode *inode); > > extern int sb_set_blocksize(struct super_block *, int); > -extern int sb_min_blocksize(struct super_block *, int); > +extern int __must_check sb_min_blocksize(struct super_block *, int); > > int generic_file_mmap(struct file *, struct vm_area_struct *); > int generic_file_mmap_prepare(struct vm_area_desc *desc); > -- > 2.43.0 > >