[syzbot] general protection fault in sg_alloc_append_table_from_pages

20 views
Skip to first unread message

syzbot

unread,
Oct 13, 2021, 12:51:24 PM10/13/21
to christia...@amd.com, dri-...@lists.freedesktop.org, gurchet...@chromium.org, kra...@redhat.com, linaro...@lists.linaro.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, sumit....@linaro.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 717478d89fe2 Merge tag 'riscv-for-linus-5.15-rc5' of git:/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12489abf300000
kernel config: https://syzkaller.appspot.com/x/.config?x=32e6048063923b7b
dashboard link: https://syzkaller.appspot.com/bug?extid=2c56b725ec547fa9cb29
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=167b9e4f300000

The issue was bisected to:

commit 284562e1f34874e267d4f499362c3816f8f6bc3f
Author: Gurchetan Singh <gurchet...@chromium.org>
Date: Tue Dec 3 01:36:27 2019 +0000

udmabuf: implement begin_cpu_access/end_cpu_access hooks

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

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2c56b7...@syzkaller.appspotmail.com
Fixes: 284562e1f348 ("udmabuf: implement begin_cpu_access/end_cpu_access hooks")

general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 1 PID: 7990 Comm: syz-executor.0 Not tainted 5.15.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:sg_alloc_append_table_from_pages+0x821/0xdb0 lib/scatterlist.c:525
Code: 0c 24 48 8b 4c 24 48 48 39 c8 48 0f 46 c8 89 f0 4c 8d 3c c7 48 89 4c 24 30 48 b9 00 00 00 00 00 fc ff df 4c 89 f8 48 c1 e8 03 <80> 3c 08 00 0f 85 24 05 00 00 4d 8b 3f 4c 89 e0 31 ff 83 e0 03 48
RSP: 0018:ffffc90006087c48 EFLAGS: 00010212
RAX: 0000000000000002 RBX: 0000000000000001 RCX: dffffc0000000000
RDX: ffff888074588000 RSI: 0000000000000000 RDI: 0000000000000010
RBP: 00000000fffff000 R08: fffffffffffff000 R09: ffff88801afe1940
R10: ffffffff83d737d0 R11: 0000000000000000 R12: 0000000000000002
R13: ffff88801afe1940 R14: 0000000000000000 R15: 0000000000000010
FS: 00007fd273545700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fd273545718 CR3: 000000001a51c000 CR4: 0000000000350ee0
Call Trace:
sg_alloc_table_from_pages_segment+0xc9/0x260 lib/scatterlist.c:573
sg_alloc_table_from_pages include/linux/scatterlist.h:331 [inline]
get_sg_table.isra.0+0xbb/0x160 drivers/dma-buf/udmabuf.c:67
begin_cpu_udmabuf+0x130/0x1d0 drivers/dma-buf/udmabuf.c:126
dma_buf_begin_cpu_access+0xfd/0x1d0 drivers/dma-buf/dma-buf.c:1204
dma_buf_ioctl+0x29a/0x380 drivers/dma-buf/dma-buf.c:403
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:874 [inline]
__se_sys_ioctl fs/ioctl.c:860 [inline]
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fd273e108d9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd273545188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fd273f150e0 RCX: 00007fd273e108d9
RDX: 0000000020000000 RSI: 0000000040086200 RDI: 0000000000000004
RBP: 00007fd273e6acb4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd358e3ccf R14: 00007fd273545300 R15: 0000000000022000
Modules linked in:
---[ end trace 225c119d3f055d42 ]---
RIP: 0010:sg_alloc_append_table_from_pages+0x821/0xdb0 lib/scatterlist.c:525
Code: 0c 24 48 8b 4c 24 48 48 39 c8 48 0f 46 c8 89 f0 4c 8d 3c c7 48 89 4c 24 30 48 b9 00 00 00 00 00 fc ff df 4c 89 f8 48 c1 e8 03 <80> 3c 08 00 0f 85 24 05 00 00 4d 8b 3f 4c 89 e0 31 ff 83 e0 03 48
RSP: 0018:ffffc90006087c48 EFLAGS: 00010212
RAX: 0000000000000002 RBX: 0000000000000001 RCX: dffffc0000000000
RDX: ffff888074588000 RSI: 0000000000000000 RDI: 0000000000000010
RBP: 00000000fffff000 R08: fffffffffffff000 R09: ffff88801afe1940
R10: ffffffff83d737d0 R11: 0000000000000000 R12: 0000000000000002
R13: ffff88801afe1940 R14: 0000000000000000 R15: 0000000000000010
FS: 00007fd273545700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fd273545718 CR3: 000000001a51c000 CR4: 0000000000350ee0
----------------
Code disassembly (best guess):
0: 0c 24 or $0x24,%al
2: 48 8b 4c 24 48 mov 0x48(%rsp),%rcx
7: 48 39 c8 cmp %rcx,%rax
a: 48 0f 46 c8 cmovbe %rax,%rcx
e: 89 f0 mov %esi,%eax
10: 4c 8d 3c c7 lea (%rdi,%rax,8),%r15
14: 48 89 4c 24 30 mov %rcx,0x30(%rsp)
19: 48 b9 00 00 00 00 00 movabs $0xdffffc0000000000,%rcx
20: fc ff df
23: 4c 89 f8 mov %r15,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 80 3c 08 00 cmpb $0x0,(%rax,%rcx,1) <-- trapping instruction
2e: 0f 85 24 05 00 00 jne 0x558
34: 4d 8b 3f mov (%r15),%r15
37: 4c 89 e0 mov %r12,%rax
3a: 31 ff xor %edi,%edi
3c: 83 e0 03 and $0x3,%eax
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.
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

syzbot

unread,
Dec 19, 2021, 12:27:20 PM12/19/21
to christia...@amd.com, dri-...@lists.freedesktop.org, gurchet...@chromium.org, kra...@redhat.com, linaro-mm...@lists.linaro.org, linaro...@lists.linaro.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, sumit....@linaro.org, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 3f667b5d4053 Merge tag 'tty-5.16-rc6' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=174324a3b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=fa556098924b78f0
dashboard link: https://syzkaller.appspot.com/bug?extid=2c56b725ec547fa9cb29
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14df5c71b00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11d67495b00000

The issue was bisected to:

commit 284562e1f34874e267d4f499362c3816f8f6bc3f
Author: Gurchetan Singh <gurchet...@chromium.org>
Date: Tue Dec 3 01:36:27 2019 +0000

udmabuf: implement begin_cpu_access/end_cpu_access hooks

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

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2c56b7...@syzkaller.appspotmail.com
Fixes: 284562e1f348 ("udmabuf: implement begin_cpu_access/end_cpu_access hooks")

general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 1 PID: 3595 Comm: syz-executor559 Not tainted 5.16.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:sg_alloc_append_table_from_pages+0x821/0xdb0 lib/scatterlist.c:525 lib/scatterlist.c:525
Code: 0c 24 48 8b 4c 24 48 48 39 c8 48 0f 46 c8 89 f0 4c 8d 3c c7 48 89 4c 24 30 48 b9 00 00 00 00 00 fc ff df 4c 89 f8 48 c1 e8 03 <80> 3c 08 00 0f 85 24 05 00 00 4d 8b 3f 4c 89 e0 31 ff 83 e0 03 48
RSP: 0018:ffffc90002d0fc48 EFLAGS: 00010212
RAX: 0000000000000002 RBX: 0000000000000001 RCX: dffffc0000000000
RDX: ffff888021fd5700 RSI: 0000000000000000 RDI: 0000000000000010
RBP: 00000000fffff000 R08: fffffffffffff000 R09: ffff8880189ddb00
R10: ffffffff83d88b30 R11: 0000000000000000 R12: 0000000000000002
R13: ffff8880189ddb00 R14: 0000000000000000 R15: 0000000000000010
FS: 000055555652c300(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020005b4c CR3: 00000000176ae000 CR4: 0000000000350ee0
Call Trace:
<TASK>
sg_alloc_table_from_pages_segment+0xc9/0x260 lib/scatterlist.c:573 lib/scatterlist.c:573
sg_alloc_table_from_pages include/linux/scatterlist.h:331 [inline]
sg_alloc_table_from_pages include/linux/scatterlist.h:331 [inline] drivers/dma-buf/udmabuf.c:67
get_sg_table.isra.0+0xbb/0x160 drivers/dma-buf/udmabuf.c:67 drivers/dma-buf/udmabuf.c:67
begin_cpu_udmabuf+0x130/0x1d0 drivers/dma-buf/udmabuf.c:126 drivers/dma-buf/udmabuf.c:126
dma_buf_begin_cpu_access+0xfd/0x1d0 drivers/dma-buf/dma-buf.c:1175 drivers/dma-buf/dma-buf.c:1175
dma_buf_ioctl+0x29a/0x380 drivers/dma-buf/dma-buf.c:374 drivers/dma-buf/dma-buf.c:374
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:874 [inline]
__se_sys_ioctl fs/ioctl.c:860 [inline]
vfs_ioctl fs/ioctl.c:51 [inline] fs/ioctl.c:860
__do_sys_ioctl fs/ioctl.c:874 [inline] fs/ioctl.c:860
__se_sys_ioctl fs/ioctl.c:860 [inline] fs/ioctl.c:860
__x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860 fs/ioctl.c:860
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_x64 arch/x86/entry/common.c:50 [inline] arch/x86/entry/common.c:80
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f57966b60a9
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:00007ffea34a0a78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f57966b60a9
RDX: 0000000020000000 RSI: 0000000040086200 RDI: 0000000000000004
RBP: 00007f579667a090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f579667a120
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>
Modules linked in:
---[ end trace ed55bd5e5ccee2ad ]---
RIP: 0010:sg_alloc_append_table_from_pages+0x821/0xdb0 lib/scatterlist.c:525 lib/scatterlist.c:525
Code: 0c 24 48 8b 4c 24 48 48 39 c8 48 0f 46 c8 89 f0 4c 8d 3c c7 48 89 4c 24 30 48 b9 00 00 00 00 00 fc ff df 4c 89 f8 48 c1 e8 03 <80> 3c 08 00 0f 85 24 05 00 00 4d 8b 3f 4c 89 e0 31 ff 83 e0 03 48
RSP: 0018:ffffc90002d0fc48 EFLAGS: 00010212
RAX: 0000000000000002 RBX: 0000000000000001 RCX: dffffc0000000000
RDX: ffff888021fd5700 RSI: 0000000000000000 RDI: 0000000000000010
RBP: 00000000fffff000 R08: fffffffffffff000 R09: ffff8880189ddb00
R10: ffffffff83d88b30 R11: 0000000000000000 R12: 0000000000000002
R13: ffff8880189ddb00 R14: 0000000000000000 R15: 0000000000000010
FS: 000055555652c300(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055c8ef357220 CR3: 00000000176ae000 CR4: 0000000000350ef0

Pavel Skripkin

unread,
Dec 30, 2021, 8:53:25 AM12/30/21
to syzbot, christia...@amd.com, dri-...@lists.freedesktop.org, gurchet...@chromium.org, kra...@redhat.com, linaro...@lists.linaro.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, sumit....@linaro.org, syzkall...@googlegroups.com
On 10/13/21 19:51, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 717478d89fe2 Merge tag 'riscv-for-linus-5.15-rc5' of git:/..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=12489abf300000
> kernel config: https://syzkaller.appspot.com/x/.config?x=32e6048063923b7b
> dashboard link: https://syzkaller.appspot.com/bug?extid=2c56b725ec547fa9cb29
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=167b9e4f300000
>
> The issue was bisected to:
>
> commit 284562e1f34874e267d4f499362c3816f8f6bc3f
> Author: Gurchetan Singh <gurchet...@chromium.org>
> Date: Tue Dec 3 01:36:27 2019 +0000
>
> udmabuf: implement begin_cpu_access/end_cpu_access hooks
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12d68447300000
> final oops: https://syzkaller.appspot.com/x/report.txt?x=11d68447300000
> console output: https://syzkaller.appspot.com/x/log.txt?x=16d68447300000
>

zero ubuf->pagecount will cause kmalloc_array() to return ZERO_PTR, that
is unsafe to deref

#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master



With regards,
Pavel Skripkin
ph

syzbot

unread,
Dec 30, 2021, 9:04:10 AM12/30/21
to christia...@amd.com, dri-...@lists.freedesktop.org, gurchet...@chromium.org, kra...@redhat.com, linaro...@lists.linaro.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, paskr...@gmail.com, sumit....@linaro.org, syzkall...@googlegroups.com
Hello,

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

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

Tested on:

commit: eec4df26 Merge tag 's390-5.16-6' of git://git.kernel.o..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=1bce7595e2f1eaf8
dashboard link: https://syzkaller.appspot.com/bug?extid=2c56b725ec547fa9cb29
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=14fe2f47b00000

Note: testing is done by a robot and is best-effort only.
Reply all
Reply to author
Forward
0 new messages