Date: Tue, 11 Apr 2023 17:21:17 +0200 From: Michael van Elst <mlel...@serpens.de> Message-ID: <zdv67xp1ngvhy...@serpens.de>
| In that state then decrementing dk_rawopens beyond zero will make | dklastclose do the right thing: nothing. Except that if that happens, dk_rawopens will be left == ~0 and the next open attempt will then increment it, back to 0 again, which is almost certainly not what was wanted. dklastclose() used to have code in it like if (...->dk_rawopens > 0) { if (--...->dk_rawopens == 0) so that the -- would never be performed if rawopens was 0 when entered. | When you want to check for overflows of dk_rawopens (which is difficult | to overflow as you had to create 2^32 wedges) It wasn't the overflow that Taylor meant, but this underflow (from 0 -> ~0) which might be a problem. (Not really relevant, but it wouldn't be 2^32 wedges, but 2^32 simultaneous opens of any single wedge, right ... but that's not the real issue, that one probably can't happen on any normal system, the file table could never get big enough to allow 2^32 simultaneous opens of everything, let alone one device). Either dklastclose() can be called when dk_rawopens == 0 (in which case the current code is broken) or it cannot, in which case the assertion would have just verified that. kre