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, Sep 6, 1:08 PM
Unknown Object (File)
Sat, Sep 5, 8:48 AM
Unknown Object (File)
Sat, Sep 5, 8:28 AM
Unknown Object (File)
Sat, Sep 5, 5:30 AM
Unknown Object (File)
Fri, Sep 4, 5:59 AM
Unknown Object (File)
Thu, Sep 3, 1:34 PM
Unknown Object (File)
Wed, Sep 2, 4:14 AM
Unknown Object (File)
Tue, Sep 1, 1:23 PM
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.