[v5.15] KASAN: out-of-bounds Write in udf_write_fi

0 views
Skip to first unread message

syzbot

unread,
Apr 3, 2023, 7:46:41 AM4/3/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c957cbb87315 Linux 5.15.105
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1705615dc80000
kernel config: https://syzkaller.appspot.com/x/.config?x=6f83fab0469f5de7
dashboard link: https://syzkaller.appspot.com/bug?extid=f9de9ee6cb8adb5b14c5
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/35817fda76e5/disk-c957cbb8.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/80f96399b8d4/vmlinux-c957cbb8.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4336a6ad59ec/bzImage-c957cbb8.xz

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

==================================================================
BUG: KASAN: out-of-bounds in udf_write_fi+0x569/0xb70
Write of size 18446744073709551572 at addr ffff88805107d02c by task syz-executor.4/16017

CPU: 1 PID: 16017 Comm: syz-executor.4 Not tainted 5.15.105-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
memset+0x1f/0x40 mm/kasan/shadow.c:44
udf_write_fi+0x569/0xb70
udf_delete_entry fs/udf/namei.c:577 [inline]
udf_rename+0x8b3/0x14d0 fs/udf/namei.c:1173
vfs_rename+0xd8f/0x1190 fs/namei.c:4736
do_renameat2+0xb97/0x13b0 fs/namei.c:4887
__do_sys_rename fs/namei.c:4933 [inline]
__se_sys_rename fs/namei.c:4931 [inline]
__x64_sys_rename+0x82/0x90 fs/namei.c:4931
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fc4730220f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fc469273168 EFLAGS: 00000246 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 00007fc473142050 RCX: 00007fc4730220f9
RDX: 0000000000000000 RSI: 0000000020000280 RDI: 0000000020000240
RBP: 00007fc47307db39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fff38109ebf R14: 00007fc469273300 R15: 0000000000022000
</TASK>

The buggy address belongs to the page:
page:ffffea0001441f40 refcount:4 mapcount:0 mapping:ffff888012094f30 index:0xb0 pfn:0x5107d
memcg:ffff8880287a8000
aops:def_blk_aops ino:700004
flags: 0xfff0000000203e(referenced|uptodate|dirty|lru|active|private|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff0000000203e ffffea00016ff648 ffff88801e925030 ffff888012094f30
raw: 00000000000000b0 ffff8880259171d0 00000004ffffffff ffff8880287a8000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x108c48(GFP_NOFS|__GFP_NOFAIL|__GFP_HARDWALL|__GFP_MOVABLE), pid 16017, ts 2539560125360, free_ts 2539458358084
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
__alloc_pages+0x272/0x700 mm/page_alloc.c:5421
__page_cache_alloc+0xd4/0x4a0 mm/filemap.c:1022
pagecache_get_page+0xa91/0x1010 mm/filemap.c:1940
find_or_create_page include/linux/pagemap.h:420 [inline]
grow_dev_page fs/buffer.c:949 [inline]
grow_buffers fs/buffer.c:1014 [inline]
__getblk_slow fs/buffer.c:1041 [inline]
__getblk_gfp+0x22a/0xaf0 fs/buffer.c:1336
__bread_gfp+0x2a/0x390 fs/buffer.c:1381
udf_find_entry+0x118b/0x14d0 fs/udf/namei.c:206
udf_lookup+0x11b/0x370 fs/udf/namei.c:309
__lookup_hash+0x117/0x240 fs/namei.c:1560
do_renameat2+0x570/0x13b0 fs/namei.c:4830
__do_sys_rename fs/namei.c:4933 [inline]
__se_sys_rename fs/namei.c:4931 [inline]
__x64_sys_rename+0x82/0x90 fs/namei.c:4931
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page_list+0x1f7/0x8e0 mm/page_alloc.c:3433
release_pages+0x1bb9/0x1f40 mm/swap.c:963
tlb_batch_pages_flush mm/mmu_gather.c:49 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:240 [inline]
tlb_flush_mmu mm/mmu_gather.c:247 [inline]
tlb_finish_mmu+0x177/0x320 mm/mmu_gather.c:338
exit_mmap+0x3cd/0x670 mm/mmap.c:3188
__mmput+0x112/0x3b0 kernel/fork.c:1118
exit_mm+0x688/0x7f0 kernel/exit.c:548
do_exit+0x626/0x2480 kernel/exit.c:859
do_group_exit+0x144/0x310 kernel/exit.c:994
__do_sys_exit_group kernel/exit.c:1005 [inline]
__se_sys_exit_group kernel/exit.c:1003 [inline]
__x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1003
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
ffff88805107cf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88805107cf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88805107d000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
ffff88805107d080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88805107d100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


---
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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
May 29, 2023, 7:43:54 AM5/29/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 1fe619a7d252 Linux 5.15.113
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1767ba69280000
kernel config: https://syzkaller.appspot.com/x/.config?x=8f10ee30ae29b021
dashboard link: https://syzkaller.appspot.com/bug?extid=f9de9ee6cb8adb5b14c5
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16e83d85280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17238736280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/1b707a1e1816/disk-1fe619a7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/19cc598a8bbe/vmlinux-1fe619a7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/a6cf7269bae5/Image-1fe619a7.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/041b068d4f0d/mount_0.gz

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

do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
==================================================================
BUG: KASAN: null-ptr-deref in udf_write_fi+0x3e4/0x9c0
Write of size 18446744073709551572 at addr 0000000000000020 by task syz-executor770/3965

CPU: 1 PID: 3965 Comm: syz-executor770 Not tainted 5.15.113-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
__kasan_report mm/kasan/report.c:438 [inline]
kasan_report+0x168/0x1e4 mm/kasan/report.c:451
kasan_check_range+0x274/0x2b4 mm/kasan/generic.c:189
memset+0x58/0x88 mm/kasan/shadow.c:44
udf_write_fi+0x3e4/0x9c0
udf_delete_entry fs/udf/namei.c:577 [inline]
udf_rename+0x90c/0x10b0 fs/udf/namei.c:1173
vfs_rename+0x9e0/0xe80 fs/namei.c:4736
do_renameat2+0x980/0x1040 fs/namei.c:4887
__do_sys_renameat fs/namei.c:4927 [inline]
__se_sys_renameat fs/namei.c:4924 [inline]
__arm64_sys_renameat+0xc8/0xe4 fs/namei.c:4924
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
==================================================================
Unable to handle kernel paging request at virtual address dfff800000000003
Mem abort info:
ESR = 0x0000000096000006
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x06: level 2 translation fault
Data abort info:
ISV = 0, ISS = 0x00000006
CM = 0, WnR = 0
[dfff800000000003] address between user and kernel address ranges
Internal error: Oops: 96000006 [#1] PREEMPT SMP
Modules linked in:
CPU: 1 PID: 3965 Comm: syz-executor770 Tainted: G B 5.15.113-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : crc_itu_t+0x5c/0x108 lib/crc-itu-t.c:60
lr : crc_itu_t+0x38/0x108 lib/crc-itu-t.c:59
sp : ffff80001a8d7500
x29: ffff80001a8d7510 x28: 0000000000000000 x27: 00000000fffffff0
x26: ffff80001a8d76c8 x25: 1ffff0000351aed9 x24: ffff800011f52540
x23: 000000000000ffd9 x22: dfff800000000000 x21: 000000000000001a
x20: 000000000000001a x19: 00000000a79d5f14 x18: 1fffe0003690378e
x17: 1fffe0003690378e x16: ffff80001194ffd4 x15: ffff80001497f100
x14: ffff0001b481bc80 x13: ffffffffffffffff x12: 0000000000000000
x11: ff8080000a9ab690 x10: 0000000000000000 x9 : 0000000000000002
x8 : 0000000000000003 x7 : 0000000000000000 x6 : ffff800008268c6c
x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff80000819b8b0
x2 : 000000000000ffda x1 : 000000000000ffda x0 : 0000000000000000
Call trace:
crc_itu_t+0x5c/0x108 lib/crc-itu-t.c:60
udf_write_fi+0x540/0x9c0
udf_delete_entry fs/udf/namei.c:577 [inline]
udf_rename+0x90c/0x10b0 fs/udf/namei.c:1173
vfs_rename+0x9e0/0xe80 fs/namei.c:4736
do_renameat2+0x980/0x1040 fs/namei.c:4887
__do_sys_renameat fs/namei.c:4927 [inline]
__se_sys_renameat fs/namei.c:4924 [inline]
__arm64_sys_renameat+0xc8/0xe4 fs/namei.c:4924
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
Code: f003ad38 91150318 d343fea8 12000aa9 (38f66908)
---[ end trace 19f87059c62af2e8 ]---
----------------
Code disassembly (best guess):
0: f003ad38 adrp x24, 0x75a7000
4: 91150318 add x24, x24, #0x540
8: d343fea8 lsr x8, x21, #3
c: 12000aa9 and w9, w21, #0x7
* 10: 38f66908 ldrsb w8, [x8, x22] <-- trapping instruction


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

syzbot

unread,
Oct 23, 2023, 3:23:47 PM10/23/23
to syzkaller...@googlegroups.com
syzbot suspects this issue could be fixed by backporting the following commit:

commit e9109a92d2a95889498bed3719cd2318892171a2
git tree: upstream
Author: Jan Kara <ja...@suse.cz>
Date: Thu Oct 6 14:41:23 2022 +0000

udf: Convert udf_rename() to new directory iteration code

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15c63095680000
kernel config: https://syzkaller.appspot.com/x/.config?x=717fa62bb7f0fe9
dashboard link: https://syzkaller.appspot.com/bug?extid=f9de9ee6cb8adb5b14c5
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10726123280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1078fc1b280000


Please keep in mind that other backports might be required as well.

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages