You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

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