Bug 1227383 (RH-CVE-2280317)

Summary: VUL-0: kernel: slab-out-of-bounds in hex_dump_to_buffer
Product: [Novell Products] SUSE Security Incidents Reporter: SMASH SMASH <smash_bz>
Component: IncidentsAssignee: Security Team bot <security-team>
Status: NEW --- QA Contact: Security Team bot <security-team>
Severity: Minor    
Priority: P3 - Medium CC: ddiss, thomas.leroy
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://smash.suse.de/issue/406061/
Whiteboard:
Found By: Security Response Team Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description SMASH SMASH 2024-07-04 08:57:39 UTC
There is a c,it was found by syzkaller with linux tag: v6.8.

Here is the crash info:

BUG: KASAN: slab-out-of-bounds in hex_dump_to_buffer+0xd8f/0xde0 lib/hexdump.c:193
Read of size 1 at addr ffff88802acbee80 by task syz-executor.3/25149

CPU: 0 PID: 25149 Comm: syz-executor.3 Not tainted 6.8.0 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd5/0x150 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:377 [inline]
print_report+0xc1/0x5e0 mm/kasan/report.c:488
kasan_report+0xba/0xf0 mm/kasan/report.c:601
hex_dump_to_buffer+0xd8f/0xde0 lib/hexdump.c:193
print_hex_dump+0x16d/0x240 lib/hexdump.c:276
ea_get+0x747/0x12f0 fs/jfs/xattr.c:561
__jfs_getxattr+0xc2/0x330 fs/jfs/xattr.c:807
jfs_xattr_get+0x39/0x50 fs/jfs/xattr.c:931
__vfs_getxattr+0x134/0x190 fs/xattr.c:424
cap_inode_need_killpriv+0x3c/0x60 security/commoncap.c:302
security_inode_need_killpriv+0x40/0x90 security/security.c:2453
dentry_needs_remove_privs+0xa6/0xf0 fs/inode.c:2013
do_truncate+0xcc/0x200 fs/open.c:58
handle_truncate fs/namei.c:3303 [inline]
do_open fs/namei.c:3649 [inline]
path_openat+0x1f86/0x2660 fs/namei.c:3802
do_filp_open+0x1c5/0x410 fs/namei.c:3829
do_sys_openat2+0x160/0x1c0 fs/open.c:1404
do_sys_open fs/open.c:1419 [inline]
__do_sys_creat fs/open.c:1495 [inline]
__se_sys_creat fs/open.c:1489 [inline]
__x64_sys_creat+0xc9/0x120 fs/open.c:1489
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x73/0x1c0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f018169002d
Code: c3 e8 97 2b 00 00 0f 1f 80 00 00 00 00 f3 0f 1e fa 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:00007f0182331028 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f01817cc050 RCX: 00007f018169002d
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000240
RBP: 00007f01816f14a6 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000006e R14: 00007f01817cc050 R15: 00007f0182311000
</TASK>

Allocated by task 25122:
kasan_save_stack+0x20/0x40 mm/kasan/common.c:47
kasan_save_track+0x10/0x30 mm/kasan/common.c:68
unpoison_slab_object mm/kasan/common.c:312 [inline]
__kasan_slab_alloc+0x7b/0x80 mm/kasan/common.c:338
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+0x13b/0x880 mm/slub.c:3879
alloc_inode_sb include/linux/fs.h:3018 [inline]
jfs_alloc_inode+0x23/0x60 fs/jfs/super.c:105
alloc_inode+0x61/0x230 fs/inode.c:260
iget_locked+0x1a4/0x6d0 fs/inode.c:1278
jfs_iget+0x1a/0x4d0 fs/jfs/inode.c:29
jfs_lookup+0x274/0x340 fs/jfs/namei.c:1469
lookup_open.isra.0+0x8b2/0x1350 fs/namei.c:3478
open_last_lookups fs/namei.c:3569 [inline]
path_openat+0xa87/0x2660 fs/namei.c:3799
do_filp_open+0x1c5/0x410 fs/namei.c:3829
do_sys_openat2+0x160/0x1c0 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+0x13c/0x1f0 fs/open.c:1430
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x73/0x1c0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

The buggy address belongs to the object at ffff88802acbe5c0
which belongs to the cache jfs_ip of size 2240
The buggy address is located 0 bytes to the right of
allocated 2240-byte region [ffff88802acbe5c0, ffff88802acbee80)

The buggy address belongs to the physical page:
page:ffffea0000ab2e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2acb8
head:ffffea0000ab2e00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff8880475c9201
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888104298c80 dead000000000100 dead000000000122
raw: 0000000000000000 00000000000d000d 00000001ffffffff ffff8880475c9201
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Reclaimable, gfp_mask 0x1d2050(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 22224, tgid 22221 (syz-executor.1), ts 2735761345773, free_ts 1577602259194
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1533
prep_new_page mm/page_alloc.c:1540 [inline]
get_page_from_freelist+0xd38/0x3030 mm/page_alloc.c:3311
__alloc_pages+0x1c7/0x490 mm/page_alloc.c:4569
__alloc_pages_node include/linux/gfp.h:238 [inline]
alloc_pages_node include/linux/gfp.h:261 [inline]
alloc_slab_page mm/slub.c:2190 [inline]
allocate_slab+0xa7/0x380 mm/slub.c:2354
new_slab mm/slub.c:2407 [inline]
___slab_alloc+0x99a/0x1870 mm/slub.c:3540
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3625
__slab_alloc_node mm/slub.c:3678 [inline]
slab_alloc_node mm/slub.c:3850 [inline]
kmem_cache_alloc_lru+0x475/0x880 mm/slub.c:3879
alloc_inode_sb include/linux/fs.h:3018 [inline]
jfs_alloc_inode+0x23/0x60 fs/jfs/super.c:105
alloc_inode+0x61/0x230 fs/inode.c:260
new_inode_pseudo fs/inode.c:1005 [inline]
new_inode+0x1e/0x270 fs/inode.c:1031
diReadSpecial+0x4f/0x6d0 fs/jfs/jfs_imap.c:423
jfs_mount+0x60c/0x8b0 fs/jfs/jfs_mount.c:138
jfs_fill_super+0x5a4/0xd40 fs/jfs/super.c:556
mount_bdev+0x1e1/0x2d0 fs/super.c:1658
legacy_get_tree+0x105/0x220 fs/fs_context.c:662
vfs_get_tree+0x8d/0x370 fs/super.c:1779
page last free pid 17309 tgid 17309 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+0x50d/0xb00 mm/page_alloc.c:2346
free_unref_page+0x2f/0x3d0 mm/page_alloc.c:2486
__put_partials+0x151/0x170 mm/slub.c:2922
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x50/0x140 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x18a/0x1d0 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x5f/0x80 mm/kasan/common.c:322
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]
__do_kmalloc_node mm/slub.c:3980 [inline]
__kmalloc+0x1c1/0x570 mm/slub.c:3994
kmalloc include/linux/slab.h:594 [inline]
tomoyo_realpath_from_path+0xbf/0x630 security/tomoyo/realpath.c:251
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path_perm+0x22b/0x440 security/tomoyo/file.c:822
security_inode_getattr+0xcf/0x140 security/security.c:2238
vfs_getattr fs/stat.c:173 [inline]
vfs_fstat+0x46/0xb0 fs/stat.c:198
__do_sys_newfstat+0x7a/0xf0 fs/stat.c:478
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x73/0x1c0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Memory state around the buggy address:
ffff88802acbed80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88802acbee00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88802acbee80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff88802acbef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88802acbef80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

References:
https://bugzilla.redhat.com/show_bug.cgi?id=2280317
Comment 1 David Disseldorp 2024-07-04 16:24:15 UTC
This isn't relevant for SLE - we don't support jfs in SLE >=11 kernels.

Looks like Greg attempted to address this via 7c55b78818cfb ("jfs: xattr: fix buffer overflow for invalid xattr"). I'll merge it for openSUSE.
Comment 2 David Disseldorp 2024-07-05 09:34:12 UTC
(In reply to David Disseldorp from comment #1)
> This isn't relevant for SLE - we don't support jfs in SLE >=11 kernels.
> 
> Looks like Greg attempted to address this via 7c55b78818cfb ("jfs: xattr:
> fix buffer overflow for invalid xattr"). I'll merge it for openSUSE.

Fixes submitted via users/ddiss/cve/linux-5.14-LTSS/for-next and users/ddiss/SLE15-SP6/for-next . I omitted the RH-CVE-2280317 changelog reference following discussion with Marcus.

Reassigning to the security team for closure.