From nobody Mon Sep 28 08:07:53 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDBE13630AC for ; Mon, 24 Aug 2026 14:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787582923; cv=none; b=CkgBefbmagyRmjS6OEUXvbGHkU32uDs3aTNxAZ7vRwpjSN2QZhT0Uyu4g8a1v+GBe4gC7parGcNkKAD6C6sH53YkQh461/6COzRcUBmaVf8tDCY7j9PCq73hlLO+LQowODte8FqnQsn0s3FXSJZQInHXuy3TWrgG1QLxWhPxqrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787582923; c=relaxed/simple; bh=zgYb0g4/ZbLj1nEz72O4c+y3pPFdMyaiVYTduwIGTqg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=d5UseHErpGaESK6zsFdfYt2sZoAN1tbXBTFWoXSkXeXb50RkRe9CNo8GBfH1pHpFMCG0yCAMuSVESogVMrIWFxqUpWG6c1PJmRS8TkYlfMjb2keKxISA9gIoTr7afF59cp7Jy5wQGtGm+ZxfKv4xlUJwIG7QcIhnK6KHbyhvcRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=snu.ac.kr; spf=pass smtp.mailfrom=snu.ac.kr; dkim=pass (1024-bit key) header.d=snu.ac.kr header.i=@snu.ac.kr header.b=giU8a8OJ; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=snu.ac.kr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=snu.ac.kr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=snu.ac.kr header.i=@snu.ac.kr header.b="giU8a8OJ" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-84830c774a0so4011545b3a.1 for ; Mon, 24 Aug 2026 07:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=snu.ac.kr; s=google; t=1787582919; x=1788187719; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=pDBeWDp+XbPr7ncXEFfJAA0Z5cw3Q1kxIg2N5z42Wsw=; b=giU8a8OJ342d8L01ZbRGXY6XkQsQULP0nYWjtgrOqpt2o85XDPPrgwlhGGmVpLnnG1 s26BIiUOr1SCqjEYNyaC/S8QukazFwI8aZZGtV7f/9XkHMwuee30VBPHusME/kZz37mL GjpAHmmv+bNOjguySTnFjO8kdU8TfLKeKeVCM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787582919; x=1788187719; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pDBeWDp+XbPr7ncXEFfJAA0Z5cw3Q1kxIg2N5z42Wsw=; b=klXjYaiN5oetlKP/uBE/NidHOm7lJqHJ2tK8U0G51qCd8ibPJpuXbLWRZp/t/7ctna I3XW3yWE7RinrH8WI+Ddc4NEKCyBT7XRojUx7VIY56KaZhchFDhXrljypaT1fvPhk4Pi gU5pCd05tyxcb7Uh9l2Qc1if1SBIt8f5r3DXq6oIUO7ei0hvkWeIkfejy9k2YwiY6uR6 QjSi1XwPsCH+I3LQ+SSqKTXlBNbZ9GvWk+02Vj/yeRidAbFKWE5a57nKUGqAq0DHNuZL CoUNvXDrs8H6uXacGFLyx8VVWDbeEw8RFTPVVijP7bRrFEgR1aIhMlGfy3qTRpKQGRmq cz4A== X-Forwarded-Encrypted: i=1; AHgh+RrqoJVRX5pp9X/1fTYWgjsOLG7CfHaXSMY++OW65RL01JZVqbBgrk8gx+9+UMBAtGfgTitp/AM0oWrjrBw=@vger.kernel.org X-Gm-Message-State: AFuF++mdKgvHBW6lkVVA2b7f+TpymARfDmG1XPtfF5w+M5bMVU5Awa8x TyCKweQX4pgBmrBLaH4+OzxIr1D6Xl1YDRCRWW0ntdh/iOvdkMz44mGXUqL3bqsdiz8= X-Gm-Gg: AR+sD1007KOInItxD0dH1bo8tt7rOhWpq31M+eYCYQKr12HJ2b9rGgOYBkMsjOnffP0 DFBwcmj4/bhh5qTbwsFJTlP56DjhX8R1WdLQAVI07i2SwY2uwedU1lArO+io4FPO7PIrgmNI77K MsT3BbUAfuyl0AhAzq6ACAXI+uqaMcLdVTsnVbN/sigr2FEuj6jgu5u2m8jz1J/Yv1USbK9oFir +Rz82AkibXyDMSf6iHU1ECU27Bb7gvIG3+Ieiz3moPVkR9AUswjCsLsfw/pwIZI1DH2ECCR3UQ8 UrWGCnuxC34TNfT17uMxpVUazCfrE4eW03SR5MW/0yeCt/qtzWgLcTU1eX4Jt6AFwcTjOx41Di/ GbS4h1AmKTS7dwnHSbaWnNECo1Co6Qj3OtJDLJZwlj79JnS2/J0cSyaItcDodz0zk3m7MuxRaFU RVOdCqz28P+cLN63RbYUqVLIygUOjlzSf9ynp6YEkpDa9fy39ocjHNnRzIYEs/Lb1/xUGQmL4v3 VyfCANweHg7EM4CIYtkJGBPvTJrfUKHujJMkegh7HCUx52aApVVJz6xR7U1tkCb4zof7Je89WDr t1qX22pPNAh20SZgc9p8N8BTljzUsYXmSK3LIeJknTXI1+V9szGXhQ== X-Received: by 2002:a05:6a00:6ca2:b0:845:e7ee:eae7 with SMTP id d2e1a72fcca58-851f9a2f1edmr49018886b3a.5.1787582919100; Mon, 24 Aug 2026 07:48:39 -0700 (PDT) Received: from leesin ([147.46.121.37]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8520ef0911bsm2084283b3a.14.2026.08.24.07.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 07:48:38 -0700 (PDT) From: Jaeyoung Chung To: linux-media@vger.kernel.org, mchehab@kernel.org Cc: hverkuil+cisco@kernel.org, kees@kernel.org, linux-kernel@vger.kernel.org, ribalda@chromium.org, sakari.ailus@linux.intel.com, eulgyukim@snu.ac.kr, jjy600901@snu.ac.kr Subject: [BUG] WARNING: refcount bug in dvb_device_open Date: Mon, 24 Aug 2026 23:48:08 +0900 Message-ID: <20260824144832.2135903-1-jjy600901@snu.ac.kr> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hello, We found a "WARNING: refcount bug in dvb_device_open" on Linux v7.2. The issue was found by our own race fuzzer. We have not analyzed the root c= ause, so we do not have a proposed fix to offer. To reproduce the race reliably, we applied the delay patch below to the kernel and ran the C reproducer as root inside an x86_64 QEMU guest. The crash log we observed, the delay patch and the reproducer are all included below. The following kernel config options are required to reproduce the issue: CONFIG_MEDIA_SUPPORT=3Dy CONFIG_MEDIA_DIGITAL_TV_SUPPORT=3Dy CONFIG_DVB_CORE=3Dy CONFIG_DVB_VIDTV=3Dy # CONFIG_DVB_DYNAMIC_MINORS is not set CONFIG_DVB_TEST_DRIVERS=3Dy CONFIG_KASAN=3Dy We hope this report is useful. Please let us know if any further information would help. Reported-by: Eulgyu Kim Reported-by: Jaeyoung Chung Kernel delay patch: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- a/drivers/media/dvb-core/dvbdev.c 2026-08-21 00:29:05.580120458 +0900 +++ b/drivers/media/dvb-core/dvbdev.c 2026-08-21 00:29:05.652121379 +0900 @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include =20 /* Due to enum tuner_pad_index */ @@ -105,6 +111,9 @@ goto fail; file->private_data =3D dvb_device_get(dvbdev); replace_fops(file, new_fops); + if (strncmp(current->comm, "syzrepro1", 9) =3D=3D 0) { + mdelay(20); + } if (file->f_op->open) err =3D file->f_op->open(inode, file); up_read(&minor_rwsem); @@ -613,6 +625,9 @@ { struct dvb_device *dvbdev =3D container_of(ref, struct dvb_device, ref); =20 + if (strncmp(current->comm, "syzrepro", 8) =3D=3D 0) { + mdelay(60); + } kfree(dvbdev); } =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D C reproducer: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #define SYSCHK(x) ({ long __r =3D (long)(x); if (__r =3D=3D -1L) { perror(#= x); exit(1); } __r; }) #define DVB_MAJOR 212 #define FE_MINOR(a, id) (((a) << 6) | ((id) << 4) | 3) struct k_sigevent { uint64_t sigev_value; int sigev_signo, sigev_notify, sigev_tid, _pad[12]; }; static char g_path[256]; static pid_t g_pid; static volatile pid_t g_t1; static volatile int g_stop; static int usable(const char *p) { int fd =3D open(p, O_RDONLY | O_NONBLOCK); if (fd >=3D 0) { close(fd); return 1; } return errno =3D=3D EBUSY; } static int find_frontend(void) { int a, id; for (a =3D 0; a < 4; a++) { for (id =3D 0; id < 4; id++) { snprintf(g_path, sizeof(g_path), "/dev/dvb/adapter%d/frontend%d", a, id); if (usable(g_path)) return 0; snprintf(g_path, sizeof(g_path), "/tmp/fe%d", FE_MINOR(a, id)); unlink(g_path); if (mknod(g_path, S_IFCHR | 0600, makedev(DVB_MAJOR, FE_MINOR(a, id))) =3D=3D 0 && usable(g_path)) return 0; unlink(g_path); } } return -1; } static void noop(int sig) { (void)sig; } static void *opener(void *a) { (void)a; prctl(PR_SET_NAME, "syzrepro0", 0, 0, 0); while (!g_stop) { int fd =3D open(g_path, O_RDONLY | O_NONBLOCK); if (fd >=3D 0) close(fd); } return NULL; } /* T1: takes a signal inside dvb_device_open(), unwinding the open midway */ static void *victim(void *a) { struct k_sigevent sev =3D { .sigev_signo =3D SIGUSR1, .sigev_notify =3D 4 = }; struct itimerspec its =3D { { 0, 3000000 }, { 0, 3000000 } }; int timerid =3D 0; long i; (void)a; prctl(PR_SET_NAME, "syzrepro1", 0, 0, 0); g_t1 =3D sev.sigev_tid =3D syscall(__NR_gettid); if (syscall(__NR_timer_create, CLOCK_MONOTONIC, &sev, &timerid) =3D=3D 0) syscall(__NR_timer_settime, timerid, 0, &its, NULL); for (i =3D 0; i < 40 && !g_stop; i++) { int fd =3D open(g_path, O_RDWR | O_NOATIME); if (fd >=3D 0) close(fd); } g_stop =3D 1; return NULL; } static void *signaller(void *a) { (void)a; prctl(PR_SET_NAME, "syzrepro2", 0, 0, 0); while (!g_stop) { if (g_t1) syscall(__NR_tgkill, g_pid, g_t1, SIGUSR1); usleep(300); } return NULL; } int main(void) { struct sigaction sa =3D { .sa_handler =3D noop }; pthread_t a, b, c; prctl(PR_SET_NAME, "syzrepro3", 0, 0, 0); g_pid =3D getpid(); if (find_frontend() !=3D 0) { fprintf(stderr, "no dvb frontend\n"); return 1; } SYSCHK(sigaction(SIGUSR1, &sa, NULL)); pthread_create(&b, NULL, victim, NULL); pthread_create(&c, NULL, signaller, NULL); pthread_create(&a, NULL, opener, NULL); pthread_join(b, NULL); g_stop =3D 1; pthread_join(c, NULL); pthread_join(a, NULL); return 0; } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Crash log: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D refcount_t: addition on 0; use-after-free. WARNING: lib/refcount.c:25 at refcount_warn_saturate+0x76/0xd0 lib/refcount= .c:25, CPU#2: syzrepro0/411 Modules linked in: CPU: 2 UID: 0 PID: 411 Comm: syzrepro0 Not tainted 7.2.0-dirty #3 PREEMPT=20 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1= .1 04/01/2014 RIP: 0010:refcount_warn_saturate+0x76/0xd0 lib/refcount.c:25 Code: 3d ff af bd 04 67 48 0f b9 3a eb 4d 85 db 74 2f 83 fb 01 75 38 48 8d = 3d f8 af bd 04 67 48 0f b9 3a eb 36 48 8d 3d fa af bd 04 <67> 48 0f b9 3a e= b 28 48 8d 3d fc af bd 04 67 48 0f b9 3a eb 1a 48 RSP: 0018:ffff88810ab6f9e8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000002 RCX: dffffc0000000000 RDX: 0000000000000001 RSI: 0000000000000004 RDI: ffffffffbce53340 RBP: 00000000ffffffed R08: ffff88810344ff13 R09: 1ffff11020689fe2 R10: dffffc0000000000 R11: ffffed1020689fe3 R12: ffff88810344ff10 R13: ffff88810409a000 R14: ffff88810344ff10 R15: dffffc0000000000 FS: 00007fb58863a6c0(0000) GS:ffff888153bf7000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb588639f78 CR3: 000000010afa4000 CR4: 00000000000006f0 Call Trace: __refcount_add drivers/media/dvb-core/dvbdev.c:-1 [inline] __refcount_inc include/linux/refcount.h:366 [inline] refcount_inc include/linux/refcount.h:383 [inline] kref_get include/linux/kref.h:45 [inline] dvb_device_get drivers/media/dvb-core/dvbdev.c:629 [inline] dvb_device_open+0x340/0x370 drivers/media/dvb-core/dvbdev.c:108 chrdev_open+0x3b8/0x490 fs/char_dev.c:411 do_dentry_open+0x3f0/0x1120 fs/open.c:947 vfs_open+0x38/0x2b0 fs/open.c:1052 do_open fs/namei.c:4700 [inline] path_openat+0x21a0/0x29b0 fs/namei.c:4863 do_file_open+0x19d/0x360 fs/namei.c:4892 do_sys_openat2+0x9a/0x100 fs/open.c:1368 do_sys_open fs/open.c:1374 [inline] __do_sys_openat fs/open.c:1390 [inline] __se_sys_openat fs/open.c:1385 [inline] __x64_sys_openat+0xf8/0x130 fs/open.c:1385 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xf7/0x370 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7fb589738090 Code: 48 89 44 24 20 75 93 44 89 54 24 0c e8 a9 d7 f8 ff 44 8b 54 24 0c 89 = da 48 89 ee 41 89 c0 bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff f= f 77 38 44 89 c7 89 44 24 0c e8 fc d7 f8 ff 8b 44 RSP: 002b:00007fb588639e50 EFLAGS: 00000293 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 0000000000000800 RCX: 00007fb589738090 RDX: 0000000000000800 RSI: 00005c341bf5c060 RDI: 00000000ffffff9c RBP: 00005c341bf5c060 R08: 0000000000000000 R09: 00007ffece858747 R10: 0000000000000000 R11: 0000000000000293 R12: ffffffffffffff80 R13: 0000000000000000 R14: 00007ffece858650 R15: 00007fb587e3a000 ---[ end trace 0000000000000000 ]--- ---------------- Code disassembly (best guess): 0: 3d ff af bd 04 cmp $0x4bdafff,%eax 5: 67 48 0f b9 3a ud1 (%edx),%rdi a: eb 4d jmp 0x59 c: 85 db test %ebx,%ebx e: 74 2f je 0x3f 10: 83 fb 01 cmp $0x1,%ebx 13: 75 38 jne 0x4d 15: 48 8d 3d f8 af bd 04 lea 0x4bdaff8(%rip),%rdi # 0x4bdb014 1c: 67 48 0f b9 3a ud1 (%edx),%rdi 21: eb 36 jmp 0x59 23: 48 8d 3d fa af bd 04 lea 0x4bdaffa(%rip),%rdi # 0x4bdb024 * 2a: 67 48 0f b9 3a ud1 (%edx),%rdi <-- trapping instruction 2f: eb 28 jmp 0x59 31: 48 8d 3d fc af bd 04 lea 0x4bdaffc(%rip),%rdi # 0x4bdb034 38: 67 48 0f b9 3a ud1 (%edx),%rdi 3d: eb 1a jmp 0x59 3f: 48 rex.W =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D