]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move lock earlier in the call sequence
authorMark Andrews <marka@isc.org>
Wed, 28 Aug 2024 03:07:54 +0000 (13:07 +1000)
committerMark Andrews <marka@isc.org>
Thu, 29 Aug 2024 04:33:56 +0000 (04:33 +0000)
fctx->state should be read with the lock held.

    1559        /*
    1560         * Caller must be holding the fctx lock.
    1561         */

    CID 468796: (#1 of 1): Data race condition (MISSING_LOCK)
    1. missing_lock: Accessing fctx->state without holding lock fetchctx.lock.
       Elsewhere, fetchctx.state is written to with fetchctx.lock held 2 out of 2 times.
    1562        REQUIRE(fctx->state == fetchstate_done);
    1563
    1564        FCTXTRACE("sendevents");
    1565
    1566        LOCK(&fctx->lock);
    1567

lib/dns/resolver.c

index a6f12fe4aaa71c75489c98d9381d10b9aee19475..6643bdc23385efc7eeb2a67a35dcbf582c4d40f7 100644 (file)
@@ -1556,15 +1556,12 @@ fctx_sendevents(fetchctx_t *fctx, isc_result_t result) {
        unsigned int new_spillat = 0; /* initialized to silence
                                       * compiler warnings */
 
-       /*
-        * Caller must be holding the fctx lock.
-        */
+       LOCK(&fctx->lock);
+
        REQUIRE(fctx->state == fetchstate_done);
 
        FCTXTRACE("sendevents");
 
-       LOCK(&fctx->lock);
-
        /*
         * Keep some record of fetch result for logging later (if required).
         */