Reiserfs development archive or lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Ts'o" <tytso@mit.edu>
To: syzbot <syzbot+5407ecf3112f882d2ef3@syzkaller.appspotmail.com>
Cc: adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	reiserfs-devel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [ext4?] KASAN: slab-use-after-free Read in __ext4_iget
Date: Thu, 29 Jun 2023 00:28:39 -0400	[thread overview]
Message-ID: <20230629042839.GK8954@mit.edu> (raw)
In-Reply-To: <000000000000ddfe0405fd7ef847@google.com>

#syz set subsystems: fs, reiserfs

On Tue, Jun 06, 2023 at 05:11:06PM -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    a4d7d7011219 Merge tag 'spi-fix-v6.4-rc5' of git://git.ker..
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1455f745280000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=7474de833c217bf4
> dashboard link: https://syzkaller.appspot.com/bug?extid=5407ecf3112f882d2ef3
> compiler:       Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

The stack traces on this are... intersting.  The use-after free is
coming when ext4_fill_super() tries to get the root inode, via
iget_locked(sb, EXT2_ROOT_INO)

> BUG: KASAN: slab-use-after-free in __ext4_iget+0x2f2/0x3f30 fs/ext4/inode.c:4700
> Read of size 8 at addr ffff888078ca5550 by task syz-executor.5/26112
	...
>  __ext4_iget+0x2f2/0x3f30 fs/ext4/inode.c:4700
>  __ext4_fill_super fs/ext4/super.c:5446 [inline]
>  ext4_fill_super+0x545b/0x6c60 fs/ext4/super.c:5672

However, we are getting back an object which is freed, and which was
originally allocated by reiserfs(!):

> Allocated by task 20729:
>  kasan_save_stack mm/kasan/common.c:45 [inline]
>  kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
>  __kasan_slab_alloc+0x66/0x70 mm/kasan/common.c:328
>  kasan_slab_alloc include/linux/kasan.h:186 [inline]
>  slab_post_alloc_hook+0x68/0x3a0 mm/slab.h:711
>  slab_alloc_node mm/slub.c:3451 [inline]
>  slab_alloc mm/slub.c:3459 [inline]
>  __kmem_cache_alloc_lru mm/slub.c:3466 [inline]
>  kmem_cache_alloc_lru+0x11f/0x2e0 mm/slub.c:3482
>  alloc_inode_sb include/linux/fs.h:2705 [inline]
>  reiserfs_alloc_inode+0x2a/0xc0 fs/reiserfs/super.c:642
>  alloc_inode fs/inode.c:260 [inline]
>  iget5_locked+0xa0/0x270 fs/inode.c:1241
>  reiserfs_fill_super+0x12e4/0x2620 fs/reiserfs/super.c:2053
>  mount_bdev+0x2d0/0x3f0 fs/super.c:1380

There is no reproducer, but it seems to be triggering quite frequently
(over once day --- 20 times since June 16, 2023 as of this writing).
I've checked a number of the reports in the Syzkaller dashboard, and
they are all quite similar; somehow ext4 is getting an inode which is
freed, and whose memory was originally allocated by reiserfs.

I'm not sure if this is a reiserfs bug or a core VFS bug, since this
seems to imply that an an old reiserfs inode was left on the
inode_hashtable when a reiserfs file system was unmounted, and then
the struct super was reused and returned for a fresh ext4 mount, and
then when ext4 tried do an iget_locked(), it got the reserifs inode.

That reiserfs inode was either freed and left on the inode_hashtable,
or lifetime of the reiserfs root inode was allowed to last longer than
the reiserfs superblock (maybe someone is playing RCU games?) and so
since it was left on the inode_hashtable, the attempt to free reiserfs
root inode raced with ext4's attempt to fetch the ext4 inode via
iget_locked().

Perhaps one of the VFS or reiserfs maintainers could take a look?

       	       	  	   	      	       - Ted

           reply	other threads:[~2023-06-29  4:28 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <000000000000ddfe0405fd7ef847@google.com>]

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=20230629042839.GK8954@mit.edu \
    --to=tytso@mit.edu \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=syzbot+5407ecf3112f882d2ef3@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).