Re: [PATCH] loop: Add sanity check for read/write_iter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 25 Apr 2025 12:20:21 +0800, Ming Lei <ming.lei@xxxxxxxxxx> wrote:
> > Some file systems do not support read_iter or write_iter, such as selinuxfs
> > in this issue.
> > So before calling them, first confirm that the interface is supported and
> > then call it.
> >
> > Reported-by: syzbot+6af973a3b8dfd2faefdc@xxxxxxxxxxxxxxxxxxxxxxxxx
> > Closes: https://syzkaller.appspot.com/bug?extid=6af973a3b8dfd2faefdc
> > Signed-off-by: Lizhi Xu <lizhi.xu@xxxxxxxxxxxxx>
> > ---
> >  drivers/block/loop.c | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > 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))
> > +                       ret = file->f_op->read_iter(&cmd->iocb, &iter);
> > +       }
> 
> The check can be added in loop_configure()/loop_change_fd()
> instead of fast IO path.
Yes, you are right, I will test and send V2 patch.

BR,
Lizhi





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux