Re: [syzbot] [media?] WARNING in call_s_stream

Laurent Pinchart
2024-04-16T06:53:51Z

On Tue, Apr 16, 2024 at 03:00:21PM +0900, Tomasz Figa wrote:
> On Thu, Mar 28, 2024 at 4:34 AM syzbot wrote:
> >
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit: 480e035fc4c7 Merge tag 'drm-next-2024-03-13' of https://gi..
> > git tree: upstream
> > console output: https://syzkaller.appspot.com/x/log.txt?x=141370b1180000
> > kernel config: https://syzkaller.appspot.com/x/.config?x=1e5b814e91787669
> > dashboard link: https://syzkaller.appspot.com/bug?extid=5bcd7c809d365e14c4df
> > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
> >
> > Unfortunately, I don't have any reproducer for this issue yet.
> >
> > Downloadable assets:
> > disk image: https://storage.googleapis.com/syzbot-assets/5f73b6ef963d/disk-480e035f.raw.xz
> > vmlinux: https://storage.googleapis.com/syzbot-assets/46c949396aad/vmlinux-480e035f.xz
> > kernel image: https://storage.googleapis.com/syzbot-assets/e3b4d0f5a5f8/bzImage-480e035f.xz
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+5bcd7c809d365e14c4df@syzkaller.appspotmail.com
> >
> > vimc vimc.0: subdev_call error Scaler
> > ------------[ cut here ]------------
> > WARNING: CPU: 1 PID: 7323 at drivers/media/v4l2-core/v4l2-subdev.c:412 call_s_stream+0x1f5/0x220 drivers/media/v4l2-core/v4l2-subdev.c:412
>
> Looks like vimc is trying to stop an already stopped subdev and a
> warning was added by commit 009905ec50433 ("media: v4l2-subdev:
> Document and enforce .s_stream() requirements") to catch it.
> Shuah, Kieran, could you help with this?
>
> Also CC Laurent, Sakari and Hans who added the warning.

An easy fix would be to skip the .s_stream() call for entities that
haven't been started, by tracking their streaming state in vimc. A
better fix may be to propagate the .s_stream() calls from subdev to
subdev like in the real world, instead of calling it on all subdevs in a
loop.

Somewhere very deep on my todo list is to rewrite a large part of vimc
to make it closer to a real sensor + ISP device. I still hope someone
will beat me to it :-)

> > Modules linked in:
> > CPU: 1 PID: 7323 Comm: syz-executor.4 Not tainted 6.8.0-syzkaller-08073-g480e035fc4c7 #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024
> > RIP: 0010:call_s_stream+0x1f5/0x220 drivers/media/v4l2-core/v4l2-subdev.c:412
> > Code: c1 e8 03 80 3c 28 00 74 08 4c 89 ff e8 a4 79 4c fa 49 8b 3f 48 c7 c6 a0 5a 64 8c 89 da e8 03 d0 c7 03 eb 9e e8 6c 2a e9 f9 90 <0f> 0b 90 eb b0 44 89 e1 80 e1 07 80 c1 03 38 c1 0f 8c ca fe ff ff
> > RSP: 0018:ffffc9000939f880 EFLAGS: 00010293
> > RAX: ffffffff87abcae4 RBX: 0000000000000000 RCX: ffff88801ee13c00
> > RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
> > RBP: 0000000000000001 R08: ffffffff87abc951 R09: 1ffff92001273e78
> > R10: dffffc0000000000 R11: ffffffff87abc8f0 R12: ffff888024a6c190
> > R13: 0000000000000000 R14: 1ffff1100494d832 R15: ffff888024a6c020
> > FS: 00007ff8da9646c0(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
> > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > CR2: 00007f3e3ed79198 CR3: 0000000049c48000 CR4: 00000000003506f0
> > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> > Call Trace:
> > <TASK>
> > vimc_streamer_pipeline_terminate+0x219/0x360 drivers/media/test-drivers/vimc/vimc-streamer.c:62
> > vimc_streamer_s_stream+0x69f/0x800 drivers/media/test-drivers/vimc/vimc-streamer.c:203
> > vimc_capture_start_streaming+0x230/0x440 drivers/media/test-drivers/vimc/vimc-capture.c:255
> > vb2_start_streaming+0x12e/0x510 drivers/media/common/videobuf2/videobuf2-core.c:1676
> > vb2_core_qbuf+0x87d/0x13b0 drivers/media/common/videobuf2/videobuf2-core.c:1850
> > vb2_qbuf+0x31b/0x3b0 drivers/media/common/videobuf2/videobuf2-v4l2.c:827
> > __video_do_ioctl+0xc26/0xde0 drivers/media/v4l2-core/v4l2-ioctl.c:3049
> > video_usercopy+0x899/0x1180 drivers/media/v4l2-core/v4l2-ioctl.c:3390
> > v4l2_ioctl+0x18c/0x1e0 drivers/media/v4l2-core/v4l2-dev.c:364
> > vfs_ioctl fs/ioctl.c:51 [inline]
> > __do_sys_ioctl fs/ioctl.c:904 [inline]
> > __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:890
> > do_syscall_64+0xfb/0x240
> > entry_SYSCALL_64_after_hwframe+0x6d/0x75
> > RIP: 0033:0x7ff8d9c7dda9
> > Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48
> > RSP: 002b:00007ff8da9640c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> > RAX: ffffffffffffffda RBX: 00007ff8d9dac050 RCX: 00007ff8d9c7dda9
> > RDX: 00000000200000c0 RSI: 00000000c058560f RDI: 0000000000000003
> > RBP: 00007ff8d9cca47a R08: 0000000000000000 R09: 0000000000000000
> > R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> > R13: 000000000000006e R14: 00007ff8d9dac050 R15: 00007ff8d9ecfa48
> > </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 syzkaller@googlegroups.com.
> >
> > syzbot will keep track of this issue. See:
> > https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
> >
> > If the report is already addressed, let syzbot know by replying with:
> > #syz fix: exact-commit-title
> >
> > 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
> >

--
Regards,

Laurent Pinchart