linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Vyukov <dvyukov@google.com>
To: syzbot <syzbot+ec4650f158c91a963120@syzkaller.appspotmail.com>
Cc: akpm@linux-foundation.org, hughd@google.com,
	linux-fsdevel@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-mm@kvack.org,  syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [mm?] [fs?] KCSAN: data-race in __filemap_remove_folio / shmem_get_folio_gfp
Date: Mon, 24 Apr 2023 09:48:37 +0200	[thread overview]
Message-ID: <CACT4Y+aGqEb-Z9JOR0eccoL9cw2BYZVspTJfB_33y=Q_+PO4QA@mail.gmail.com> (raw)
In-Reply-To: <000000000000fb55ed05fa0fdb4b@google.com>

On Mon, 24 Apr 2023 at 09:21, syzbot
<syzbot+ec4650f158c91a963120@syzkaller.appspotmail.com> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit:    cb0856346a60 Merge tag 'mm-hotfixes-stable-2023-04-19-16-3..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=170802cfc80000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=fa4baf7c6b35b5d5
> dashboard link: https://syzkaller.appspot.com/bug?extid=ec4650f158c91a963120
> 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/a02dd7789fb2/disk-cb085634.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/a1a1eac454f6/vmlinux-cb085634.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/bb0447014913/bzImage-cb085634.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+ec4650f158c91a963120@syzkaller.appspotmail.com

shmem_recalc_inode() has a check for "freed > 0", but I think it can
be violated due to this race, if i_mapping->nrpages is read twice. If
there are concurrent modifications, the code should use at least
READ/WRITE_ONCE for accesses.

> ==================================================================
> BUG: KCSAN: data-race in __filemap_remove_folio / shmem_get_folio_gfp
>
> read-write to 0xffff888136bf8960 of 8 bytes by task 19402 on cpu 1:
>  page_cache_delete mm/filemap.c:147 [inline]
>  __filemap_remove_folio+0x22f/0x330 mm/filemap.c:225
>  filemap_remove_folio+0x6c/0x220 mm/filemap.c:257
>  truncate_inode_folio+0x19f/0x1e0 mm/truncate.c:196
>  shmem_undo_range+0x24d/0xc20 mm/shmem.c:942
>  shmem_truncate_range mm/shmem.c:1041 [inline]
>  shmem_fallocate+0x2fc/0x8d0 mm/shmem.c:2779
>  vfs_fallocate+0x369/0x3d0 fs/open.c:324
>  madvise_remove mm/madvise.c:1001 [inline]
>  madvise_vma_behavior mm/madvise.c:1025 [inline]
>  madvise_walk_vmas mm/madvise.c:1260 [inline]
>  do_madvise+0x77b/0x28a0 mm/madvise.c:1439
>  __do_sys_madvise mm/madvise.c:1452 [inline]
>  __se_sys_madvise mm/madvise.c:1450 [inline]
>  __x64_sys_madvise+0x60/0x70 mm/madvise.c:1450
>  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 0xffff888136bf8960 of 8 bytes by task 19400 on cpu 0:
>  shmem_recalc_inode mm/shmem.c:359 [inline]
>  shmem_get_folio_gfp+0xc0a/0x1120 mm/shmem.c:1977
>  shmem_fault+0xd9/0x3d0 mm/shmem.c:2152
>  __do_fault mm/memory.c:4155 [inline]
>  do_read_fault mm/memory.c:4506 [inline]
>  do_fault mm/memory.c:4635 [inline]
>  handle_pte_fault mm/memory.c:4923 [inline]
>  __handle_mm_fault mm/memory.c:5065 [inline]
>  handle_mm_fault+0x115d/0x21d0 mm/memory.c:5211
>  faultin_page mm/gup.c:925 [inline]
>  __get_user_pages+0x363/0xc30 mm/gup.c:1147
>  populate_vma_page_range mm/gup.c:1543 [inline]
>  __mm_populate+0x23a/0x360 mm/gup.c:1652
>  mm_populate include/linux/mm.h:3026 [inline]
>  vm_mmap_pgoff+0x174/0x210 mm/util.c:547
>  ksys_mmap_pgoff+0xc5/0x320 mm/mmap.c:1410
>  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
>
> value changed: 0x0000000000000437 -> 0x0000000000000430
>
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 0 PID: 19400 Comm: syz-executor.3 Not tainted 6.3.0-rc7-syzkaller-00089-gcb0856346a60 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/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/000000000000fb55ed05fa0fdb4b%40google.com.


      reply	other threads:[~2023-04-24  7:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  7:21 syzbot
2023-04-24  7:48 ` Dmitry Vyukov [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='CACT4Y+aGqEb-Z9JOR0eccoL9cw2BYZVspTJfB_33y=Q_+PO4QA@mail.gmail.com' \
    --to=dvyukov@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=syzbot+ec4650f158c91a963120@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