From: Christopher Faulet Date: Fri, 19 Apr 2019 12:50:55 +0000 (+0200) Subject: BUG/MEDIUM: thread/http: Add missing locks in set-map and add-acl HTTP rules X-Git-Tag: v2.0-dev3~210 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e84289e5854aa3b00cd19032387f435ca6748491;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: thread/http: Add missing locks in set-map and add-acl HTTP rules Locks are missing in the rules "http-request set-map" and "http-response add-acl" when an acl or map update is performed. Pattern elements must be locked. This patch must be backported to 1.9 and 1.8. For the 1.8, the HTX part must be ignored. --- diff --git a/src/proto_http.c b/src/proto_http.c index e68b0e2f52..695ff7e33b 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -1750,12 +1750,14 @@ resume_execution: value->area[value->data] = '\0'; /* perform update */ + HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); if (pat_ref_find_elt(ref, key->area) != NULL) /* update entry if it exists */ pat_ref_set(ref, key->area, value->area, NULL); else /* insert a new entry */ pat_ref_add(ref, key->area, value->area, NULL); + HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); free_trash_chunk(value); @@ -2058,8 +2060,10 @@ resume_execution: /* perform update */ /* check if the entry already exists */ + HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); if (pat_ref_find_elt(ref, key->area) == NULL) pat_ref_add(ref, key->area, NULL, NULL); + HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); break; diff --git a/src/proto_htx.c b/src/proto_htx.c index 5643c625a4..d2c03e180b 100644 --- a/src/proto_htx.c +++ b/src/proto_htx.c @@ -2977,13 +2977,14 @@ static enum rule_result htx_req_get_intercept_rule(struct proxy *px, struct list value->area[value->data] = '\0'; /* perform update */ + HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); if (pat_ref_find_elt(ref, key->area) != NULL) /* update entry if it exists */ pat_ref_set(ref, key->area, value->area, NULL); else /* insert a new entry */ pat_ref_add(ref, key->area, value->area, NULL); - + HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); free_trash_chunk(value); break; @@ -3272,9 +3273,10 @@ resume_execution: /* perform update */ /* check if the entry already exists */ + HA_SPIN_LOCK(PATREF_LOCK, &ref->lock); if (pat_ref_find_elt(ref, key->area) == NULL) pat_ref_add(ref, key->area, NULL, NULL); - + HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock); free_trash_chunk(key); break; }