Page MenuHomeFreeBSD

sound: Address race between pcm_unregister() and dsp_close()
AbandonedPublic

Authored by christos on Nov 20 2025, 3:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 4, 12:48 PM
Unknown Object (File)
Wed, Sep 16, 12:00 PM
Unknown Object (File)
Tue, Sep 15, 10:51 PM
Unknown Object (File)
Mon, Sep 14, 5:49 PM
Unknown Object (File)
Sun, Sep 13, 2:17 PM
Unknown Object (File)
Sep 6 2026, 1:08 PM
Unknown Object (File)
Sep 5 2026, 8:48 AM
Unknown Object (File)
Sep 5 2026, 8:28 AM
Subscribers
None

Details

Summary

There is an easily reproducable case (see modification in tests), where
pcm_unregister() will clear SD_F_REGISTERED and start killing channels
(pcm_killchans()), right before dsp_close() acquires the PCM lock, which
will can lead to a panic in dsp_close().

The fix is rather hacky and ugly, but it does the job for now.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68769
Build 65652: arc lint + arc unit

Event Timeline

christos created this revision.
christos retitled this revision from sound: Address race in dsp_close() to sound: Address race between pcm_unregister() and dsp_close().

Abandoning. It seems similar races exist across most syscalls, especially dsp_ioctl(). They can be triggered by running the test suite (with the patch here included) with -v parallelism=8.