All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
@ 2024-02-01 15:17 syzbot
  0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2024-02-01 15:17 UTC (permalink / raw)
  To: almaz.alexandrovich, linux-fsdevel, linux-kernel, ntfs3,
	syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    8a696a29c690 Merge tag 'platform-drivers-x86-v6.8-2' of gi..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16753f17e80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=9247001bfee478be
dashboard link: https://syzkaller.appspot.com/bug?extid=a426cde6dee8c2884b0b
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=12c4efc3e80000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16a562f3e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/e52b675ecac5/disk-8a696a29.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/4fc98d5eb84b/vmlinux-8a696a29.xz
kernel image: https://storage.googleapis.com/syzbot-assets/5d4769a0b908/bzImage-8a696a29.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/d57d4609374b/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+a426cde6dee8c2884b0b@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: slab-out-of-bounds in mi_enum_attr+0x850/0x9e0 fs/ntfs3/record.c:246
Read of size 4 at addr ffff88807483335d by task syz-executor171/9769

CPU: 0 PID: 9769 Comm: syz-executor171 Not tainted 6.8.0-rc1-syzkaller-00356-g8a696a29c690 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x163/0x540 mm/kasan/report.c:488
 kasan_report+0x142/0x170 mm/kasan/report.c:601
 mi_enum_attr+0x850/0x9e0 fs/ntfs3/record.c:246
 mi_find_attr+0x1c5/0x2b0 fs/ntfs3/record.c:353
 ni_find_attr+0x609/0x8d0 fs/ntfs3/frecord.c:218
 ntfs_readlink_hlp+0xa6/0xcb0 fs/ntfs3/inode.c:1922
 ntfs_get_link+0x79/0x110 fs/ntfs3/inode.c:2068
 pick_link+0x638/0xd70
 step_into+0xc9f/0x1080 fs/namei.c:1871
 open_last_lookups fs/namei.c:3588 [inline]
 path_openat+0x187c/0x31e0 fs/namei.c:3795
 do_filp_open+0x234/0x490 fs/namei.c:3825
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1404
 do_sys_open fs/open.c:1419 [inline]
 __do_sys_open fs/open.c:1427 [inline]
 __se_sys_open fs/open.c:1423 [inline]
 __x64_sys_open+0x225/0x270 fs/open.c:1423
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f1b33964c19
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 81 1d 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f1b338d3218 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 00007f1b33a06708 RCX: 00007f1b33964c19
RDX: 0000000000000065 RSI: 0000000000000080 RDI: 0000000020000440
RBP: 0000000000000020 R08: 0000000000000000 R09: 0000000000000000
R10: 00007ffcb7e5f0f7 R11: 0000000000000246 R12: 00007f1b33a06700
R13: 00007f1b339d2024 R14: 0030656c69662f2e R15: 0031656c69662f2e
 </TASK>

Allocated by task 5096:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x70 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:372 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:389
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slub.c:3981 [inline]
 __kmalloc+0x22e/0x490 mm/slub.c:3994
 kmalloc include/linux/slab.h:594 [inline]
 tomoyo_realpath_from_path+0xcf/0x5e0 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x2b7/0x730 security/tomoyo/file.c:822
 security_inode_getattr+0xd3/0x120 security/security.c:2237
 vfs_getattr+0x46/0x430 fs/stat.c:173
 vfs_statx+0x1a5/0x4e0 fs/stat.c:248
 vfs_fstatat+0x135/0x190 fs/stat.c:304
 __do_sys_newfstatat fs/stat.c:468 [inline]
 __se_sys_newfstatat fs/stat.c:462 [inline]
 __x64_sys_newfstatat+0x117/0x190 fs/stat.c:462
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Freed by task 5096:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x70 mm/kasan/common.c:68
 kasan_save_free_info+0x4e/0x60 mm/kasan/generic.c:640
 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:241
 __kasan_slab_free+0x34/0x60 mm/kasan/common.c:257
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2121 [inline]
 slab_free mm/slub.c:4299 [inline]
 kfree+0x14a/0x380 mm/slub.c:4409
 tomoyo_realpath_from_path+0x5a3/0x5e0 security/tomoyo/realpath.c:286
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x2b7/0x730 security/tomoyo/file.c:822
 security_inode_getattr+0xd3/0x120 security/security.c:2237
 vfs_getattr+0x46/0x430 fs/stat.c:173
 vfs_statx+0x1a5/0x4e0 fs/stat.c:248
 vfs_fstatat+0x135/0x190 fs/stat.c:304
 __do_sys_newfstatat fs/stat.c:468 [inline]
 __se_sys_newfstatat fs/stat.c:462 [inline]
 __x64_sys_newfstatat+0x117/0x190 fs/stat.c:462
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

The buggy address belongs to the object at ffff888074832000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 861 bytes to the right of
 allocated 4096-byte region [ffff888074832000, ffff888074833000)

The buggy address belongs to the physical page:
page:ffffea0001d20c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x74830
head:ffffea0001d20c00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888013042140 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4500, tgid 4500 (udevd), ts 828902194240, free_ts 828781426813
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0x33ea/0x3570 mm/page_alloc.c:3311
 __alloc_pages+0x255/0x680 mm/page_alloc.c:4567
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page+0x5f/0x160 mm/slub.c:2190
 allocate_slab mm/slub.c:2354 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2407
 ___slab_alloc+0xd17/0x13d0 mm/slub.c:3540
 __slab_alloc mm/slub.c:3625 [inline]
 __slab_alloc_node mm/slub.c:3678 [inline]
 slab_alloc_node mm/slub.c:3850 [inline]
 __do_kmalloc_node mm/slub.c:3980 [inline]
 __kmalloc+0x2dc/0x490 mm/slub.c:3994
 kmalloc include/linux/slab.h:594 [inline]
 tomoyo_realpath_from_path+0xcf/0x5e0 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x255/0x500 security/tomoyo/file.c:771
 security_file_open+0x66/0x560 security/security.c:2932
 do_dentry_open+0x327/0x1590 fs/open.c:940
 do_open fs/namei.c:3641 [inline]
 path_openat+0x2823/0x31e0 fs/namei.c:3798
 do_filp_open+0x234/0x490 fs/namei.c:3825
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1404
 do_sys_open fs/open.c:1419 [inline]
 __do_sys_openat fs/open.c:1435 [inline]
 __se_sys_openat fs/open.c:1430 [inline]
 __x64_sys_openat+0x247/0x290 fs/open.c:1430
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
page last free pid 4500 tgid 4500 stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1140 [inline]
 free_unref_page_prepare+0x959/0xa80 mm/page_alloc.c:2346
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486
 discard_slab mm/slub.c:2453 [inline]
 __put_partials+0xeb/0x130 mm/slub.c:2922
 put_cpu_partial+0x17b/0x250 mm/slub.c:2997
 __slab_free+0x2fe/0x410 mm/slub.c:4166
 qlink_free mm/kasan/quarantine.c:160 [inline]
 qlist_free_all+0x6d/0xd0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x14b/0x160 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x23/0x70 mm/kasan/common.c:324
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3813 [inline]
 slab_alloc_node mm/slub.c:3860 [inline]
 kmem_cache_alloc_lru+0x172/0x340 mm/slub.c:3879
 __d_alloc+0x31/0x750 fs/dcache.c:1624
 d_alloc+0x4b/0x190 fs/dcache.c:1704
 lookup_one_qstr_excl+0xce/0x250 fs/namei.c:1604
 do_unlinkat+0x297/0x830 fs/namei.c:4386
 __do_sys_unlink fs/namei.c:4446 [inline]
 __se_sys_unlink fs/namei.c:4444 [inline]
 __x64_sys_unlink+0x49/0x50 fs/namei.c:4444
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf5/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Memory state around the buggy address:
 ffff888074833200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888074833280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888074833300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                                    ^
 ffff888074833380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888074833400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
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.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
       [not found] <20240202024950.941119-1-lizhi.xu@windriver.com>
@ 2024-02-02  3:16 ` syzbot
  0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2024-02-02  3:16 UTC (permalink / raw)
  To: linux-kernel, lizhi.xu, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+a426cde6dee8c2884b0b@syzkaller.appspotmail.com

Tested on:

commit:         02153319 Kconfig: Disable -Wstringop-overflow for GCC ..
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=101765d3e80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ac580c73b7cf3629
dashboard link: https://syzkaller.appspot.com/bug?extid=a426cde6dee8c2884b0b
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=10e774b7e80000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
  2024-07-04 13:44 [syzbot] " Dmitry Vyukov
@ 2024-07-05 13:52 ` Lizhi Xu
  2024-07-08  6:54   ` Dmitry Vyukov
  0 siblings, 1 reply; 8+ messages in thread
From: Lizhi Xu @ 2024-07-05 13:52 UTC (permalink / raw)
  To: dvyukov
  Cc: almaz.alexandrovich, linux-kernel, ntfs3, linux-fsdevel,
	syzbot+a426cde6dee8c2884b0b, syzkaller-bugs

On Thu, 4 Jul 2024 15:44:02 +0200, Dmitry Vyukov wrote: 
> > index 53629b1f65e9..a435df98c2b1 100644
> > --- a/fs/ntfs3/record.c
> > +++ b/fs/ntfs3/record.c
> > @@ -243,14 +243,14 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr)
> >                 off += asize;
> >         }
> >
> > -       asize = le32_to_cpu(attr->size);
> > -
> >         /* Can we use the first field (attr->type). */
> >         if (off + 8 > used) {
> >                 static_assert(ALIGN(sizeof(enum ATTR_TYPE), 8) == 8);
> >                 return NULL;
> >         }
> >
> > +       asize = le32_to_cpu(attr->size);
> > +
> >         if (attr->type == ATTR_END) {
> >                 /* End of enumeration. */
> >                 return NULL;
> 
> Hi Lizhi,
> 
> I don't see this fix mailed as a patch. Do you plan to submit it officially?
Hi Dmitry Vyukov,
Here: https://lore.kernel.org/all/20240202033334.1784409-1-lizhi.xu@windriver.com

--
Lizhi

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
  2024-07-05 13:52 ` Lizhi Xu
@ 2024-07-08  6:54   ` Dmitry Vyukov
  2024-07-11  8:27     ` Konstantin Komarov
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Vyukov @ 2024-07-08  6:54 UTC (permalink / raw)
  To: Lizhi Xu
  Cc: almaz.alexandrovich, linux-kernel, ntfs3, linux-fsdevel,
	syzbot+a426cde6dee8c2884b0b, syzkaller-bugs, Kees Cook

On Fri, 5 Jul 2024 at 15:52, Lizhi Xu <lizhi.xu@windriver.com> wrote:
>
> On Thu, 4 Jul 2024 15:44:02 +0200, Dmitry Vyukov wrote:
> > > index 53629b1f65e9..a435df98c2b1 100644
> > > --- a/fs/ntfs3/record.c
> > > +++ b/fs/ntfs3/record.c
> > > @@ -243,14 +243,14 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr)
> > >                 off += asize;
> > >         }
> > >
> > > -       asize = le32_to_cpu(attr->size);
> > > -
> > >         /* Can we use the first field (attr->type). */
> > >         if (off + 8 > used) {
> > >                 static_assert(ALIGN(sizeof(enum ATTR_TYPE), 8) == 8);
> > >                 return NULL;
> > >         }
> > >
> > > +       asize = le32_to_cpu(attr->size);
> > > +
> > >         if (attr->type == ATTR_END) {
> > >                 /* End of enumeration. */
> > >                 return NULL;
> >
> > Hi Lizhi,
> >
> > I don't see this fix mailed as a patch. Do you plan to submit it officially?
> Hi Dmitry Vyukov,
> Here: https://lore.kernel.org/all/20240202033334.1784409-1-lizhi.xu@windriver.com

I don't see this patch merged upstream.  Was it lost? Perhaps it needs
to be resent.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
       [not found] <086e91b5-4afa-40e3-b8a6-f2734761f801@paragon-software.com>
@ 2024-07-11  7:37 ` syzbot
  0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2024-07-11  7:37 UTC (permalink / raw)
  To: almaz.alexandrovich, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+a426cde6dee8c2884b0b@syzkaller.appspotmail.com

Tested on:

commit:         9d9a2f29 Merge tag 'mm-hotfixes-stable-2024-07-10-13-1..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=106c2e9e980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=bb254077242b0ab4
dashboard link: https://syzkaller.appspot.com/bug?extid=a426cde6dee8c2884b0b
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.
Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
       [not found] <7bc3c0f4-d611-4328-b456-a7d2ac0ff4b9@paragon-software.com>
@ 2024-07-11  7:57 ` syzbot
  0 siblings, 0 replies; 8+ messages in thread
From: syzbot @ 2024-07-11  7:57 UTC (permalink / raw)
  To: almaz.alexandrovich, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-out-of-bounds Read in mi_enum_attr

==================================================================
BUG: KASAN: slab-out-of-bounds in mi_enum_attr+0x84b/0x9e0 fs/ntfs3/record.c:246
Read of size 4 at addr ffff888068a97345 by task syz-executor.4/9900

CPU: 1 PID: 9900 Comm: syz-executor.4 Not tainted 6.10.0-rc1-syzkaller-00042-gbde63e8eae5d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 mi_enum_attr+0x84b/0x9e0 fs/ntfs3/record.c:246
 mi_find_attr+0x1c5/0x2b0 fs/ntfs3/record.c:353
 ni_find_attr+0x390/0x8d0 fs/ntfs3/frecord.c:202
 ntfs_readlink_hlp+0xa5/0xc70 fs/ntfs3/inode.c:1960
 ntfs_get_link+0x79/0x110 fs/ntfs3/inode.c:2106
 pick_link+0x631/0xd50
 step_into+0xca9/0x1080 fs/namei.c:1874
 open_last_lookups fs/namei.c:3597 [inline]
 path_openat+0x18ef/0x3280 fs/namei.c:3804
 do_filp_open+0x235/0x490 fs/namei.c:3834
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1405
 do_sys_open fs/open.c:1420 [inline]
 __do_sys_open fs/open.c:1428 [inline]
 __se_sys_open fs/open.c:1424 [inline]
 __x64_sys_open+0x225/0x270 fs/open.c:1424
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5e9bc7cda9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f5e9c9930c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 00007f5e9bdac050 RCX: 00007f5e9bc7cda9
RDX: 0000000000000065 RSI: 0000000000000080 RDI: 0000000020000440
RBP: 00007f5e9bcc947a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f5e9bdac050 R15: 00007fff3591b788
 </TASK>

Allocated by task 9815:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 kmalloc_trace_noprof+0x19c/0x2c0 mm/slub.c:4152
 kmalloc_noprof include/linux/slab.h:660 [inline]
 ntfs_get_link+0x63/0x110 fs/ntfs3/inode.c:2102
 pick_link+0x631/0xd50
 step_into+0xca9/0x1080 fs/namei.c:1874
 open_last_lookups fs/namei.c:3597 [inline]
 path_openat+0x18ef/0x3280 fs/namei.c:3804
 do_filp_open+0x235/0x490 fs/namei.c:3834
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1405
 do_sys_open fs/open.c:1420 [inline]
 __do_sys_open fs/open.c:1428 [inline]
 __se_sys_open fs/open.c:1424 [inline]
 __x64_sys_open+0x225/0x270 fs/open.c:1424
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 9815:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2195 [inline]
 slab_free mm/slub.c:4436 [inline]
 kfree+0x149/0x360 mm/slub.c:4557
 do_delayed_call include/linux/delayed_call.h:28 [inline]
 put_link fs/namei.c:1025 [inline]
 open_last_lookups fs/namei.c:3596 [inline]
 path_openat+0x180d/0x3280 fs/namei.c:3804
 do_filp_open+0x235/0x490 fs/namei.c:3834
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1405
 do_sys_open fs/open.c:1420 [inline]
 __do_sys_open fs/open.c:1428 [inline]
 __se_sys_open fs/open.c:1424 [inline]
 __x64_sys_open+0x225/0x270 fs/open.c:1424
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888068a96000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 837 bytes to the right of
 allocated 4096-byte region [ffff888068a96000, ffff888068a97000)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x68a90
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffefff(slab)
raw: 00fff00000000040 ffff888014c42140 ffffea000087be00 dead000000000002
raw: 0000000000000000 0000000000040004 00000001ffffefff 0000000000000000
head: 00fff00000000040 ffff888014c42140 ffffea000087be00 dead000000000002
head: 0000000000000000 0000000000040004 00000001ffffefff 0000000000000000
head: 00fff00000000003 ffffea0001a2a401 ffffffffffffffff 0000000000000000
head: 0000000000000008 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5079, tgid 5079 (kworker/0:3), ts 179614011412, free_ts 179293511077
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1468
 prep_new_page mm/page_alloc.c:1476 [inline]
 get_page_from_freelist+0x2e2d/0x2ee0 mm/page_alloc.c:3402
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4660
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x5f/0x120 mm/slub.c:2264
 allocate_slab+0x5a/0x2e0 mm/slub.c:2427
 new_slab mm/slub.c:2480 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3666
 __slab_alloc+0x58/0xa0 mm/slub.c:3756
 __slab_alloc_node mm/slub.c:3809 [inline]
 slab_alloc_node mm/slub.c:3988 [inline]
 __do_kmalloc_node mm/slub.c:4120 [inline]
 kmalloc_node_track_caller_noprof+0x281/0x440 mm/slub.c:4141
 kmalloc_reserve+0x111/0x2a0 net/core/skbuff.c:597
 __alloc_skb+0x1f3/0x440 net/core/skbuff.c:666
 alloc_skb include/linux/skbuff.h:1308 [inline]
 nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:748 [inline]
 nsim_dev_trap_report drivers/net/netdevsim/dev.c:805 [inline]
 nsim_dev_trap_report_work+0x254/0xaa0 drivers/net/netdevsim/dev.c:850
 process_one_work kernel/workqueue.c:3231 [inline]
 process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3312
 worker_thread+0x86d/0xd70 kernel/workqueue.c:3393
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
page last free pid 6810 tgid 6808 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1088 [inline]
 free_unref_page+0xd19/0xea0 mm/page_alloc.c:2565
 discard_slab mm/slub.c:2526 [inline]
 __put_partials+0xeb/0x130 mm/slub.c:2994
 put_cpu_partial+0x17c/0x250 mm/slub.c:3069
 __slab_free+0x2ea/0x3d0 mm/slub.c:4306
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x9e/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3940 [inline]
 slab_alloc_node mm/slub.c:4000 [inline]
 kmalloc_trace_noprof+0x132/0x2c0 mm/slub.c:4147
 kmalloc_noprof include/linux/slab.h:660 [inline]
 kzalloc_noprof include/linux/slab.h:778 [inline]
 fnd_get fs/ntfs3/ntfs_fs.h:672 [inline]
 dir_search_u+0x16a/0x3a0 fs/ntfs3/dir.c:246
 ntfs_extend_init+0x27a/0x530 fs/ntfs3/fsntfs.c:250
 ntfs_fill_super+0x4213/0x4830 fs/ntfs3/super.c:1523
 get_tree_bdev+0x3f7/0x570 fs/super.c:1615
 vfs_get_tree+0x90/0x2a0 fs/super.c:1780
 do_new_mount+0x2be/0xb40 fs/namespace.c:3352
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount+0x2d9/0x3c0 fs/namespace.c:3875
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83

Memory state around the buggy address:
 ffff888068a97200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888068a97280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888068a97300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                           ^
 ffff888068a97380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888068a97400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


Tested on:

commit:         bde63e8e fs/ntfs3: Fix formatting, change comments, re..
git tree:       https://github.com/Paragon-Software-Group/linux-ntfs3.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=12c9e87e980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=e4430a9c6b8c7af4
dashboard link: https://syzkaller.appspot.com/bug?extid=a426cde6dee8c2884b0b
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
  2024-07-08  6:54   ` Dmitry Vyukov
@ 2024-07-11  8:27     ` Konstantin Komarov
  2024-08-20 10:53       ` lei lu
  0 siblings, 1 reply; 8+ messages in thread
From: Konstantin Komarov @ 2024-07-11  8:27 UTC (permalink / raw)
  To: Dmitry Vyukov, Lizhi Xu
  Cc: linux-kernel, ntfs3, linux-fsdevel, syzbot+a426cde6dee8c2884b0b,
	syzkaller-bugs, Kees Cook

On 08.07.2024 09:54, Dmitry Vyukov wrote:
> On Fri, 5 Jul 2024 at 15:52, Lizhi Xu <lizhi.xu@windriver.com> wrote:
>> On Thu, 4 Jul 2024 15:44:02 +0200, Dmitry Vyukov wrote:
>>>> index 53629b1f65e9..a435df98c2b1 100644
>>>> --- a/fs/ntfs3/record.c
>>>> +++ b/fs/ntfs3/record.c
>>>> @@ -243,14 +243,14 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr)
>>>>                  off += asize;
>>>>          }
>>>>
>>>> -       asize = le32_to_cpu(attr->size);
>>>> -
>>>>          /* Can we use the first field (attr->type). */
>>>>          if (off + 8 > used) {
>>>>                  static_assert(ALIGN(sizeof(enum ATTR_TYPE), 8) == 8);
>>>>                  return NULL;
>>>>          }
>>>>
>>>> +       asize = le32_to_cpu(attr->size);
>>>> +
>>>>          if (attr->type == ATTR_END) {
>>>>                  /* End of enumeration. */
>>>>                  return NULL;
>>> Hi Lizhi,
>>>
>>> I don't see this fix mailed as a patch. Do you plan to submit it officially?
>> Hi Dmitry Vyukov,
>> Here: https://lore.kernel.org/all/20240202033334.1784409-1-lizhi.xu@windriver.com
> I don't see this patch merged upstream.  Was it lost? Perhaps it needs
> to be resent.
Hi, Lizhi, Dmitry, This patch is indeed not present in either the 
upstream or our repository. I will retest it and figure out why I didn't 
add it. Around the same time, I was making changes to mi_enum_attr, so I 
might have mixed something up. Thanks for your attention! Regards,
Konstantin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr
  2024-07-11  8:27     ` Konstantin Komarov
@ 2024-08-20 10:53       ` lei lu
  0 siblings, 0 replies; 8+ messages in thread
From: lei lu @ 2024-08-20 10:53 UTC (permalink / raw)
  To: almaz.alexandrovich
  Cc: dvyukov, keescook, linux-fsdevel, linux-kernel, lizhi.xu, ntfs3,
	syzbot+a426cde6dee8c2884b0b, syzkaller-bugs

Hi, Konstantin,

I think this patch is not fully considered. The root cause is there is a lack of
verification of the space occupied by the fixed members of attr before accessing.
In this patch, 'if (off + 8 > used)' just ensure that type and size field don't
stry beyond valid memory region without considering other members.

We can make a PoC as below to trigger out-of-bound read in 'if (!attr->non_res)',
because if the attr is the first ATTRIB, it will not call
'if (asize < SIZEOF_REDISENT)'. So 'if (off + asize < off || off + asize > used)'
is an invalid check.

PoC:
MFT_REC for MFT_REC_VOL located at: 0x660c00
  MFT_REC.rhdr.sign: 0x454c4946 (FILE)
  MFT_REC.rhdr.fix_off: 0x30
  MFT_REC.rhdr.fix_num: 0x3
  MFT_REC.rhdr.lsn: 0x10550c
  MFT_REC.seq: 0x3
  MFT_REC.hard_links: 0x1
  MFT_REC.attr_off: 0x38 --> 0x3f8
  MFT_REC.flags: 0x1
  MFT_REC.used: 0x178 --> 0x400
  MFT_REC.total: 0x400
  MFT_REC.parent_ref.low: 0x0
  MFT_REC.parent_ref.high: 0x0
  MFT_REC.parent_ref.seq: 0x0
  MFT_REC.next_attr_id: 0x6
  MFT_REC.res: 0x0
  MFT_REC.mft_record: 0x3
ATTRIB[0] located at: 0x660ff8
  ATTRIB[0].type: 0x0 --> 0x10
  ATTRIB[0].size: 0x20000 --> 0x8

KASAN report:
[  611.082411] ==================================================================
[  611.082411] BUG: KASAN: slab-out-of-bounds in mi_enum_attr+0x762/0x810
[  611.082411] Read of size 1 at addr ffff88810e853c00 by task mount/298
[  611.082411]
[  611.082411] CPU: 1 PID: 298 Comm: mount Not tainted 6.8.2 #2
[  611.082411] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
[  611.082411] Call Trace:
[  611.082411]  <TASK>
[  611.082411]  dump_stack_lvl+0x50/0x70
[  611.082411]  print_report+0xcc/0x620
[  611.082411]  ? __virt_addr_valid+0xcb/0x320
[  611.082411]  ? mi_enum_attr+0x762/0x810
[  611.082411]  kasan_report+0xb0/0xe0
[  611.082411]  ? mi_enum_attr+0x762/0x810
[  611.082411]  mi_enum_attr+0x762/0x810
[  611.082411]  ni_enum_attr_ex+0x2fc/0x3e0
[  611.082411]  ? ntfs_read_bh+0x48/0xa0
[  611.082411]  ? __pfx_ni_enum_attr_ex+0x10/0x10
[  611.082411]  ? mi_read+0x32b/0x540
[  611.082411]  ntfs_iget5+0x86c/0x2dc0
[  611.082411]  ? __pfx_ntfs_iget5+0x10/0x10
[  611.082411]  ? __brelse+0x7c/0xa0
[  611.082411]  ntfs_fill_super+0x1686/0x3c00
[  611.082411]  ? __pfx_ntfs_fill_super+0x10/0x10
[  611.082411]  ? set_blocksize+0xbe/0x3a0
[  611.082411]  ? set_blocksize+0x28c/0x3a0
[  611.082411]  ? sb_set_blocksize+0xde/0x110
[  611.082411]  ? setup_bdev_super+0x331/0x690
[  611.082411]  get_tree_bdev+0x32b/0x590
[  611.082411]  ? __pfx_ntfs_fill_super+0x10/0x10
[  611.082411]  ? __pfx_get_tree_bdev+0x10/0x10
[  611.082411]  ? __pfx_vfs_parse_fs_string+0x10/0x10
[  611.082411]  ? cap_capable+0x199/0x200
[  611.082411]  ? security_capable+0x8d/0xc0
[  611.082411]  vfs_get_tree+0x8c/0x300
[  611.082411]  path_mount+0x507/0x1a30
[  611.082411]  ? sysvec_apic_timer_interrupt+0xf/0x80
[  611.082411]  ? __pfx_path_mount+0x10/0x10
[  611.082411]  __x64_sys_mount+0x23b/0x2d0
[  611.082411]  ? __pfx___x64_sys_mount+0x10/0x10
[  611.082411]  ? __do_softirq+0x18a/0x575
[  611.082411]  do_syscall_64+0xb3/0x1b0
[  611.082411]  entry_SYSCALL_64_after_hwframe+0x6f/0x77
[  611.082411] RIP: 0033:0x7f2d7417566a
[  611.082411] Code: 48 8b 0d 29 18 0d 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 8
[  611.082411] RSP: 002b:00007fff27f71598 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
[  611.082411] RAX: ffffffffffffffda RBX: 00007f2d742a9264 RCX: 00007f2d7417566a
[  611.082411] RDX: 000055ec2ff0cf80 RSI: 000055ec2ff0cfc0 RDI: 000055ec2ff0cfa0
[  611.082411] RBP: 000055ec2ff0cd50 R08: 0000000000000000 R09: 00007f2d74247be0
[  611.082411] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
[  611.082411] R13: 000055ec2ff0cfa0 R14: 000055ec2ff0cf80 R15: 000055ec2ff0cd50
[  611.082411]  </TASK>
[  611.082411]
[  611.082411] Allocated by task 298:
[  611.082411]  kasan_save_stack+0x24/0x50
[  611.082411]  kasan_save_track+0x14/0x30
[  611.082411]  __kasan_kmalloc+0x7f/0x90
[  611.082411]  __kmalloc+0x179/0x370
[  611.082411]  mi_init+0x90/0x100
[  611.082411]  ntfs_iget5+0x3d1/0x2dc0
[  611.082411]  ntfs_fill_super+0x1686/0x3c00
[  611.082411]  get_tree_bdev+0x32b/0x590
[  611.082411]  vfs_get_tree+0x8c/0x300
[  611.082411]  path_mount+0x507/0x1a30
[  611.082411]  __x64_sys_mount+0x23b/0x2d0
[  611.082411]  do_syscall_64+0xb3/0x1b0
[  611.082411]  entry_SYSCALL_64_after_hwframe+0x6f/0x77
[  611.082411]
[  611.082411] The buggy address belongs to the object at ffff88810e853800
[  611.082411]  which belongs to the cache kmalloc-1k of size 1024
[  611.082411] The buggy address is located 0 bytes to the right of
[  611.082411]  allocated 1024-byte region [ffff88810e853800, ffff88810e853c00)
[  611.082411]
[  611.082411] The buggy address belongs to the physical page:
[  611.082411] page:00000000a08f2d1e refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10e850
[  611.082411] head:00000000a08f2d1e order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
[  611.082411] flags: 0x200000000000840(slab|head|node=0|zone=2)
[  611.082411] page_type: 0xffffffff()
[  611.082411] raw: 0200000000000840 ffff888100041dc0 dead000000000122 0000000000000000
[  611.082411] raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
[  611.082411] page dumped because: kasan: bad access detected
[  611.082411]
[  611.082411] Memory state around the buggy address:
[  611.082411]  ffff88810e853b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[  611.082411]  ffff88810e853b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[  611.082411] >ffff88810e853c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[  611.082411]                    ^
[  611.082411]  ffff88810e853c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[  611.082411]  ffff88810e853d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[  611.082411] ==================================================================

Thanks,
LL

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-08-20 10:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <086e91b5-4afa-40e3-b8a6-f2734761f801@paragon-software.com>
2024-07-11  7:37 ` [syzbot] [ntfs3?] KASAN: slab-out-of-bounds Read in mi_enum_attr syzbot
     [not found] <7bc3c0f4-d611-4328-b456-a7d2ac0ff4b9@paragon-software.com>
2024-07-11  7:57 ` syzbot
2024-07-04 13:44 [syzbot] " Dmitry Vyukov
2024-07-05 13:52 ` Lizhi Xu
2024-07-08  6:54   ` Dmitry Vyukov
2024-07-11  8:27     ` Konstantin Komarov
2024-08-20 10:53       ` lei lu
     [not found] <20240202024950.941119-1-lizhi.xu@windriver.com>
2024-02-02  3:16 ` syzbot
  -- strict thread matches above, loose matches on Subject: below --
2024-02-01 15:17 syzbot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.