[syzbot] UBSAN: array-index-out-of-bounds in ima_inode_setxattr

21 views
Skip to first unread message

syzbot

unread,
Aug 19, 2021, 11:30:37 AM8/19/21
to dmitry....@gmail.com, jmo...@namei.org, linux-i...@vger.kernel.org, linux-...@vger.kernel.org, linux-secu...@vger.kernel.org, se...@hallyn.com, syzkall...@googlegroups.com, zo...@linux.ibm.com
Hello,

syzbot found the following issue on:

HEAD commit: 33e65b1f975c Add linux-next specific files for 20210819
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1546c341300000
kernel config: https://syzkaller.appspot.com/x/.config?x=3022de5bd1dbc8f5
dashboard link: https://syzkaller.appspot.com/bug?extid=e8bafe7b82c739eaf153
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.1
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15767d41300000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13582731300000

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

================================================================================
UBSAN: array-index-out-of-bounds in security/integrity/ima/ima_appraise.c:621:36
index 222 is out of range for type 'char *[20]'
CPU: 1 PID: 6550 Comm: syz-executor680 Not tainted 5.14.0-rc6-next-20210819-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
ubsan_epilogue+0xb/0x5a lib/ubsan.c:151
__ubsan_handle_out_of_bounds.cold+0x64/0x70 lib/ubsan.c:291
validate_hash_algo security/integrity/ima/ima_appraise.c:621 [inline]
ima_inode_setxattr+0x536/0x540 security/integrity/ima/ima_appraise.c:656
security_inode_setxattr+0x148/0x240 security/security.c:1355
__vfs_setxattr_locked+0xa7/0x260 fs/xattr.c:266
vfs_setxattr+0x14e/0x350 fs/xattr.c:301
setxattr+0x21b/0x2b0 fs/xattr.c:575
path_setxattr+0x19d/0x1d0 fs/xattr.c:595
__do_sys_lsetxattr fs/xattr.c:618 [inline]
__se_sys_lsetxattr fs/xattr.c:614 [inline]
__x64_sys_lsetxattr+0xbd/0x150 fs/xattr.c:614
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x43ee89
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe96b06768 EFLAGS: 00000246 ORIG_RAX: 00000000000000bd
RAX: ffffffffffffffda RBX: 0000000000400488 RCX: 000000000043ee89
RDX: 0000000020000140 RSI: 00000000200000c0 RDI: 0000000020000000
RBP: 0000000000402e70 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000000a R11: 0000000000000246 R12: 0000000000402f00
R13: 0000000000000000 R14: 00000000004ac018 R15: 0000000000400488
================================================================================
----------------
Code disassembly (best guess):
0: 28 c3 sub %al,%bl
2: e8 2a 14 00 00 callq 0x1431
7: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
e: 00 00 00
11: 48 89 f8 mov %rdi,%rax
14: 48 89 f7 mov %rsi,%rdi
17: 48 89 d6 mov %rdx,%rsi
1a: 48 89 ca mov %rcx,%rdx
1d: 4d 89 c2 mov %r8,%r10
20: 4d 89 c8 mov %r9,%r8
23: 4c 8b 4c 24 08 mov 0x8(%rsp),%r9
28: 0f 05 syscall
2a: 48 3d 01 f0 ff ff cmp $0xfffffffffffff001,%rax <-- trapping instruction
30: 73 01 jae 0x33
32: c3 retq
33: 48 c7 c1 c0 ff ff ff mov $0xffffffffffffffc0,%rcx
3a: f7 d8 neg %eax
3c: 64 89 01 mov %eax,%fs:(%rcx)
3f: 48 rex.W


---
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 can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Aug 20, 2021, 7:18:15 AM8/20/21
to Simon...@viveris.fr, syzkall...@googlegroups.com
Hello,

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

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

Tested on:

commit: 33e65b1f Add linux-next specific files for 20210819
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
kernel config: https://syzkaller.appspot.com/x/.config?x=3022de5bd1dbc8f5
dashboard link: https://syzkaller.appspot.com/bug?extid=e8bafe7b82c739eaf153
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.1
patch: https://syzkaller.appspot.com/x/patch.diff?x=159c5d16300000

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

syzbot

unread,
Aug 21, 2021, 10:42:09 PM8/21/21
to ash...@itfac.mrt.ac.lk, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KFENCE: use-after-free in kvm_fastop_exception

==================================================================
BUG: KFENCE: use-after-free read in kvm_fastop_exception+0xf68/0x1056

Use-after-free read at 0xffff88823bda8020 (in kfence-#211):
kvm_fastop_exception+0xf68/0x1056
d_lookup+0xdd/0x170 fs/dcache.c:2370
lookup_dcache+0x1e/0x130 fs/namei.c:1520
__lookup_hash+0x29/0x180 fs/namei.c:1543
kern_path_locked+0x17e/0x320 fs/namei.c:2567
handle_remove+0xa2/0x5fe drivers/base/devtmpfs.c:312
handle drivers/base/devtmpfs.c:382 [inline]
devtmpfs_work_loop drivers/base/devtmpfs.c:395 [inline]
devtmpfsd+0x1ba/0x2ab drivers/base/devtmpfs.c:437
kthread+0x3e5/0x4d0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

kfence-#211: 0xffff88823bda8000-0xffff88823bda8fff, size=4096, cache=names_cache

allocated by task 22 on cpu 1 at 75.896775s:
getname_kernel+0x4e/0x370 fs/namei.c:226
kern_path_locked+0x71/0x320 fs/namei.c:2558
handle_remove+0xa2/0x5fe drivers/base/devtmpfs.c:312
handle drivers/base/devtmpfs.c:382 [inline]
devtmpfs_work_loop drivers/base/devtmpfs.c:395 [inline]
devtmpfsd+0x1ba/0x2ab drivers/base/devtmpfs.c:437
kthread+0x3e5/0x4d0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

freed by task 22 on cpu 1 at 75.896796s:
putname.part.0+0xe9/0x130 fs/namei.c:270
putname include/linux/err.h:41 [inline]
filename_parentat fs/namei.c:2547 [inline]
kern_path_locked+0xc2/0x320 fs/namei.c:2558
handle_remove+0xa2/0x5fe drivers/base/devtmpfs.c:312
handle drivers/base/devtmpfs.c:382 [inline]
devtmpfs_work_loop drivers/base/devtmpfs.c:395 [inline]
devtmpfsd+0x1ba/0x2ab drivers/base/devtmpfs.c:437
kthread+0x3e5/0x4d0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

CPU: 1 PID: 22 Comm: kdevtmpfs Not tainted 5.14.0-rc6-next-20210820-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:kvm_fastop_exception+0xf68/0x1056
Code: d3 ed e9 e4 91 6d f8 49 8d 0e 48 83 e1 f8 4c 8b 21 41 8d 0e 83 e1 07 c1 e1 03 49 d3 ec e9 3f 9f 6d f8 49 8d 4d 00 48 83 e1 f8 <4c> 8b 21 41 8d 4d 00 83 e1 07 c1 e1 03 49 d3 ec e9 39 a9 6d f8 bd
RSP: 0018:ffffc90000dcfaa8 EFLAGS: 00010282
RAX: 0000003336706174 RBX: ffff88806c831068 RCX: ffff88823bda8020
RDX: ffffed100d906214 RSI: 0000000000000005 RDI: 0000000000000007
RBP: 0000000000000005 R08: 0000000000000000 R09: ffff88806c831098
R10: ffffed100d906213 R11: 0000000000000000 R12: ffff88823bda8020
R13: ffff88823bda8020 R14: ffff88806c831098 R15: dffffc0000000000
FS: 0000000000000000(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff88823bda8020 CR3: 000000000b68e000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
d_lookup+0xdd/0x170 fs/dcache.c:2370
lookup_dcache+0x1e/0x130 fs/namei.c:1520
__lookup_hash+0x29/0x180 fs/namei.c:1543
kern_path_locked+0x17e/0x320 fs/namei.c:2567
handle_remove+0xa2/0x5fe drivers/base/devtmpfs.c:312
handle drivers/base/devtmpfs.c:382 [inline]
devtmpfs_work_loop drivers/base/devtmpfs.c:395 [inline]
devtmpfsd+0x1ba/0x2ab drivers/base/devtmpfs.c:437
kthread+0x3e5/0x4d0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
==================================================================
----------------
Code disassembly (best guess):
0: d3 ed shr %cl,%ebp
2: e9 e4 91 6d f8 jmpq 0xf86d91eb
7: 49 8d 0e lea (%r14),%rcx
a: 48 83 e1 f8 and $0xfffffffffffffff8,%rcx
e: 4c 8b 21 mov (%rcx),%r12
11: 41 8d 0e lea (%r14),%ecx
14: 83 e1 07 and $0x7,%ecx
17: c1 e1 03 shl $0x3,%ecx
1a: 49 d3 ec shr %cl,%r12
1d: e9 3f 9f 6d f8 jmpq 0xf86d9f61
22: 49 8d 4d 00 lea 0x0(%r13),%rcx
26: 48 83 e1 f8 and $0xfffffffffffffff8,%rcx
* 2a: 4c 8b 21 mov (%rcx),%r12 <-- trapping instruction
2d: 41 8d 4d 00 lea 0x0(%r13),%ecx
31: 83 e1 07 and $0x7,%ecx
34: c1 e1 03 shl $0x3,%ecx
37: 49 d3 ec shr %cl,%r12
3a: e9 39 a9 6d f8 jmpq 0xf86da978
3f: bd .byte 0xbd


Tested on:

commit: 86ed57fd Add linux-next specific files for 20210820
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=10b17329300000
kernel config: https://syzkaller.appspot.com/x/.config?x=f64eccb415bd479d
Reply all
Reply to author
Forward
0 new messages