Re: [syzbot] [ext4?] KCSAN: data-race in __es_find_extent_range / __es_find_extent_range (6)

From: Jan Kara
Date: Wed May 03 2023 - 13:43:08 EST


On Mon 24-04-23 09:27:00, Dmitry Vyukov wrote:
> On Mon, 24 Apr 2023 at 09:19, syzbot
> <syzbot+4a03518df1e31b537066@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit: 44149752e998 Merge tag 'cgroup-for-6.3-rc6-fixes' of git:/..
> > git tree: upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=100db37bc80000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=710057cbb8def08c
> > dashboard link: https://syzkaller.appspot.com/bug?extid=4a03518df1e31b537066
> > 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/7bfa303f05cc/disk-44149752.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/4e8ea8730409/vmlinux-44149752.xz
> > kernel image: https://storage.googleapis.com/syzbot-assets/e584bce13ba7/bzImage-44149752.xz
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+4a03518df1e31b537066@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> The race is here:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/ext4/extents_status.c?id=44149752e9987a9eac5ad78e6d3a20934b5e018d#n271
>
> If I am reading this correctly, it can lead to returning a wrong
> extent if tree->cache_es is re-read after the range check.
> I think tree->cache_es read/write should use READ/WRITE_ONCE.

Right. I'll send a fix.

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR