]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lb_fas: Don't test the server's lb_tree from outside the lock
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 4 Jul 2019 09:59:42 +0000 (11:59 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 Jul 2019 12:26:15 +0000 (14:26 +0200)
In the function fas_srv_reposition(), the server's lb_tree is tested from
outside the lock. So it is possible to remove it after the test and then call
eb32_insert() in fas_queue_srv() with a NULL root pointer, which is
invalid. Moving the test in the scope of the lock fixes the bug.

This issue was reported on Github, issue #126.

This patch must be backported to 2.0, 1.9 and 1.8.

src/lb_fas.c

index 69b85d72df1577eb9508abd8fd17abe899ebcad9..6b72099f3da2aa7b329f0c197169de72586bd27c 100644 (file)
@@ -70,12 +70,11 @@ static inline void fas_queue_srv(struct server *s)
  */
 static void fas_srv_reposition(struct server *s)
 {
-       if (!s->lb_tree)
-               return;
-
        HA_SPIN_LOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
-       fas_dequeue_srv(s);
-       fas_queue_srv(s);
+       if (s->lb_tree) {
+               fas_dequeue_srv(s);
+               fas_queue_srv(s);
+       }
        HA_SPIN_UNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
 }