Re: git: d3690a599586 - stable/15 - devfs: make destroy_dev() a release barrier for cdevpriv destructors runs

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Thu, 18 Dec 2025 03:50:28 UTC
On 12/17/25 21:24, Konstantin Belousov wrote:
> On Wed, Dec 17, 2025 at 09:07:52PM +0000, Vladimir Kondratyev wrote:
>> The branch stable/15 has been updated by wulf:
>>
>> URL: https://cgit.FreeBSD.org/src/commit/?id=d3690a5995867e35d4d1dc63127343d4b0a092d6
>>
>> commit d3690a5995867e35d4d1dc63127343d4b0a092d6
>> Author:     Konstantin Belousov <kib@FreeBSD.org>
>> AuthorDate: 2025-10-23 18:37:00 +0000
>> Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
>> CommitDate: 2025-12-17 21:05:38 +0000
>>
>>      devfs: make destroy_dev() a release barrier for cdevpriv destructors runs
>>      
>>      Ensure that all destructors for cdevpriv finished running before
>>      destroy_dev() returns to the caller.  Otherwise, since
>>      devfs_destroy_cdevpriv() removes the cdevpriv data from the list, drops
>>      the cdevpriv_mtx, and then starts the destructor, it is possible for
>>      destroy_dev() to return before destructor finished in other thread.
>>      
>>      This should allow drivers to safely remove cdev instance data that might
>>      be referenced by cdevpriv data.
>>      
>>      Diagnosed by:   kevans
>>      Reviewed by:    kevans, markj
>>      Sponsored by:   The FreeBSD Foundation
>>      MFC after:      1 week
>>      Differential revision:  https://reviews.freebsd.org/D53303
>>      
>>      (cherry picked from commit 4dbe6628179d8e6bf400bfdb4bfa869bdc102a56)
> 
> I did not merged this to 15 (or 14) because if_tun has a regressions
> requiring some fixes from kevans, which were not merged.
> 

Ah, woof- sorry, it's been busy here.  I'll go ahead and merge the fix to stable/15.  The relevant
feature won't be merged to stable/14, so it should be safe to take it back there as well.

Thanks,

Kyle Evans