129c0b7d48bbaea62170c5b404b9fd03dd6674de
[openwrt-packages.git] /
1 commit 3f0b1de623d09f8668db34c1be696f7245de7d50
2 Author: Christopher Faulet <cfaulet@haproxy.com>
3 Date:   Wed Jun 19 10:50:38 2019 +0200
4
5     BUG/MEDIUM: lb_fwlc: Don't test the server's lb_tree from outside the lock
6     
7     In the function fwlc_srv_reposition(), the server's lb_tree is tested from
8     outside the lock. So it is possible to remove it after the test and then call
9     eb32_insert() in fwlc_queue_srv() with a NULL root pointer, which is
10     invalid. Moving the test in the scope of the lock fixes the bug.
11     
12     This issue was reported on Github, issue #126.
13     
14     This patch must be backported to 2.0, 1.9 and 1.8.
15     
16     (cherry picked from commit 1ae2a8878170ded922f2c4d32b6704af7689bbfd)
17     Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
18
19 diff --git a/src/lb_fwlc.c b/src/lb_fwlc.c
20 index 174dc67e..5fa81739 100644
21 --- a/src/lb_fwlc.c
22 +++ b/src/lb_fwlc.c
23 @@ -66,12 +66,11 @@ static inline void fwlc_queue_srv(struct server *s)
24   */
25  static void fwlc_srv_reposition(struct server *s)
26  {
27 -       if (!s->lb_tree)
28 -               return;
29 -
30         HA_SPIN_LOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
31 -       fwlc_dequeue_srv(s);
32 -       fwlc_queue_srv(s);
33 +       if (s->lb_tree) {
34 +               fwlc_dequeue_srv(s);
35 +               fwlc_queue_srv(s);
36 +       }
37         HA_SPIN_UNLOCK(LBPRM_LOCK, &s->proxy->lbprm.lock);
38  }
39  
git clone https://git.99rst.org/PROJECT