UBSAN: array-index-out-of-bounds in dquot_resume

From: syzbot
Date: Mon Dec 07 2020 - 14:04:40 EST


Hello,

syzbot found the following issue on:

HEAD commit: b3298500 Merge tag 'for-5.10/dm-fixes' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1429c99b500000
kernel config: https://syzkaller.appspot.com/x/.config?x=c3904d1cc0af152
dashboard link: https://syzkaller.appspot.com/bug?extid=2643e825238d7aabb37f
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project.git ca2dcbd030eadbf0aa9b660efe864ff08af6e18b)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10391d45500000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16eab99b500000

The issue was bisected to:

commit ae45f07d47cc30e9170488a4e5fe91ba4fe5ed4e
Author: Jan Kara <jack@xxxxxxx>
Date: Fri Nov 1 16:51:05 2019 +0000

quota: Simplify dquot_resume()

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=14d95975500000
final oops: https://syzkaller.appspot.com/x/report.txt?x=16d95975500000
console output: https://syzkaller.appspot.com/x/log.txt?x=12d95975500000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2643e825238d7aabb37f@xxxxxxxxxxxxxxxxxxxxxxxxx
Fixes: ae45f07d47cc ("quota: Simplify dquot_resume()")

EXT4-fs (loop0): warning: mounting fs with errors, running e2fsck is recommended
================================================================================
UBSAN: array-index-out-of-bounds in fs/quota/dquot.c:2169:24
index -1 is out of range for type 'struct inode *[3]'
CPU: 0 PID: 8448 Comm: syz-executor007 Not tainted 5.10.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x137/0x1be lib/dump_stack.c:118
ubsan_epilogue lib/ubsan.c:148 [inline]
__ubsan_handle_out_of_bounds+0xdb/0x130 lib/ubsan.c:356
vfs_cleanup_quota_inode fs/quota/dquot.c:2169 [inline]
dquot_resume+0x3f1/0x440 fs/quota/dquot.c:2458
ext4_remount+0x2455/0x3230 fs/ext4/super.c:6018
reconfigure_super+0x3b4/0x7b0 fs/super.c:957
do_remount fs/namespace.c:2612 [inline]
path_mount+0x1a1f/0x2a20 fs/namespace.c:3197
do_mount fs/namespace.c:3218 [inline]
__do_sys_mount fs/namespace.c:3426 [inline]
__se_sys_mount+0x28c/0x320 fs/namespace.c:3403
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x44c99a
Code: b8 08 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 dd ab fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 ba ab fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007fa03c8b9ba8 EFLAGS: 00000297 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00000000ffffffff RCX: 000000000044c99a
RDX: 0000000020000540 RSI: 0000000020000580 RDI: 0000000000000000
RBP: 00007fa03c8ba6d0 R08: 00007fa03c8b9c40 R09: 0000000000240038
R10: 0000000000240038 R11: 0000000000000297 R12: 00000000ffffffff
R13: 0000000000000000 R14: 0000000000000000 R15: 00007fa03c8b9c40
================================================================================


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

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches