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: <20250425041939.3388803-1-lizhi.xu@windriver.com>
Date: Fri, 25 Apr 2025 12:19:39 +0800
From: Lizhi Xu <lizhi.xu@...driver.com>
To: <yanjun.zhu@...ux.dev>
CC: <axboe@...nel.dk>, <linux-block@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <lizhi.xu@...driver.com>,
        <syzbot+6af973a3b8dfd2faefdc@...kaller.appspotmail.com>,
        <syzkaller-bugs@...glegroups.com>
Subject: Re: [PATCH] loop: Add sanity check for read/write_iter

On Fri, 25 Apr 2025 06:06:51 +0200, Zhu Yanjun wrote:
> > diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> > index 674527d770dc..4f968e3071ed 100644
> > --- a/drivers/block/loop.c
> > +++ b/drivers/block/loop.c
> > @@ -449,10 +449,15 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
> >       cmd->iocb.ki_flags = IOCB_DIRECT;
> >       cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
> >
> > -     if (rw == ITER_SOURCE)
> > -             ret = file->f_op->write_iter(&cmd->iocb, &iter);
> > -     else
> > -             ret = file->f_op->read_iter(&cmd->iocb, &iter);
> > +     ret = 0;
> > +     if (rw == ITER_SOURCE) {
> > +             if (likely(file->f_op->write_iter))
> > +                     ret = file->f_op->write_iter(&cmd->iocb, &iter);
> > +     }
> > +     else {
> > +             if (likely(file->f_op->read_iter))
> 
> "else if" is better?
There is nothing wrong with writing it this way logically, but it will
destroy the clarity of the original context regarding the read/write logical
relationship.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ