linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] [media?] general protection fault in su3000_i2c_transfer
@ 2025-08-22  0:15 syzbot
  2025-08-22  2:09 ` [PATCH] i2c: dev: Block zero-length messages Lizhi Xu
  0 siblings, 1 reply; 2+ messages in thread
From: syzbot @ 2025-08-22  0:15 UTC (permalink / raw)
  To: linux-kernel, linux-media, mchehab, micha, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    8d561baae505 Merge tag 'x86_urgent_for_v6.17_rc2' of git:/..
git tree:       upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15226ba2580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ce98061fb8ee27bc
dashboard link: https://syzkaller.appspot.com/bug?extid=d99f3a288cc7d8ef60fb
compiler:       Debian clang version 20.1.7 (++20250616065708+6146a88f6049-1~exp1~20250616065826.132), Debian LLD 20.1.7
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=176206f0580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=102993a2580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/f70b0639e5f7/disk-8d561baa.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/8d12dcdbfe95/vmlinux-8d561baa.xz
kernel image: https://storage.googleapis.com/syzbot-assets/47f7ceb7ac19/bzImage-8d561baa.xz

The issue was bisected to:

commit 0e148a522b8453115038193e19ec7bea71403e4a
Author: Michael Bunk <micha@freedict.org>
Date:   Sun Jan 16 11:22:36 2022 +0000

    media: dw2102: Don't translate i2c read into write

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=14657ba2580000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=16657ba2580000
console output: https://syzkaller.appspot.com/x/log.txt?x=12657ba2580000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+d99f3a288cc7d8ef60fb@syzkaller.appspotmail.com
Fixes: 0e148a522b84 ("media: dw2102: Don't translate i2c read into write")

Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 1 UID: 0 PID: 5865 Comm: syz-executor259 Not tainted 6.17.0-rc1-syzkaller-00224-g8d561baae505 #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:su3000_i2c_transfer+0x1ad/0x1040 drivers/media/usb/dvb-usb/dw2102.c:740
Code: 4c 89 f8 48 c1 e8 03 49 bc 00 00 00 00 00 fc ff df 42 80 3c 20 00 74 08 4c 89 ff e8 8d b6 3c fa 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 0f b6 04 20 84 c0 0f 85 5f 09 00 00 0f b6 1b 48 8b 44 24 38 42
RSP: 0018:ffffc9000411faa8 EFLAGS: 00010202

RAX: 0000000000000002 RBX: 0000000000000010 RCX: 0000000000000003
RDX: ffffffff87e65d05 RSI: ffffffff8f0d3a50 RDI: 0000000000001900
RBP: 0000000000000000 R08: ffff888032dd0000 R09: 0000000000000002
R10: 0000000000001a00 R11: 0000000000000000 R12: dffffc0000000000
R13: 1ffff1100fb25968 R14: 0000000000000002 R15: ffff88807d92cb48
FS:  000055556ae14380(0000) GS:ffff888125d1b000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055b6f1430230 CR3: 000000007277a000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 __i2c_transfer+0x871/0x2170 drivers/i2c/i2c-core-base.c:-1
 i2c_transfer+0x25b/0x3a0 drivers/i2c/i2c-core-base.c:2320
 i2cdev_ioctl_rdwr+0x460/0x740 drivers/i2c/i2c-dev.c:306
 i2cdev_ioctl+0x64b/0x7f0 drivers/i2c/i2c-dev.c:467
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:598 [inline]
 __se_sys_ioctl+0xf9/0x170 fs/ioctl.c:584
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fc919191e19
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 31 17 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:00007ffcc5ebd038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fc9191cd533 RCX: 00007fc919191e19
RDX: 0000200000000a40 RSI: 0000000000000707 RDI: 0000000000000004
RBP: 00007fc919205610 R08: 0000000000002a00 R09: 00007ffcc5ebd208
R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffcc5ebd1f8 R14: 0000000000000001 R15: 0000000000000001
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:su3000_i2c_transfer+0x1ad/0x1040 drivers/media/usb/dvb-usb/dw2102.c:740
Code: 4c 89 f8 48 c1 e8 03 49 bc 00 00 00 00 00 fc ff df 42 80 3c 20 00 74 08 4c 89 ff e8 8d b6 3c fa 49 8b 1f 48 89 d8 48 c1 e8 03 <42> 0f b6 04 20 84 c0 0f 85 5f 09 00 00 0f b6 1b 48 8b 44 24 38 42
RSP: 0018:ffffc9000411faa8 EFLAGS: 00010202
RAX: 0000000000000002 RBX: 0000000000000010 RCX: 0000000000000003
RDX: ffffffff87e65d05 RSI: ffffffff8f0d3a50 RDI: 0000000000001900
RBP: 0000000000000000 R08: ffff888032dd0000 R09: 0000000000000002
R10: 0000000000001a00 R11: 0000000000000000 R12: dffffc0000000000
R13: 1ffff1100fb25968 R14: 0000000000000002 R15: ffff88807d92cb48
FS:  000055556ae14380(0000) GS:ffff888125c1b000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000562d24ac2168 CR3: 000000007277a000 CR4: 00000000003526f0
----------------
Code disassembly (best guess):
   0:	4c 89 f8             	mov    %r15,%rax
   3:	48 c1 e8 03          	shr    $0x3,%rax
   7:	49 bc 00 00 00 00 00 	movabs $0xdffffc0000000000,%r12
   e:	fc ff df
  11:	42 80 3c 20 00       	cmpb   $0x0,(%rax,%r12,1)
  16:	74 08                	je     0x20
  18:	4c 89 ff             	mov    %r15,%rdi
  1b:	e8 8d b6 3c fa       	call   0xfa3cb6ad
  20:	49 8b 1f             	mov    (%r15),%rbx
  23:	48 89 d8             	mov    %rbx,%rax
  26:	48 c1 e8 03          	shr    $0x3,%rax
* 2a:	42 0f b6 04 20       	movzbl (%rax,%r12,1),%eax <-- trapping instruction
  2f:	84 c0                	test   %al,%al
  31:	0f 85 5f 09 00 00    	jne    0x996
  37:	0f b6 1b             	movzbl (%rbx),%ebx
  3a:	48 8b 44 24 38       	mov    0x38(%rsp),%rax
  3f:	42                   	rex.X


---
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@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 report is already addressed, 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 report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

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

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] i2c: dev: Block zero-length messages
  2025-08-22  0:15 [syzbot] [media?] general protection fault in su3000_i2c_transfer syzbot
@ 2025-08-22  2:09 ` Lizhi Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Lizhi Xu @ 2025-08-22  2:09 UTC (permalink / raw)
  To: syzbot+d99f3a288cc7d8ef60fb
  Cc: linux-kernel, linux-media, mchehab, micha, syzkaller-bugs

The user passed two messages via ioctl, both of which were zero-length.
This caused i2cdev_ioctl_rdwr() to allocate zero-length memory for msgs[i].buf
when executing memdup_user(), resulting in a ZERO_SIZE_PTR.
i2cdev_ioctl_rdwr() did not handle this situation, leading to a null-ptr-deref
when accessing msgs[i].buf in su3000_i2c_transfer().

Adding a zero-length check in i2cdev_ioctl_rdwr() resolves the ZERO_SIZE_PTR
issue.

Reported-by: syzbot+d99f3a288cc7d8ef60fb@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d99f3a288cc7d8ef60fb
Tested-by: syzbot+d99f3a288cc7d8ef60fb@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
---
 drivers/i2c/i2c-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index e9577f920286..17b0bec53e21 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -257,7 +257,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
 	res = 0;
 	for (i = 0; i < nmsgs; i++) {
 		/* Limit the size of the message to a sane amount */
-		if (msgs[i].len > 8192) {
+		if (msgs[i].len > 8192 || msgs[i].len == 0) {
 			res = -EINVAL;
 			break;
 		}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-22  2:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22  0:15 [syzbot] [media?] general protection fault in su3000_i2c_transfer syzbot
2025-08-22  2:09 ` [PATCH] i2c: dev: Block zero-length messages Lizhi Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).