mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: Ryusuke Konishi <konishi.ryusuke@gmail.com>,
	Joshua Crofts <joshua.crofts1@gmail.com>
Cc: linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	 syzbot+cae54346a70bbceeff2c@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] nilfs2: fix infinite loop in nilfs_clean_segments()
Date: Tue, 28 Jul 2026 16:43:22 -0700	[thread overview]
Message-ID: <cec4c380ffb60c6bbb3ee2a49394d53bab8ee5cc.camel@dubeyko.com> (raw)
In-Reply-To: <CAKFNMome_9P59vdiP0=kS33H3qKJCNVL--SE7tR1rsUJajBETw@mail.gmail.com>

On Fri, 2026-07-17 at 22:30 +0900, Ryusuke Konishi wrote:
> On Fri, Jul 17, 2026 at 7:59 PM Joshua Crofts wrote:
> > 
> > syzbot reported a hung task in nilfs_transaction_begin(). This
> > occurs
> > because the cleaner ioctl falls into an infinite loop if
> > nilfs_segctor_construct() repeatedly returns -EROFS (e.g. the
> > device
> > is remounted as read-only after an I/O error).
> > 
> > Currently in nilfs_clean_segments(), if err is non-zero, it logs
> > the
> > error and sleeps but doesn't abort when it encounters a terminal
> > error
> > like -EROFS. This causes the thread to loop forever.
> > 
> > Fix this by breaking out of the loop if nilfs_segctor_construct()
> > returns -EROFS. This matches the behaviour in
> > nilfs_segctor_write_out(), which also handles -EROFS.
> > 
> > Reported-by: syzbot+cae54346a70bbceeff2c@syzkaller.appspotmail.com
> > Closes:
> > https://syzkaller.appspot.com/bug?extid=cae54346a70bbceeff2c
> > Fixes: 9ff05123e3bf ("nilfs2: segment constructor")
> > Assisted-by: gemini:gemini-3.1-pro
> > Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
> > ---
> > Changes in v2:
> > - use `goto out_unlock` instead of break to prevent discard
> > commands
> >   from being sent
> > 
> > As much as I've tried, syzbot is unable to test this and always
> > fails
> > with "FATAL: Kernel too old". Nevertheless, I've tested the patch
> > with
> > the same reproducer in QEMU and the system didn't hang.
> > ---
> >  fs/nilfs2/segment.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
> > index 9332f5ac6..218926789 100644
> > --- a/fs/nilfs2/segment.c
> > +++ b/fs/nilfs2/segment.c
> > @@ -2561,6 +2561,10 @@ int nilfs_clean_segments(struct super_block
> > *sb, struct nilfs_argv *argv,
> >                         break;
> > 
> >                 nilfs_warn(sb, "error %d cleaning segments", err);
> > +
> > +               if (unlikely(err == -EROFS))
> > +                       goto out_unlock;
> > +
> >                 set_current_state(TASK_INTERRUPTIBLE);
> >                 schedule_timeout(sci->sc_interval);
> >         }
> > --
> > 2.47.3
> 
> Looks good.
> 
> Viacheslav, could you please pick this up for your queue?
> 
> Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
> 
> 

Applied.

Thanks,
Slava.

      reply	other threads:[~2026-07-28 23:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 10:58 Joshua Crofts
2026-07-17 13:30 ` Ryusuke Konishi
2026-07-28 23:43   ` Viacheslav Dubeyko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cec4c380ffb60c6bbb3ee2a49394d53bab8ee5cc.camel@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=konishi.ryusuke@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=syzbot+cae54346a70bbceeff2c@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®