]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix CID 352776: Concurrent data access violations
authorMatthijs Mekking <matthijs@isc.org>
Mon, 16 May 2022 17:00:47 +0000 (19:00 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 23 May 2022 10:00:45 +0000 (12:00 +0200)
*** CID 352776:  Concurrent data access violations  (MISSING_LOCK)
/lib/dns/dst_api.c: 474 in dst_key_setmodified()
468     dst_key_isexternal(dst_key_t *key) {
469 return (key->external);
470     }
471
472     void
473     dst_key_setmodified(dst_key_t *key, bool value) {
>>>     CID 352776:  Concurrent data access violations  (MISSING_LOCK)
>>>     Accessing "key->modified" without holding lock
>>> "dst_key.mdlock". Elsewhere, "dst_key.modified" is accessed with
>>> "dst_key.mdlock" held 8 out of 11 times (8 of these accesses
>>> strongly imply that it is necessary).
474 key->modified = value;
475     }
476
477     bool
478     dst_key_ismodified(dst_key_t *key) {
479 return (key->modified);

(cherry picked from commit 1fa24d0afbc01d25d71446156758b3a945db5b5f)

lib/dns/dst_api.c
lib/dns/include/dst/dst.h

index f36f087fd0e9cbe6f71b78b0b942ac2892b9150b..237ddc05153495a1cb19f1165dafa26bf0ebcc43 100644 (file)
@@ -471,12 +471,20 @@ dst_key_isexternal(dst_key_t *key) {
 
 void
 dst_key_setmodified(dst_key_t *key, bool value) {
+       isc_mutex_lock(&key->mdlock);
        key->modified = value;
+       isc_mutex_unlock(&key->mdlock);
 }
 
 bool
-dst_key_ismodified(dst_key_t *key) {
-       return (key->modified);
+dst_key_ismodified(const dst_key_t *key) {
+       bool modified;
+
+       isc_mutex_lock(&(((dst_key_t *)key)->mdlock));
+       modified = key->modified;
+       isc_mutex_unlock(&(((dst_key_t *)key)->mdlock));
+
+       return (modified);
 }
 
 isc_result_t
index 8fe32ab15c03081d2aea7310ac413ad8e736581e..fdd2122b20465f3a37a600072ca9f90b0aef2062 100644 (file)
@@ -1118,7 +1118,7 @@ dst_key_setmodified(dst_key_t *key, bool value);
  */
 
 bool
-dst_key_ismodified(dst_key_t *key);
+dst_key_ismodified(const dst_key_t *key);
 /*%<
  * Check if the key file has been modified.
  *