bcm2835-codec: NULL deref Oops after STREAMOFF / buffer-return race (Pi 4, Chromium H.264 decode, 6.18.50 and 6.18.60)

未關閉
#7,787 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
8/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
c, linux, raspberry-pi

研究方向

The race sits in the bcm2835-codec driver: start with buffer_work_cb and the stop_streaming path in drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c, and the videobuf2 cancel path in videobuf2-core.c near lines 1187 and 2222. Done would mean the NULL dereferences from the stop path no longer occur under a reproducer that stops the decoder while firmware returns buffers, but no reproducer exists yet. This is kernel-internal concurrency work and is not suited to a first contribution.

由索引模型根據 Issue 內容生成。

描述

Describe the bug

(with help of Claude ;-) ) i hope this helps others and you for fixing... Rob

On a Pi 4 running a Chromium kiosk, stopping the V4L2 hardware decoder occasionally triggers a WARNING in videobuf2. In 5 cases it coincided with a second WARNING in vb2_buffer_done on another CPU, and in 4 of those a NULL-pointer Oops followed within 12-300 ms in the bcm2835-codec / videobuf2-dma-contig path. After the Oops of 2026-11-23 the Chromium GPU process hung in D state inside a CMA allocation about 55 minutes later, which froze the display and touch (the machine stayed reachable over ssh). It happens on 6.18.50 and on 6.18.60.

I looked at the similar issues GitHub suggested (#7712, #7163, #7721). #7712 and #7163 are related in part, see "Additional context".

Steps to reproduce the behaviour

Not reproducible on demand; it happens sporadically on a kiosk that runs 24/7.

  1. Pi 4, Raspberry Pi OS (trixie, arm64), X11 session with openbox, Chromium in --app (kiosk) mode.
  2. The kiosk page rotates between a few dashboards every 20-30 s; one full rotation takes 80 s (the camera page is requested every 80 s according to my web server log).
  3. One dashboard plays three low-latency HLS streams from MediaMTX (all H.264, 640x360, 15-20 fps, about 0.2 Mbit/s each, video only: avc1.4d0016 for one, avc1.640016 for two). While that page is shown the Chromium GPU process has a /dev/video* node open; on the other dashboards it does not (checked via /proc//fd on 2026-11-11). So the decoder is started and stopped about every 80 s, roughly 1,000 times a day. The firmware log in the attached raspinfo shows one or two "video_decode:NN:RIL: resolution changing" messages per rotation.
  4. Leave it running. The events also happen at night when nobody is looking (e.g. 2026-11-09 05:51).
Device (s)

Raspberry Pi 4 Mod. B

System
  • Raspberry Pi reference 2026-06-18 (pi-gen ca8aeed0ae300c2a89f55ce9617d5f96a27e99e5, stage4), Debian 13 trixie, arm64; Xorg with KMS (vc4-kms-v3d-pi4), openbox
  • Kernel 6.18.50+rpt-rpi-v8 (1:6.18.50-1+rpt1) until 2026-11-08, 6.18.60+rpt-rpi-v8 (1:6.18.60-1+rpt1) from 2026-11-08 to 2026-11-12, and 6.18.50 again since 2026-11-12 13:06 (rolled back by copying vmlinuz/initrd into /boot/firmware; kernel packages on hold). Tainted G C (staging drivers), W after the first WARNING of a boot.
  • Firmware Sep 14 2026 14:49:30 (a86983925695a7e63166327d7c002d64040ed31d), bootloader EEPROM 2026-10-30, up to date
  • Chromium 155.0.8059.79 until 2026-11-08, 156.0.8078.79 since. Mesa 26.2.2 until 2026-11-08, then 26.2.6; 26.2.7 and rpi-chromium-mods 20261111 since 2026-11-22.
  • Relevant Chromium flags: --use-angle=gles --enable-gpu-rasterization --ozone-platform=x11; hardware video decode left at the default (enabled)
  • vcgencmd get_throttled = 0x0. See the attached raspinfo.
Logs

Combined event = WARNING at videobuf2-core.c:1187 (vb2_buffer_done, from buffer_work_cb) and WARNING at :2222 (__vb2_queue_cancel via v4l2_m2m_streamoff from Chromium's ThreadPoolSingl) in the same second, on different CPUs:

  • 2026-11-11 12:15:57 (6.18.60): via ip_buffer_cb, no Oops
  • 2026-11-11 19:04:40 (6.18.60): via ip_buffer_cb, Oops 16 ms later
  • 2026-11-12 11:40:58 (6.18.60): via ip_buffer_cb, Oops 19 ms later
  • 2026-11-13 15:42:48 (6.18.50): via op_buffer_cb, Oops about 300 ms later (15:42:49); "driver bug: stop_streaming operation is leaving buffer 6/7/8 in active state" in the same second
  • 2026-11-23 09:29:32 (6.18.50): via ip_buffer_cb, Oops 12 ms later; "driver bug: ... buffer 0/1/2/13/14/15 in active state" in the same second

The four Oopses (full traces in the attachment):

  1. 2026-11-11 19:04:40, 6.18.60, kworker (delayed_fput): NULL deref at 0x248, dma_release_from_dev_coherent <- dma_free_attrs <- vb2_dc_put <- vb2_dc_dmabuf_ops_release <- dma_buf_release <- __dentry_kill <- dput <- __fput <- delayed_fput
  2. 2026-11-12 11:40:58, 6.18.60, Chromium ThreadPoolSingl: NULL deref at 0x40, mutex_lock <- mmal_vchi_buffer_cleanup <- bcm2835_codec_buffer_cleanup <- __vb2_queue_free <- vb2_core_reqbufs <- vb2_reqbufs <- v4l2_m2m_ioctl_reqbufs <- v4l_reqbufs
  3. 2026-11-13 15:42:49, 6.18.50, Chromium (close() syscall): same signature as 1 (0x248, vb2_dc_put <- vb2_dc_dmabuf_ops_release <- dma_buf_release), via fput_close_sync / __arm64_sys_close instead of delayed_fput
  4. 2026-11-23 09:29:32, 6.18.50, kworker (delayed_fput): same signature as 1 (0x248)

My reading is that the firmware returns buffers (buffer_work_cb) while the decoder is being stopped, and the driver then touches state that is already gone. That is an interpretation of the traces, not something I verified in the source.

Consequence of the 2026-11-23 Oops: the last request from the kiosk page was at 10:24:40, about 55 minutes after the Oops. The Chromium GPU process was stuck in D state, could not be killed, load average 1.0 on an otherwise idle CPU:

__flush_work+0x258/0x350
flush_work+0x1c/0x30
__lru_add_drain_all+0x164/0x208
lru_cache_disable+0x68/0x80
alloc_contig_range_noprof+0x210/0x940
__cma_alloc+0x1b4/0x6e0
cma_alloc+0x28/0x40
cma_alloc_aligned+0x4c/0x60
dma_alloc_contiguous+0x38/0x60
dma_direct_alloc+0x118/0x3d0
dma_alloc_attrs+0x94/0x238
drm_gem_dma_create+0xb4/0x160 [drm_dma_helper]
drm_gem_dma_dumb_create_internal+0x60/0x80 [drm_dma_helper]
vc5_dumb_create+0x54/0x68 [vc4]
drm_mode_create_dumb_ioctl+0x98/0xc0 [drm]

After the Oops of 2026-11-11 the display and touch also froze (I did not capture a stack that time). After the Oopses of 11-12 and 11-13 I did not check whether the display froze.

Attached: kernelerror-syslogs.txt (all four Oopses with context), kernelissue-raspinfo-clean.txt (serial number, MAC address and EDID removed).

kernelissue-raspinfo-clean.txt

kernelerror-syslogs.txt

Additional context
  • Frequency: not deterministic. WARNING :2222 without the second warning: 2026-10-14, 10-15, 10-27 (six times between 11:31 and 21:47), 11-09 (05:51, 22:58), 11-11 14:58, 11-16, 11-20 (08:03, 14:37). No videobuf2 WARNING at all between 10-27 and 11-09. My logs start on 2026-10-11.
  • The :1187 combination and the Oopses do not appear in my logs before 2026-11-11 (10-11 to 11-10). On 2026-11-08 I updated several things at once (kernel 6.18.50 -> 6.18.60, Chromium 155 -> 156, Mesa 26.2.2 -> 26.2.6). Rolling back the kernel to 6.18.50 did not stop the Oopses (11-13, 11-23), so it is not specific to 6.18.60; I cannot tell whether Chromium 156 or Mesa matter.
  • Same messages as in #7712: "bcm2835_codec_flush_buffers: Timeout waiting for buffers to be returned - 0 outstanding", 8 times between 2026-10-26 and 2026-11-15 (10-26, 10-30, 11-01, 11-06, 11-12, 11-13 twice, 11-15), on both kernels. I have not tested the patch in #7713. It could be the same race with a more severe outcome here, but I cannot show that.
  • #7163 (CM4, MMAL timeouts and videobuf2 warnings when stopping live H.264): I see the same "driver bug ... leaving buffer in active state" lines (on 11-13 and 11-23) and a later comment there reports an Oops. I do not see "timed out waiting for sync completion" messages in my kernel log, so no firmware wedge as described there.
  • Also seen: "bcm2835_mmal_vchiq: buffer_work_cb: ... No mmal buffer to pass details" (2026-11-11 15:15 and 15:45) and "vc_sm_cma_vchi_rx_ack: received response 0, throw away..." on most days, also directly before the 11-11 events.
  • Not tested: --disable-accelerated-video-decode, other kernel versions, a reproducer without Chromium, the patch in #7713.
  • Related: Ubuntu LP #1915411 (similar __vb2_queue_cancel WARNING when stopping bcm2835-codec streams).
主要語言
C
星號
13.4k
分支
5.5k
平均合併
2 天 11 小時
30 天內合併 PR
32

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

raspberrypi/linux 的其他 Issue

查看 raspberrypi/linux 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。