mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: syzbot <syzbot+4a06d4373fd52f0b2f9c@syzkaller.appspotmail.com>,
	amir73il@gmail.com, jack@suse.cz, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [fs?] KCSAN: data-race in inotify_handle_inode_event / inotify_remove_from_idr
Date: Mon, 24 Apr 2023 15:54:57 +0200	[thread overview]
Message-ID: <20230424135457.i6lmrznccvwv75up@quack3> (raw)
In-Reply-To: <CACT4Y+arm0wqa=GbrTpH4UJrc-OCq3dwvTKa9k-yxoPLtwnbHQ@mail.gmail.com>

On Mon 24-04-23 10:27:46, Dmitry Vyukov wrote:
> On Mon, 24 Apr 2023 at 10:09, syzbot
> <syzbot+4a06d4373fd52f0b2f9c@syzkaller.appspotmail.com> wrote:
> >
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit:    622322f53c6d Merge tag 'mips-fixes_6.3_2' of git://git.ker..
> > git tree:       upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=1482ffafc80000
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=fa4baf7c6b35b5d5
> > dashboard link: https://syzkaller.appspot.com/bug?extid=4a06d4373fd52f0b2f9c
> > compiler:       Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
> >
> > Unfortunately, I don't have any reproducer for this issue yet.
> >
> > Downloadable assets:
> > disk image: https://storage.googleapis.com/syzbot-assets/8b5f31d96315/disk-622322f5.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/adca7dc8daae/vmlinux-622322f5.xz
> > kernel image: https://storage.googleapis.com/syzbot-assets/ed78ddc31ccb/bzImage-622322f5.xz
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+4a06d4373fd52f0b2f9c@syzkaller.appspotmail.com
> 
> If I am reading this correctly, userspace can get wd=-1 as the result
> of this race. Docs say wd must refer to a previously allocated
> descriptor, which is positive. I don't see any mentions of semantics
> of wd=-1.

Yeah, indeed this looks like a possible race when we detach the mark just
while we are generating the event. I'll send a fix.

								Honza

> > ==================================================================
> > BUG: KCSAN: data-race in inotify_handle_inode_event / inotify_remove_from_idr
> >
> > write to 0xffff888104e31368 of 4 bytes by task 3229 on cpu 1:
> >  inotify_remove_from_idr+0x106/0x310 fs/notify/inotify/inotify_user.c:511
> >  inotify_ignored_and_remove_idr+0x34/0x60 fs/notify/inotify/inotify_user.c:532
> >  inotify_freeing_mark+0x1d/0x30 fs/notify/inotify/inotify_fsnotify.c:133
> >  fsnotify_free_mark fs/notify/mark.c:490 [inline]
> >  fsnotify_destroy_mark+0x17a/0x190 fs/notify/mark.c:499
> >  __do_sys_inotify_rm_watch fs/notify/inotify/inotify_user.c:817 [inline]
> >  __se_sys_inotify_rm_watch+0xf7/0x170 fs/notify/inotify/inotify_user.c:794
> >  __x64_sys_inotify_rm_watch+0x31/0x40 fs/notify/inotify/inotify_user.c:794
> >  do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> >  do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
> >  entry_SYSCALL_64_after_hwframe+0x63/0xcd
> >
> > read to 0xffff888104e31368 of 4 bytes by task 3638 on cpu 0:
> >  inotify_handle_inode_event+0x17e/0x2c0 fs/notify/inotify/inotify_fsnotify.c:113
> >  fsnotify_handle_inode_event+0x19b/0x1f0 fs/notify/fsnotify.c:264
> >  fsnotify_handle_event fs/notify/fsnotify.c:316 [inline]
> >  send_to_group fs/notify/fsnotify.c:364 [inline]
> >  fsnotify+0x101c/0x1150 fs/notify/fsnotify.c:570
> >  __fsnotify_parent+0x307/0x480 fs/notify/fsnotify.c:230
> >  fsnotify_parent include/linux/fsnotify.h:77 [inline]
> >  fsnotify_file include/linux/fsnotify.h:99 [inline]
> >  fsnotify_close include/linux/fsnotify.h:341 [inline]
> >  __fput+0x4b0/0x570 fs/file_table.c:307
> >  ____fput+0x15/0x20 fs/file_table.c:349
> >  task_work_run+0x123/0x160 kernel/task_work.c:179
> >  resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
> >  exit_to_user_mode_loop+0xd1/0xe0 kernel/entry/common.c:171
> >  exit_to_user_mode_prepare+0x6c/0xb0 kernel/entry/common.c:204
> >  __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
> >  syscall_exit_to_user_mode+0x26/0x140 kernel/entry/common.c:297
> >  do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86
> >  entry_SYSCALL_64_after_hwframe+0x63/0xcd
> >
> > value changed: 0x00000060 -> 0xffffffff
> >
> > Reported by Kernel Concurrency Sanitizer on:
> > CPU: 0 PID: 3638 Comm: syz-executor.0 Not tainted 6.3.0-rc7-syzkaller-00191-g622322f53c6d #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/14/2023
> > ==================================================================
> >
> >
> > ---
> > This report is generated by a bot. It may contain errors.
> > See https://goo.gl/tpsmEJ for more information about syzbot.
> > syzbot engineers can be reached at syzkaller@googlegroups.com.
> >
> > syzbot will keep track of this issue. See:
> > https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/000000000000c2e89505fa108749%40google.com.
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2023-04-24 13:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  8:09 syzbot
2023-04-24  8:27 ` Dmitry Vyukov
2023-04-24 13:54   ` Jan Kara [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=20230424135457.i6lmrznccvwv75up@quack3 \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=dvyukov@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+4a06d4373fd52f0b2f9c@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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®