Linux Input/HID development
 help / color / mirror / Atom feed
* [BUG] Input: sur40: KASAN slab-use-after-free in v4l2_release
@ 2026-06-15  2:06 Shuangpeng Bai
  0 siblings, 0 replies; only message in thread
From: Shuangpeng Bai @ 2026-06-15  2:06 UTC (permalink / raw)
  To: Dmitry Torokhov, Mauro Carvalho Chehab, linux-input, linux-media,
	linux-kernel

Hi,

I hit the following KASAN report while testing current upstream kernel.

The issue was reproduced with the sur40 driver. The report shows the object
being freed from sur40_disconnect(), then v4l2_release() accesses it when the
held V4L2 fd is closed. I have not confirmed whether this is specific to sur40
or a more generic V4L2 lifetime issue.

This looks similar to the rmi4_f54 V4L2 fd lifetime report I sent earlier:
https://lore.kernel.org/all/178144969601.60470.13645789994911690209@gmail.com/
That report involved rmi4_f54; in this report the freeing path is
sur40_disconnect().

KASAN: slab-use-after-free in v4l2_release (sur40)

I reproduced this on commit: e8c2f9fdadee7cbc75134dc463c1e0d856d6e5c7 (May 25 2026)

The reproducer and .config files are here.
https://gist.github.com/shuangpengbai/40c7b5bde2a7b2ddf95981beaebc0eed

I'm happy to test debug patches or provide additional information.

Reported-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>

[  323.412431][ T8724] BUG: KASAN: slab-use-after-free in v4l2_release (drivers/media/v4l2-core/v4l2-dev.c:466)
[  323.414158][ T8724] Read of size 8 at addr ffff888120d94458 by task repro_sur40_v4l/8724
[  323.415722][ T8724]
[  323.416236][ T8724] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[  323.416240][ T8724] Call Trace:
[  323.416251][ T8724]  <TASK>
[  323.416256][ T8724]  dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120)
[  323.416279][ T8724]  print_report (mm/kasan/report.c:378 mm/kasan/report.c:482)
[  323.416357][ T8724]  kasan_report (mm/kasan/report.c:595)
[  323.416370][ T8724]  v4l2_release (drivers/media/v4l2-core/v4l2-dev.c:466)
[  323.416375][ T8724]  __fput (fs/file_table.c:510)
[  323.416398][ T8724]  fput_close_sync (fs/file_table.c:615)
[  323.416447][ T8724]  __x64_sys_close (fs/open.c:1507 fs/open.c:1492 fs/open.c:1492)
[  323.416469][ T8724]  do_syscall_64 (arch/x86/entry/syscall_64.c:63 arch/x86/entry/syscall_64.c:94)
[  323.416491][ T8724]  entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
[  323.416497][ T8724] RIP: 0033:0x7fe066183c03
[  323.416504][ T8724] Code: e9 37 ff ff ff e8 2d f9 01 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 64 8b 04 25 18 00 00 00 85 c0 75 14 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8
[  323.416509][ T8724] RSP: 002b:00007ffdf8e8ecf8 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
[  323.416524][ T8724] RAX: ffffffffffffffda RBX: 0000000000000009 RCX: 00007fe066183c03
[  323.416528][ T8724] RDX: 01dd73bc7995e62a RSI: 0000000000000000 RDI: 000000000000000b
[  323.416531][ T8724] RBP: 0000000000000001 R08: 0000000000000009 R09: 0000000000000000
[  323.416534][ T8724] R10: 00007fe066129dd0 R11: 0000000000000246 R12: 0000000000000001
[  323.416537][ T8724] R13: 0000557a10ca7090 R14: 00007ffdf8e8eda0 R15: 0000000000000000
[  323.416544][ T8724]  </TASK>
[  323.416546][ T8724]
[  323.430976][ T8724] Freed by task 31 on cpu 1 at 322.408638s:
[  323.431417][ T8724]  kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:78)
[  323.431795][ T8724]  kasan_save_free_info (mm/kasan/generic.c:584)
[  323.432193][ T8724]  __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285)
[  323.432615][ T8724]  kfree (include/linux/kasan.h:235 mm/slub.c:2689 mm/slub.c:6251 mm/slub.c:6566)
[  323.433289][ T8724]  sur40_disconnect (drivers/input/touchscreen/sur40.c:832)
[  323.433680][ T8724]  usb_unbind_interface (drivers/usb/core/driver.c:458)
[  323.434121][ T8724]  device_release_driver_internal (drivers/base/dd.c:621 drivers/base/dd.c:1352 drivers/base/dd.c:1375)
[  323.434605][ T8724]  bus_remove_device (drivers/base/bus.c:657)
[  323.435042][ T8724]  device_del (drivers/base/core.c:3895)
[  323.435481][ T8724]  usb_disable_device (drivers/usb/core/message.c:1478)
[  323.436006][ T8724]  usb_disconnect (drivers/usb/core/hub.c:2315)
[  323.436489][ T8724]  hub_event (drivers/usb/core/hub.c:5407 drivers/usb/core/hub.c:5707 drivers/usb/core/hub.c:5871 drivers/usb/core/hub.c:5953)
[  323.436825][ T8724]  process_scheduled_works (kernel/workqueue.c:3314 kernel/workqueue.c:3397)
[  323.437403][ T8724]  worker_thread (kernel/workqueue.c:3478)
[  323.437873][ T8724]  kthread (kernel/kthread.c:436)
[  323.438298][ T8724]  ret_from_fork (kernel/process.c:158)
[  323.438778][ T8724]  ret_from_fork_asm (arch/x86/entry/entry_64.S:245)
[  323.439277][ T8724]
[  323.439513][ T8724] The buggy address belongs to the object at ffff888120d94000
[  323.439513][ T8724]  which belongs to the cache kmalloc-4k of size 4096
[  323.440921][ T8724] The buggy address is located 1112 bytes inside of
[  323.440921][ T8724]  freed 4096-byte region [ffff888120d94000, ffff888120d95000)
[  323.442314][ T8724]


Best,
Shuangpeng

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-15  2:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15  2:06 [BUG] Input: sur40: KASAN slab-use-after-free in v4l2_release Shuangpeng Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox