From nobody Mon Oct 6 17:06:51 2025 Received: from mail-io1-f78.google.com (mail-io1-f78.google.com [209.85.166.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A032723A563 for ; Fri, 18 Jul 2025 12:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752841930; cv=none; b=lcIuUotwR5On44shYlWZI0vGIR1pbg+ymbDLvPLxLjsR/aEJ83cPFI7gSik/FZZfvqdWouXYxn7Pnnh0yFLOudGl9lH+CJilttWYMtcpG5z1rcp3+8qmaFnAd+rnoShnpAqLqP83HNRMdzr3iOYU79rDSfmyk0XacTlT5bBDLPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752841930; c=relaxed/simple; bh=xae8LVKWg1fIHINPBQjUY4iE4WoaH2hpqNOblOGZ2og=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=HeM2JXjaewjyFC96Lt6SdhO6NojttnwDaGrBr3RgaYH8PEabHXu3tTTv7Gk5iLK+3i0b4NVVuzyI7G3A+6ktTss9FLnN7qi+/UxTGyrwu3aJe6mZYRfHcuk6FxaxljzHQT5Tw86TmzAoOq9MKk5r9TVvuW2hjGRE3AdkoUAsjJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.166.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-io1-f78.google.com with SMTP id ca18e2360f4ac-873fd6e896bso184655839f.3 for ; Fri, 18 Jul 2025 05:32:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752841927; x=1753446727; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5TvcPMcLI0cELSdG3BfYjkD2JWzixa8Vc6/unDcxz2k=; b=Mv5irUS4JE7pKPgHy48QAzE2mtbMa/UgfrT3mZeRxtuswxmmwq8/uNH/u5DrcGrGNt VneuuvN5nz4tNKGmxn3tUjjRUv4haAjjm3De6P8DboIiBFW5C5OV//dVzgc1Xx4D2stH dKVMa1hJU4qi3k8KLr38TkRznLqfF7GibZnjOtZ2KlAMQEiaoAGNk5IDM/ioWV5G5/WZ hBIe0CvlDZJaNU2LFe0jkhg5Rcpak0b/c9wYbzL2uYkRAYZ+YlCLJl83QGf85JirAvg9 UVozC7uy7rbCtTphlfqs9B+c7CjmF0av0Whc4zoOlOBgKP70jopeMXGhOPUQY9LcrUgr W0DA== X-Gm-Message-State: AOJu0YyxQP2xbDlZ+s1f+zYwa6woSwbK3FRZemh5xOJMHgJGKEUFVGPj kyiE97U80eU6w6kwSTf7M8nK2SRsJmlH4YYtZurXdwDGDbRDanlnI6XLlcRnrEbfRBrO384RKBn +nJJ0VVtE27bSMfQEudFCZkOHVa49/4l/LXBDRiDr8D3pnVhE23GauHDXvQ824w== X-Google-Smtp-Source: AGHT+IFWZwBi1dUEvhtLgq5JbRIkLqX2RZo3gKjAozXGMxhTUPVd3dvgqW6h8KzfsTBQ3vGI2SLNJFZpHp0NqNC+6dsohyXb+5iO Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6602:6ccd:b0:86c:ee8b:c088 with SMTP id ca18e2360f4ac-87c01420cf3mr734201939f.11.1752841927551; Fri, 18 Jul 2025 05:32:07 -0700 (PDT) Date: Fri, 18 Jul 2025 05:32:07 -0700 In-Reply-To: <68794b99.a70a0220.693ce.0052.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <687a3ec7.a00a0220.3af5df.002a.GAE@google.com> Subject: Forwarded: Private message regarding: [syzbot] [fs?] KASAN: use-after-free Read in hpfs_get_ea From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: Private message regarding: [syzbot] [fs?] KASAN: use-after-free Re= ad in hpfs_get_ea Author: kapoorarnav43@gmail.com #syz test=20 From: Arnav Kapoor Date: Fri, 18 Jul 2025 12:00:00 +0000 Subject: [PATCH] hpfs: fix use-after-free in hpfs_get_ea Fix a use-after-free vulnerability in hpfs_get_ea() where corrupted extended attribute data could cause strcmp() to access freed memory. The issue occurs in the EA iteration loop where next_ea() can produce invalid pointers due to insufficient validation of ea->namelen and the calculated next EA position. This can lead to accessing memory that has been freed or is outside valid boundaries. Add proper bounds checking to ensure: 1. EA namelen is reasonable (< 256) 2. EA structure doesn't exceed the EA area bounds =20 3. next_ea() result stays within valid EA boundaries Reported-by: syzbot+fa88eb476e42878f2844@syzkaller.appspotmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Arnav Kapoor Reported-by: syzbot+fa88eb...@syzkaller.appspotmail.com=20 --- fs/hpfs/ea.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c index 123456789abc..abcdef123456 100644 --- a/fs/hpfs/ea.c +++ b/fs/hpfs/ea.c @@ -135,8 +135,29 @@ char *hpfs_get_ea(struct super_block *s, struct fnode=20 *fnode, char *key, int *s secno a; struct extended_attribute *ea; struct extended_attribute *ea_end =3D fnode_end_ea(fnode); - for (ea =3D fnode_ea(fnode); ea < ea_end; ea =3D next_ea(ea)) + for (ea =3D fnode_ea(fnode); ea < ea_end; ea =3D next_ea(ea)) { + /* Validate EA structure bounds */ + if ((char *)ea + sizeof(*ea) > (char *)ea_end) { + hpfs_error(s, "EA structure exceeds bounds"); + return NULL; + } +=20 + /* Validate namelen to prevent overflow */ + if (ea->namelen >=3D 256) { + hpfs_error(s, "EA namelen too large: %d", ea->namelen); + return NULL; + } +=20 + /* Ensure name field is within bounds */ + if ((char *)ea + 5 + ea->namelen > (char *)ea_end) { + hpfs_error(s, "EA name field exceeds bounds"); + return NULL; + } +=20 + /* Validate next_ea() result will be within bounds */ + if (next_ea(ea) > ea_end) { + hpfs_error(s, "next EA exceeds bounds"); + return NULL; + } +=20 if (!strcmp(ea->name, key)) { if (ea_indirect(ea)) return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size =3D=20 ea_len(ea)); @@ -147,6 +168,7 @@ char *hpfs_get_ea(struct super_block *s, struct fnode=20 *fnode, char *key, int *s memcpy(ret, ea_data(ea), ea_valuelen(ea)); ret[ea_valuelen(ea)] =3D 0; return ret; + } } a =3D le32_to_cpu(fnode->ea_secno); len =3D le32_to_cpu(fnode->ea_size_l); On Friday, 18 July 2025 at 00:44:34 UTC+5:30 syzbot wrote: Hello,=20 syzbot found the following issue on:=20 HEAD commit: 155a3c003e55 Merge tag 'for-6.16/dm-fixes-2' of git://git...=20 git tree: upstream=20 console+strace: https://syzkaller.appspot.com/x/log.txt?x=3D166d6382580000=20 kernel config: https://syzkaller.appspot.com/x/.config?x=3Df09d04131ef56b22=20 dashboard link: https://syzkaller.appspot.com/bug?extid=3Dfa88eb476e42878f2= 844=20 compiler: Debian clang version 20.1.7=20 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD=20 20.1.7=20 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=3D14b20d8c580000=20 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=3D16ebe58c580000=20 Downloadable assets:=20 disk image:=20 https://storage.googleapis.com/syzbot-assets/8b4489a1d2de/disk-155a3c00.raw= .xz=20 vmlinux:=20 https://storage.googleapis.com/syzbot-assets/1c498d4c0c85/vmlinux-155a3c00.= xz=20 kernel image:=20 https://storage.googleapis.com/syzbot-assets/ea8acdf1d890/bzImage-155a3c00.= xz=20 mounted in repro:=20 https://storage.googleapis.com/syzbot-assets/e47f2d7541be/mount_0.gz=20 IMPORTANT: if you fix the issue, please add the following tag to the=20 commit:=20 Reported-by: syzbot+fa88eb...@syzkaller.appspotmail.com=20 hpfs: filesystem error: warning: spare dnodes used, try chkdsk=20 hpfs: You really don't want any checks? You are crazy...=20 hpfs: hpfs_map_sector(): read error=20 hpfs: code page support is disabled=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20 BUG: KASAN: use-after-free in strcmp+0x6f/0xc0 lib/string.c:283=20 Read of size 1 at addr ffff8880116728a6 by task syz-executor411/6741=20 CPU: 1 UID: 0 PID: 6741 Comm: syz-executor411 Not tainted=20 6.16.0-rc6-syzkaller-00002-g155a3c003e55 #0 PREEMPT(full)=20 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS=20 Google 05/07/2025=20 Call Trace:=20 =20 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120=20 print_address_description mm/kasan/report.c:378 [inline]=20 print_report+0xca/0x230 mm/kasan/report.c:480=20 kasan_report+0x118/0x150 mm/kasan/report.c:593=20 strcmp+0x6f/0xc0 lib/string.c:283=20 hpfs_get_ea+0x114/0xdb0 fs/hpfs/ea.c:139=20 hpfs_read_inode+0x19d/0x1010 fs/hpfs/inode.c:63=20 hpfs_fill_super+0x12bd/0x2070 fs/hpfs/super.c:654=20 get_tree_bdev_flags+0x40e/0x4d0 fs/super.c:1681=20 vfs_get_tree+0x92/0x2b0 fs/super.c:1804=20 do_new_mount+0x24a/0xa40 fs/namespace.c:3902=20 do_mount fs/namespace.c:4239 [inline]=20 __do_sys_mount fs/namespace.c:4450 [inline]=20 __se_sys_mount+0x317/0x410 fs/namespace.c:4427=20 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]=20 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94=20 entry_SYSCALL_64_after_hwframe+0x77/0x7f=20 RIP: 0033:0x7f718b86112a=20 Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 5e 04 00 00 66 2e 0f 1f 84=20 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff=20 ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48=20 RSP: 002b:00007ffee99fcba8 EFLAGS: 00000286 ORIG_RAX: 00000000000000a5=20 RAX: ffffffffffffffda RBX: 00007ffee99fcbc0 RCX: 00007f718b86112a=20 RDX: 0000200000009e80 RSI: 0000200000009ec0 RDI: 00007ffee99fcbc0=20 RBP: 0000200000009ec0 R08: 00007ffee99fcc00 R09: 0000000000009dfd=20 R10: 0000000000000041 R11: 0000000000000286 R12: 0000200000009e80=20 R13: 0000000000000004 R14: 0000000000000003 R15: 00007ffee99fcc00=20 =20 The buggy address belongs to the physical page:=20 page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11672=20 flags: 0xfff00000000000(node=3D0|zone=3D1|lastcpupid=3D0x7ff)=20 raw: 00fff00000000000 ffffea0001ff38c8 ffffea0001ff3908 0000000000000000=20 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000=20 page dumped because: kasan: bad access detected=20 page_owner tracks the page as freed=20 page last allocated via order 0, migratetype Movable, gfp_mask=20 0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), pid 5213, tgid 5213 (udevd), ts=20 38150701195, free_ts 195740390996=20 set_page_owner include/linux/page_owner.h:32 [inline]=20 post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1704=20 prep_new_page mm/page_alloc.c:1712 [inline]=20 get_page_from_freelist+0x21d5/0x22b0 mm/page_alloc.c:3669=20 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4959=20 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2419=20 folio_alloc_mpol_noprof+0x39/0x70 mm/mempolicy.c:2438=20 shmem_alloc_folio mm/shmem.c:1851 [inline]=20 shmem_alloc_and_add_folio+0x447/0xf60 mm/shmem.c:1890=20 shmem_get_folio_gfp+0x59d/0x1660 mm/shmem.c:2536=20 shmem_get_folio mm/shmem.c:2642 [inline]=20 shmem_write_begin+0xf7/0x2b0 mm/shmem.c:3292=20 generic_perform_write+0x2c7/0x910 mm/filemap.c:4112=20 shmem_file_write_iter+0xf8/0x120 mm/shmem.c:3467=20 new_sync_write fs/read_write.c:593 [inline]=20 vfs_write+0x54b/0xa90 fs/read_write.c:686=20 ksys_write+0x145/0x250 fs/read_write.c:738=20 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]=20 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94=20 entry_SYSCALL_64_after_hwframe+0x77/0x7f=20 page last free pid 6740 tgid 6740 stack trace:=20 reset_page_owner include/linux/page_owner.h:25 [inline]=20 free_pages_prepare mm/page_alloc.c:1248 [inline]=20 free_unref_folios+0xcd2/0x1570 mm/page_alloc.c:2763=20 folios_put_refs+0x559/0x640 mm/swap.c:992=20 folio_batch_release include/linux/pagevec.h:101 [inline]=20 shmem_undo_range+0x49e/0x14b0 mm/shmem.c:1125=20 shmem_truncate_range mm/shmem.c:1237 [inline]=20 shmem_evict_inode+0x272/0xa70 mm/shmem.c:1365=20 evict+0x501/0x9c0 fs/inode.c:810=20 __dentry_kill+0x209/0x660 fs/dcache.c:669=20 shrink_kill+0xa9/0x2c0 fs/dcache.c:1114=20 shrink_dentry_list+0x2e0/0x5e0 fs/dcache.c:1141=20 shrink_dcache_parent+0xa1/0x2c0 fs/dcache.c:-1=20 do_one_tree+0x23/0xe0 fs/dcache.c:1604=20 shrink_dcache_for_umount+0xa0/0x170 fs/dcache.c:1621=20 generic_shutdown_super+0x67/0x2c0 fs/super.c:621=20 kill_anon_super fs/super.c:1282 [inline]=20 kill_litter_super+0x76/0xb0 fs/super.c:1292=20 deactivate_locked_super+0xbc/0x130 fs/super.c:474=20 cleanup_mnt+0x425/0x4c0 fs/namespace.c:1417=20 task_work_run+0x1d4/0x260 kernel/task_work.c:227=20 Memory state around the buggy address:=20 ffff888011672780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff=20 ffff888011672800: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff=20 >ffff888011672880: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff=20 ^=20 ffff888011672900: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff=20 ffff888011672980: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20 ---=20 This report is generated by a bot. It may contain errors.=20 See https://goo.gl/tpsmEJ for more information about syzbot.=20 syzbot engineers can be reached at syzk...@googlegroups.com.=20 syzbot will keep track of this issue. See:=20 https://goo.gl/tpsmEJ#status for how to communicate with syzbot.=20 If the report is already addressed, let syzbot know by replying with:=20 #syz fix: exact-commit-title=20 If you want syzbot to run the reproducer, reply with:=20 #syz test: git://repo/address.git branch-or-commit-hash=20 If you attach or paste a git patch, syzbot will apply it before testing.=20 If you want to overwrite report's subsystems, reply with:=20 #syz set subsystems: new-subsystem=20 (See the list of subsystem names on the web dashboard)=20 If the report is a duplicate of another one, reply with:=20 #syz dup: exact-subject-of-another-report=20 If you want to undo deduplication, reply with:=20 #syz undup