syzbot


possible deadlock in v4l2_release

Status: auto-obsoleted due to no activity on 2022/09/03 06:25
Reported-by: syzbot+ea05c832a73d0615bf33@syzkaller.appspotmail.com
First crash: 1476d, last: 1436d

Cause bisection: introduced by (bisect log) :
commit 757fdb51c14fda221ccb6999a865f7f895c79750
Author: Hans Verkuil <hans.verkuil@cisco.com>
Date: Mon May 21 08:54:59 2018 +0000

  media: vivid: add request support

Crash: possible deadlock in v4l2_release (log)
Repro: C syz .config

Fix bisection: fixed by (bisect log) [no-op commit]:
commit b53119f13a04879c3bf502828d99d13726639ead
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Thu Mar 7 01:22:54 2019 +0000

  pin iocb through aio.

Patch testing requests:
Created Duration User Patch Repo Result
2022/09/03 01:27 19m upstream OK log
2022/09/01 12:27 16m linux-next OK log
2022/09/01 10:27 16m upstream OK log
2022/08/31 16:27 18m upstream OK log
2022/08/31 14:27 16m upstream OK log
2022/08/31 02:27 17m upstream OK log

Sample crash report:
audit: type=1800 audit(1542499591.861:30): pid=5853 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=collect_data cause=failed(directio) comm="startpar" name="rmnologin" dev="sda1" ino=2423 res=0

======================================================
WARNING: possible circular locking dependency detected
4.20.0-rc2+ #338 Not tainted
------------------------------------------------------
kworker/0:1/12 is trying to acquire lock:
00000000568502c5 (&mdev->req_queue_mutex){+.+.}, at: v4l2_release+0x1d7/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:455

but task is already holding lock:
000000009d901cd4 ((delayed_fput_work).work){+.+.}, at: process_one_work+0xb9a/0x1c40 kernel/workqueue.c:2128

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 ((delayed_fput_work).work){+.+.}:
       process_one_work+0xc0a/0x1c40 kernel/workqueue.c:2129
       worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
       kthread+0x35a/0x440 kernel/kthread.c:246
       ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

-> #2 ((wq_completion)"events"){+.+.}:
       flush_workqueue+0x30a/0x1e10 kernel/workqueue.c:2655
       flush_scheduled_work include/linux/workqueue.h:599 [inline]
       vim2m_stop_streaming+0x7c/0x2c0 drivers/media/platform/vim2m.c:811
       __vb2_queue_cancel+0x171/0xd20 drivers/media/common/videobuf2/videobuf2-core.c:1823
       vb2_core_queue_release+0x26/0x80 drivers/media/common/videobuf2/videobuf2-core.c:2229
       vb2_queue_release+0x15/0x20 drivers/media/common/videobuf2/videobuf2-v4l2.c:837
       v4l2_m2m_ctx_release+0x1e/0x35 drivers/media/v4l2-core/v4l2-mem2mem.c:930
       vim2m_release+0xe6/0x150 drivers/media/platform/vim2m.c:977
       v4l2_release+0x224/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:456
       __fput+0x385/0xa30 fs/file_table.c:278
       ____fput+0x15/0x20 fs/file_table.c:309
       task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
       tracehook_notify_resume include/linux/tracehook.h:188 [inline]
       exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
       prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
       syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
       do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #1 (&dev->dev_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:925 [inline]
       __mutex_lock+0x166/0x16f0 kernel/locking/mutex.c:1072
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087
       vim2m_release+0xbc/0x150 drivers/media/platform/vim2m.c:976
       v4l2_release+0x224/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:456
       __fput+0x385/0xa30 fs/file_table.c:278
       ____fput+0x15/0x20 fs/file_table.c:309
       task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
       tracehook_notify_resume include/linux/tracehook.h:188 [inline]
       exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
       prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
       syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
       do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&mdev->req_queue_mutex){+.+.}:
       lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844
       __mutex_lock_common kernel/locking/mutex.c:925 [inline]
       __mutex_lock+0x166/0x16f0 kernel/locking/mutex.c:1072
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087
       v4l2_release+0x1d7/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:455
       __fput+0x385/0xa30 fs/file_table.c:278
       delayed_fput+0x55/0x80 fs/file_table.c:304
       process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
       worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
       kthread+0x35a/0x440 kernel/kthread.c:246
       ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

other info that might help us debug this:

Chain exists of:
  &mdev->req_queue_mutex --> (wq_completion)"events" --> (delayed_fput_work).work

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock((delayed_fput_work).work);
                               lock((wq_completion)"events");
                               lock((delayed_fput_work).work);
  lock(&mdev->req_queue_mutex);

 *** DEADLOCK ***

2 locks held by kworker/0:1/12:
 #0: 00000000809bd6ac ((wq_completion)"events"){+.+.}, at: __write_once_size include/linux/compiler.h:209 [inline]
 #0: 00000000809bd6ac ((wq_completion)"events"){+.+.}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
 #0: 00000000809bd6ac ((wq_completion)"events"){+.+.}, at: atomic64_set include/asm-generic/atomic-instrumented.h:40 [inline]
 #0: 00000000809bd6ac ((wq_completion)"events"){+.+.}, at: atomic_long_set include/asm-generic/atomic-long.h:59 [inline]
 #0: 00000000809bd6ac ((wq_completion)"events"){+.+.}, at: set_work_data kernel/workqueue.c:617 [inline]
 #0: 00000000809bd6ac ((wq_completion)"events"){+.+.}, at: set_work_pool_and_clear_pending kernel/workqueue.c:644 [inline]
 #0: 00000000809bd6ac ((wq_completion)"events"){+.+.}, at: process_one_work+0xb43/0x1c40 kernel/workqueue.c:2124
 #1: 000000009d901cd4 ((delayed_fput_work).work){+.+.}, at: process_one_work+0xb9a/0x1c40 kernel/workqueue.c:2128

stack backtrace:
CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 4.20.0-rc2+ #338
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events delayed_fput
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_circular_bug.isra.35.cold.54+0x1bd/0x27d kernel/locking/lockdep.c:1221
 check_prev_add kernel/locking/lockdep.c:1863 [inline]
 check_prevs_add kernel/locking/lockdep.c:1976 [inline]
 validate_chain kernel/locking/lockdep.c:2347 [inline]
 __lock_acquire+0x3399/0x4c20 kernel/locking/lockdep.c:3341
 lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844
 __mutex_lock_common kernel/locking/mutex.c:925 [inline]
 __mutex_lock+0x166/0x16f0 kernel/locking/mutex.c:1072
 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087
 v4l2_release+0x1d7/0x3a0 drivers/media/v4l2-core/v4l2-dev.c:455
 __fput+0x385/0xa30 fs/file_table.c:278
 delayed_fput+0x55/0x80 fs/file_table.c:304
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

Crashes (181):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2018/11/18 00:09 upstream 1ce80e0fe98e adf636a8 .config log report syz C
ci-upstream-kasan-gce-smack-root 2018/11/17 17:03 upstream 1ce80e0fe98e b08ee62a .config log report syz C
ci-upstream-kasan-gce-selinux-root 2018/11/17 08:50 upstream e6a2562fe27f b08ee62a .config log report syz C
ci-upstream-kasan-gce 2018/11/17 08:23 upstream 1ce80e0fe98e b08ee62a .config log report syz C
ci-upstream-kasan-gce-386 2018/11/17 08:50 upstream 1ce80e0fe98e b08ee62a .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2018/11/17 08:49 linux-next 442b8cea2477 b08ee62a .config log report syz C
ci-upstream-kasan-gce 2018/12/25 22:28 upstream 8fe28cb58bcb 8a41a0ad .config log report
ci-upstream-kasan-gce 2018/12/25 17:12 upstream 8fe28cb58bcb 8a41a0ad .config log report
ci-upstream-kasan-gce 2018/12/24 20:38 upstream 8fe28cb58bcb 8a41a0ad .config log report
ci-upstream-kasan-gce 2018/12/24 13:07 upstream 8fe28cb58bcb be79df56 .config log report
ci-upstream-kasan-gce-root 2018/12/23 20:53 upstream 3c730b1041ae e3bd7ab8 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/23 19:01 upstream 9105b8aa50c1 e3bd7ab8 .config log report
ci-upstream-kasan-gce 2018/12/23 17:37 upstream 9105b8aa50c1 e3bd7ab8 .config log report
ci-upstream-kasan-gce 2018/12/23 02:19 upstream 23203e3f34c9 e3bd7ab8 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/22 19:50 upstream 23203e3f34c9 e3bd7ab8 .config log report
ci-upstream-kasan-gce 2018/12/22 17:27 upstream 23203e3f34c9 e3bd7ab8 .config log report
ci-upstream-kasan-gce 2018/12/22 11:35 upstream 5092adb2272e 603b5124 .config log report
ci-upstream-kasan-gce 2018/12/22 10:06 upstream 5092adb2272e 603b5124 .config log report
ci-upstream-kasan-gce 2018/12/21 21:11 upstream 5092adb2272e 588075e6 .config log report
ci-upstream-kasan-gce 2018/12/21 18:14 upstream 9097a058d49e 588075e6 .config log report
ci-upstream-kasan-gce 2018/12/21 13:59 upstream 9097a058d49e 588075e6 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/21 07:50 upstream 9097a058d49e 2b497001 .config log report
ci-upstream-kasan-gce 2018/12/21 02:23 upstream 9097a058d49e 2b497001 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/20 18:43 upstream 1d51b4b1d3f2 aaf59e84 .config log report
ci-upstream-kasan-gce 2018/12/19 09:11 upstream 62393dbcbe0f 4edaba93 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/17 22:33 upstream 7566ec393f41 def91db3 .config log report
ci-upstream-kasan-gce 2018/12/17 18:54 upstream 7566ec393f41 def91db3 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/17 16:49 upstream 7566ec393f41 def91db3 .config log report
ci-upstream-kasan-gce 2018/12/17 15:16 upstream 7566ec393f41 def91db3 .config log report
ci-upstream-kasan-gce-root 2018/12/17 13:12 upstream 7566ec393f41 def91db3 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/17 02:08 upstream 7566ec393f41 def91db3 .config log report
ci-upstream-kasan-gce 2018/12/16 15:07 upstream 6531e115b7ab def91db3 .config log report
ci-upstream-kasan-gce-selinux-root 2018/12/16 14:05 upstream 6531e115b7ab def91db3 .config log report
ci-upstream-kasan-gce 2018/12/16 09:10 upstream 6531e115b7ab def91db3 .config log report
ci-upstream-kasan-gce 2018/12/16 03:38 upstream 6531e115b7ab def91db3 .config log report
ci-upstream-kasan-gce-selinux-root 2018/12/15 20:18 upstream 6531e115b7ab def91db3 .config log report
ci-upstream-kasan-gce 2018/12/15 15:32 upstream 6531e115b7ab c9128939 .config log report
ci-upstream-kasan-gce-smack-root 2018/12/14 19:18 upstream eb6cf9f8cb9d 7624ddd6 .config log report
ci-upstream-kasan-gce 2018/12/14 06:24 upstream 65e08c5e8631 fe7127be .config log report
ci-upstream-kasan-gce 2018/12/14 04:33 upstream 65e08c5e8631 fe7127be .config log report
ci-upstream-kasan-gce 2018/12/13 10:56 upstream f5d582777bcb f3d9d594 .config log report
ci-upstream-kasan-gce 2018/11/15 11:17 upstream 5929a1f0ff30 5f5f6d14 .config log report
ci-upstream-kasan-gce-386 2018/12/25 21:35 upstream 8fe28cb58bcb 8a41a0ad .config log report
ci-upstream-kasan-gce-386 2018/12/23 01:18 upstream 23203e3f34c9 e3bd7ab8 .config log report
ci-upstream-kasan-gce-386 2018/12/22 01:51 upstream 5092adb2272e 603b5124 .config log report
ci-upstream-kasan-gce-386 2018/12/21 17:54 upstream 9097a058d49e 588075e6 .config log report
ci-upstream-kasan-gce-386 2018/12/20 13:50 upstream ab63e725b49c aaf59e84 .config log report
ci-upstream-kasan-gce-386 2018/12/18 11:14 upstream 1a9430db2835 def91db3 .config log report
ci-upstream-kasan-gce-386 2018/12/15 21:37 upstream 6531e115b7ab def91db3 .config log report
ci-upstream-kasan-gce-386 2018/12/14 11:18 upstream 65e08c5e8631 fe7127be .config log report
ci-upstream-kasan-gce-386 2018/12/13 23:34 upstream 65e08c5e8631 fe7127be .config log report
ci-upstream-kasan-gce-386 2018/12/12 22:21 upstream f5d582777bcb 02613a41 .config log report
ci-upstream-linux-next-kasan-gce-root 2018/11/29 10:11 linux-next 442b8cea2477 4b6d14f2 .config log report
* Struck through repros no longer work on HEAD.