public inbox for ntfs3@lists.linux.dev
 help / color / mirror / Atom feed
* Re: [syzbot] kernel BUG in dnotify_free_mark
       [not found] <0000000000008b529305ec20dacc@google.com>
@ 2022-10-31 17:50 ` Jan Kara
  2022-10-31 18:18   ` Amir Goldstein
  2025-09-15  7:48 ` [syzbot] [ntfs3?] " syzbot
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kara @ 2022-10-31 17:50 UTC (permalink / raw)
  To: syzbot
  Cc: amir73il, jack, linux-fsdevel, linux-kernel, syzkaller-bugs,
	ntfs3, Konstantin Komarov, Al Viro, Christian Brauner

Hello!

[added some CCs to gather more ideas]

On Fri 28-10-22 16:45:33, syzbot wrote:
> syzbot found the following issue on:
> 
> HEAD commit:    247f34f7b803 Linux 6.1-rc2
> git tree:       upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=157f594a880000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=1d3548a4365ba17d
> dashboard link: https://syzkaller.appspot.com/bug?extid=06cc05ddc896f12b7ec5
> compiler:       Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15585936880000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14ec85ba880000
> 
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/a5f39164dea4/disk-247f34f7.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/8d1b92f5a01f/vmlinux-247f34f7.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/1a4d2943796c/mount_0.gz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+06cc05ddc896f12b7ec5@syzkaller.appspotmail.com
> 
> ------------[ cut here ]------------
> kernel BUG at fs/notify/dnotify/dnotify.c:136!

OK, I've tracked this down to the problem in ntfs3 driver or maybe more
exactly in bad inode handling. What the reproducer does is that it mounts
ntfs3 image, places dnotify mark on filesystem's /, then accesses something
which finds that / is corrupted.  This calls ntfs_bad_inode() which calls
make_bad_inode() which sets inode->i_mode to S_IFREG. So when the file
descriptor is closed, dnotify doesn't get properly shutdown because it
works only on directories. Now calling make_bad_inode() on live inode is
problematic because it can change inode type (e.g. from directory to
regular file) and that tends to confuse things - dnotify in this case.

Now it is easy to blame filesystem driver for calling make_bad_inode() on
live inode but given it seems to be relatively widespread maybe
make_bad_inode() should be more careful not to screw VFS? What do other
people think?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] kernel BUG in dnotify_free_mark
  2022-10-31 17:50 ` [syzbot] kernel BUG in dnotify_free_mark Jan Kara
@ 2022-10-31 18:18   ` Amir Goldstein
  2022-11-01 10:57     ` Jan Kara
  0 siblings, 1 reply; 4+ messages in thread
From: Amir Goldstein @ 2022-10-31 18:18 UTC (permalink / raw)
  To: Jan Kara
  Cc: syzbot, linux-fsdevel, linux-kernel, syzkaller-bugs, ntfs3,
	Konstantin Komarov, Al Viro, Christian Brauner

On Mon, Oct 31, 2022 at 7:50 PM Jan Kara <jack@suse.cz> wrote:
>
> Hello!
>
> [added some CCs to gather more ideas]
>
> On Fri 28-10-22 16:45:33, syzbot wrote:
> > syzbot found the following issue on:
> >
> > HEAD commit:    247f34f7b803 Linux 6.1-rc2
> > git tree:       upstream
> > console+strace: https://syzkaller.appspot.com/x/log.txt?x=157f594a880000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=1d3548a4365ba17d
> > dashboard link: https://syzkaller.appspot.com/bug?extid=06cc05ddc896f12b7ec5
> > compiler:       Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
> > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15585936880000
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14ec85ba880000
> >
> > Downloadable assets:
> > disk image: https://storage.googleapis.com/syzbot-assets/a5f39164dea4/disk-247f34f7.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/8d1b92f5a01f/vmlinux-247f34f7.xz
> > mounted in repro: https://storage.googleapis.com/syzbot-assets/1a4d2943796c/mount_0.gz
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+06cc05ddc896f12b7ec5@syzkaller.appspotmail.com
> >
> > ------------[ cut here ]------------
> > kernel BUG at fs/notify/dnotify/dnotify.c:136!
>
> OK, I've tracked this down to the problem in ntfs3 driver or maybe more
> exactly in bad inode handling. What the reproducer does is that it mounts
> ntfs3 image, places dnotify mark on filesystem's /, then accesses something
> which finds that / is corrupted.  This calls ntfs_bad_inode() which calls
> make_bad_inode() which sets inode->i_mode to S_IFREG. So when the file
> descriptor is closed, dnotify doesn't get properly shutdown because it
> works only on directories. Now calling make_bad_inode() on live inode is
> problematic because it can change inode type (e.g. from directory to
> regular file) and that tends to confuse things - dnotify in this case.
>
> Now it is easy to blame filesystem driver for calling make_bad_inode() on
> live inode but given it seems to be relatively widespread maybe
> make_bad_inode() should be more careful not to screw VFS? What do other
> people think?

Do you know why make_bad_inode() sets inode->i_mode to S_IFREG?
If it did not do that, would it solve the dnotify issue?

Thanks,
Amir.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] kernel BUG in dnotify_free_mark
  2022-10-31 18:18   ` Amir Goldstein
@ 2022-11-01 10:57     ` Jan Kara
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2022-11-01 10:57 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Jan Kara, syzbot, linux-fsdevel, linux-kernel, syzkaller-bugs,
	ntfs3, Konstantin Komarov, Al Viro, Christian Brauner

On Mon 31-10-22 20:18:25, Amir Goldstein wrote:
> On Mon, Oct 31, 2022 at 7:50 PM Jan Kara <jack@suse.cz> wrote:
> > [added some CCs to gather more ideas]
> >
> > On Fri 28-10-22 16:45:33, syzbot wrote:
> > > syzbot found the following issue on:
> > >
> > > HEAD commit:    247f34f7b803 Linux 6.1-rc2
> > > git tree:       upstream
> > > console+strace: https://syzkaller.appspot.com/x/log.txt?x=157f594a880000
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=1d3548a4365ba17d
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=06cc05ddc896f12b7ec5
> > > compiler:       Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
> > > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=15585936880000
> > > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14ec85ba880000
> > >
> > > Downloadable assets:
> > > disk image: https://storage.googleapis.com/syzbot-assets/a5f39164dea4/disk-247f34f7.raw.xz
> > > vmlinux: https://storage.googleapis.com/syzbot-assets/8d1b92f5a01f/vmlinux-247f34f7.xz
> > > mounted in repro: https://storage.googleapis.com/syzbot-assets/1a4d2943796c/mount_0.gz
> > >
> > > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > > Reported-by: syzbot+06cc05ddc896f12b7ec5@syzkaller.appspotmail.com
> > >
> > > ------------[ cut here ]------------
> > > kernel BUG at fs/notify/dnotify/dnotify.c:136!
> >
> > OK, I've tracked this down to the problem in ntfs3 driver or maybe more
> > exactly in bad inode handling. What the reproducer does is that it mounts
> > ntfs3 image, places dnotify mark on filesystem's /, then accesses something
> > which finds that / is corrupted.  This calls ntfs_bad_inode() which calls
> > make_bad_inode() which sets inode->i_mode to S_IFREG. So when the file
> > descriptor is closed, dnotify doesn't get properly shutdown because it
> > works only on directories. Now calling make_bad_inode() on live inode is
> > problematic because it can change inode type (e.g. from directory to
> > regular file) and that tends to confuse things - dnotify in this case.
> >
> > Now it is easy to blame filesystem driver for calling make_bad_inode() on
> > live inode but given it seems to be relatively widespread maybe
> > make_bad_inode() should be more careful not to screw VFS? What do other
> > people think?
> 
> Do you know why make_bad_inode() sets inode->i_mode to S_IFREG?

I suppose because i_mode can be set to some bogus value (e.g. when
make_bad_inode() is called while reading the inode from the disk). One idea
I had was that we'd do this setting only if i_mode was indeed invalid. But
note that make_bad_inode() also sets inode->i_op and inode->i_fop and that
can also cause some surprises for a live inode (e.g. if some concurrent
process is in the middle of some operation on the inode).

> If it did not do that, would it solve the dnotify issue?

Yes, if i_mode was kept untouched, dnotify problem would be fixed.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] [ntfs3?] kernel BUG in dnotify_free_mark
       [not found] <0000000000008b529305ec20dacc@google.com>
  2022-10-31 17:50 ` [syzbot] kernel BUG in dnotify_free_mark Jan Kara
@ 2025-09-15  7:48 ` syzbot
  1 sibling, 0 replies; 4+ messages in thread
From: syzbot @ 2025-09-15  7:48 UTC (permalink / raw)
  To: almaz.alexandrovich, amir73il, christian, hdanton, jack,
	linux-fsdevel, linux-kernel, ntfs3, syzkaller-bugs, viro, viro

syzbot suspects this issue was fixed by commit:

commit 55ad333de0f80bc0caee10c6c27196cdcf8891bb
Author: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Date:   Mon Dec 30 07:34:08 2024 +0000

    fs/ntfs3: Unify inode corruption marking with _ntfs_bad_inode()

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=15420e42580000
start commit:   fe46a7dd189e Merge tag 'sound-6.9-rc1' of git://git.kernel..
git tree:       upstream
kernel config:  https://syzkaller.appspot.com/x/.config?x=1a07d5da4eb21586
dashboard link: https://syzkaller.appspot.com/bug?extid=06cc05ddc896f12b7ec5
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=16e3dffd180000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=13f9e08d180000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: fs/ntfs3: Unify inode corruption marking with _ntfs_bad_inode()

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-15  7:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0000000000008b529305ec20dacc@google.com>
2022-10-31 17:50 ` [syzbot] kernel BUG in dnotify_free_mark Jan Kara
2022-10-31 18:18   ` Amir Goldstein
2022-11-01 10:57     ` Jan Kara
2025-09-15  7:48 ` [syzbot] [ntfs3?] " syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox