lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4qln6l2oc4y3yvfm36tbsgkxxaq4i7yvxbzlnz36yrvajdwmfs@lkk7ujwbulq2>
Date: Mon, 30 Jun 2025 12:05:54 +0200
From: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>
To: David Laight <david.laight.linux@...il.com>
Cc: Baokun Li <libaokun1@...wei.com>, Pankaj Raghav <p.raghav@...sung.com>, 
	Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, mcgrof@...nel.org, 
	Alexander Viro <viro@...iv.linux.org.uk>, linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org, 
	gost.dev@...sung.com, Matthew Wilcox <willy@...radead.org>, 
	Zhang Yi <yi.zhang@...wei.com>, Yang Erkun <yangerkun@...wei.com>
Subject: Re: [PATCH v4] fs/buffer: remove the min and max limit checks in
 __getblk_slow()

On Sun, Jun 29, 2025 at 11:15:06AM +0100, David Laight wrote:
> On Fri, 27 Jun 2025 10:02:30 +0800
> Baokun Li <libaokun1@...wei.com> wrote:
> 
> > On 2025/6/26 19:32, Pankaj Raghav wrote:
> > > All filesystems will already check the max and min value of their block
> > > size during their initialization. __getblk_slow() is a very low-level
> > > function to have these checks. Remove them and only check for logical
> > > block size alignment.
> > >
> > > As this check with logical block size alignment might never trigger, add
> > > WARN_ON_ONCE() to the check. As WARN_ON_ONCE() will already print the
> > > stack, remove the call to dump_stack().
> > >
> > > Suggested-by: Matthew Wilcox <willy@...radead.org>
> > > Reviewed-by: Jan Kara <jack@...e.cz>
> > > Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>  
> > 
> > Makes sense. Feel free to add:
> > 
> > Reviewed-by: Baokun Li <libaokun1@...wei.com>
> > 
> > > ---
> > > Changes since v3:
> > > - Use WARN_ON_ONCE on the logical block size check and remove the call
> > >    to dump_stack.
> > > - Use IS_ALIGNED() to check for aligned instead of open coding the
> > >    check.
> > >
> > >   fs/buffer.c | 11 +++--------
> > >   1 file changed, 3 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/fs/buffer.c b/fs/buffer.c
> > > index d61073143127..565fe88773c2 100644
> > > --- a/fs/buffer.c
> > > +++ b/fs/buffer.c
> > > @@ -1122,14 +1122,9 @@ __getblk_slow(struct block_device *bdev, sector_t block,
> > >   {
> > >   	bool blocking = gfpflags_allow_blocking(gfp);
> > >   
> > > -	if (unlikely(size & (bdev_logical_block_size(bdev) - 1) ||
> > > -		     (size < 512 || size > PAGE_SIZE))) {
> > > -		printk(KERN_ERR "getblk(): invalid block size %d requested\n",
> > > -					size);
> > > -		printk(KERN_ERR "logical block size: %d\n",
> > > -					bdev_logical_block_size(bdev));
> > > -
> > > -		dump_stack();
> > > +	if (WARN_ON_ONCE(!IS_ALIGNED(size, bdev_logical_block_size(bdev)))) {
> > > +		printk(KERN_ERR "getblk(): block size %d not aligned to logical block size %d\n",
> > > +		       size, bdev_logical_block_size(bdev));
> > >   		return NULL;
> 
> Shouldn't that use WARN_ONCE(condition, fmt, ...)

We need to return NULL if the check fails. So having the condition and
the format as an `if` condition does not look nice. Plus the formatting
will look weird.

--
Pankaj

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ