[syzbot] [block?] WARNING in blk_rq_map_user_iov

15 views
Skip to first unread message

syzbot

unread,
Sep 8, 2023, 7:55:06 AM9/8/23
to ax...@kernel.dk, dan.j.w...@intel.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, vi...@zeniv.linux.org.uk
Hello,

syzbot found the following issue on:

HEAD commit: 708283abf896 Merge tag 'dmaengine-6.6-rc1' of git://git.ke..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14142f38680000
kernel config: https://syzkaller.appspot.com/x/.config?x=1dc3cb855cd74c2
dashboard link: https://syzkaller.appspot.com/bug?extid=a532b03fdfee2c137666
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=115bfbf4680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13896ed0680000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/1bd71e72bfd8/disk-708283ab.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b1cd0be2dff5/vmlinux-708283ab.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ff76c3f9ca24/bzImage-708283ab.xz

The issue was bisected to:

commit a41dad905e5a388f88435a517de102e9b2c8e43d
Author: Al Viro <vi...@zeniv.linux.org.uk>
Date: Fri Sep 16 00:11:15 2022 +0000

iov_iter: saner checks for attempt to copy to/from iterator

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=127483b8680000
final oops: https://syzkaller.appspot.com/x/report.txt?x=117483b8680000
console output: https://syzkaller.appspot.com/x/log.txt?x=167483b8680000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+a532b0...@syzkaller.appspotmail.com
Fixes: a41dad905e5a ("iov_iter: saner checks for attempt to copy to/from iterator")

------------[ cut here ]------------
WARNING: CPU: 1 PID: 5033 at lib/iov_iter.c:385 _copy_from_iter+0x2c2/0x1270 lib/iov_iter.c:385
Modules linked in:
CPU: 1 PID: 5033 Comm: syz-executor399 Not tainted 6.5.0-syzkaller-11329-g708283abf896 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
RIP: 0010:_copy_from_iter+0x2c2/0x1270 lib/iov_iter.c:385
Code: 5d 41 5c 41 5d 41 5e 41 5f c3 e8 f9 8c 65 fd be 85 01 00 00 48 c7 c7 a0 94 e8 8a e8 d8 37 a5 fd e9 48 fe ff ff e8 de 8c 65 fd <0f> 0b 45 31 ff eb 88 e8 d2 8c 65 fd 31 ff 89 ee e8 f9 87 65 fd 40
RSP: 0018:ffffc900043c7480 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff888014b03b80 RSI: ffffffff84220fb2 RDI: 0000000000000001
RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: ffffffff8a60008b R12: 0000000000000001
R13: ffffc900043c76c8 R14: 0000000000000001 R15: 0000160000000000
FS: 0000555555a41380(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000200000c8 CR3: 000000007ebb3000 CR4: 0000000000350ee0
Call Trace:
<TASK>
copy_page_from_iter lib/iov_iter.c:542 [inline]
copy_page_from_iter+0xa5/0x120 lib/iov_iter.c:531
bio_copy_from_iter block/blk-map.c:56 [inline]
bio_copy_user_iov block/blk-map.c:211 [inline]
blk_rq_map_user_iov+0x9d5/0x1860 block/blk-map.c:662
blk_rq_map_user_io.part.0+0x276/0x2c0 block/blk-map.c:720
blk_rq_map_user_io+0xe6/0x230 block/blk-map.c:701
sg_start_req drivers/scsi/sg.c:1818 [inline]
sg_common_write.constprop.0+0xd61/0x1c90 drivers/scsi/sg.c:803
sg_new_write.isra.0+0x546/0xaa0 drivers/scsi/sg.c:770
sg_ioctl_common drivers/scsi/sg.c:935 [inline]
sg_ioctl+0x1814/0x2760 drivers/scsi/sg.c:1160
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:871 [inline]
__se_sys_ioctl fs/ioctl.c:857 [inline]
__x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:857
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f4cd02c0229
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff2da41248 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fff2da41418 RCX: 00007f4cd02c0229
RDX: 0000000020000300 RSI: 0000000000002285 RDI: 0000000000000003
RBP: 00007f4cd0333610 R08: 00007fff2da41418 R09: 00007fff2da41418
R10: 002367732f766564 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fff2da41408 R14: 0000000000000001 R15: 0000000000000001
</TASK>


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

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

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.

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Ricardo B. Marliere

unread,
Sep 12, 2023, 4:36:16 AM9/12/23
to syzbot, ax...@kernel.dk, dan.j.w...@intel.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com, vi...@zeniv.linux.org.uk
Flag iter as the data source if dxfer_direction is set to
SG_DXFER_TO_DEV or SG_DXFER_TO_FROM_DEV.

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

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 0d8afffd1683..991c6554bef4 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1737,8 +1737,13 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
Sg_scatter_hold *rsv_schp = &sfp->reserve;
struct request_queue *q = sfp->parentdp->device->request_queue;
struct rq_map_data *md, map_data;
- int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? ITER_SOURCE : ITER_DEST;
struct scsi_cmnd *scmd;
+ int rw;
+ if (hp->dxfer_direction == SG_DXFER_TO_DEV ||
+ hp->dxfer_direction == SG_DXFER_TO_FROM_DEV)
+ rw = ITER_SOURCE;
+ else
+ rw = ITER_DEST;

SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, sfp->parentdp,
"sg_start_req: dxfer_len=%d\n",

syzbot

unread,
Sep 12, 2023, 6:17:42 AM9/12/23
to ax...@kernel.dk, dan.j.w...@intel.com, linux...@vger.kernel.org, linux-...@vger.kernel.org, ric...@marliere.net, syzkall...@googlegroups.com, vi...@zeniv.linux.org.uk
Hello,

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

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

Tested on:

commit: 0bb80ecc Linux 6.6-rc1
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15c0be80680000
kernel config: https://syzkaller.appspot.com/x/.config?x=ba194e5cfd385dbf
dashboard link: https://syzkaller.appspot.com/bug?extid=a532b03fdfee2c137666
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=15e02dc8680000

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