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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aA-HSxKfbM6WCgek@infradead.org>
Date: Mon, 28 Apr 2025 06:48:59 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Lizhi Xu <lizhi.xu@...driver.com>
Cc: hch@...radead.org, axboe@...nel.dk, linux-block@...r.kernel.org,
	linux-kernel@...r.kernel.org, ming.lei@...hat.com,
	syzbot+6af973a3b8dfd2faefdc@...kaller.appspotmail.com,
	syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH V3] loop: Add sanity check for read/write_iter

On Mon, Apr 28, 2025 at 09:42:31PM +0800, Lizhi Xu wrote:
> On Mon, 28 Apr 2025 05:49:20 -0700, Christoph Hellwig wrote:
> > > +static int loop_check_backing_file(struct file *file, blk_mode_t mode, bool change)
> > > +{
> > > +	if (!file->f_op->read_iter)
> > > +		return -EINVAL;
> > > +
> > > +	if (((file->f_mode & FMODE_WRITE) ||
> > > +	     (!change && (mode & BLK_OPEN_WRITE))) &&
> > > +	    (!file->f_op->write_iter))
> > > +		return -EINVAL;
> > 
> > This looks a bit odd.  Both callers have the open struct file, so
> > we should be able to check f_mode for both cases and not need the
> > change flag as far as I can tell.  Or did I miss something/
> Changing flags? What are you talking about?

About the 'bool change' function argument used as a flag.

> The helper function does not pass fmode, but passes 'blk_mode_t mode',
> because it is used when executing LOOP_SET_FD or LOOP_CONFIGURE, but not
> when executing LOOP_CHANGE_FD.
> I think the purpose of this helper function is just to facilitate code
> management and facilitate similar problems later.

But you can just check file->f_mode unconditionally instead of passing
the blk_mode_t.  The BLK_OPEN_WRITE check is only needed for force
the read-only flag separately, and can be kept in the caller before
the call to the helper.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ