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.

67 lines
3.0 KiB

  1. commit 83af1f6b65806982640679823228976deebf5202
  2. Author: Willy Tarreau <w@1wt.eu>
  3. Date: Tue Apr 30 11:43:43 2019 +0200
  4. BUG/MAJOR: map/acl: real fix segfault during show map/acl on CLI
  5. A previous commit 8d85aa44d ("BUG/MAJOR: map: fix segfault during
  6. 'show map/acl' on cli.") was provided to address a concurrency issue
  7. between "show acl" and "clear acl" on the CLI. Sadly the code placed
  8. there was copy-pasted without changing the element type (which was
  9. struct stream in the original code) and not tested since the crash
  10. is still present.
  11. The reproducer is simple : load a large ACL file (e.g. geolocation
  12. addresses), issue "show acl #0" in loops in one window and issue a
  13. "clear acl #0" in the other one, haproxy crashes.
  14. This fix was also tested with threads enabled and looks good since
  15. the locking seems to work correctly in these areas though. It will
  16. have to be backported as far as 1.6 since the commit above went
  17. that far as well...
  18. (cherry picked from commit 49ee3b2f9a9e5d0b8d394938df527aa645ce72b4)
  19. Signed-off-by: Willy Tarreau <w@1wt.eu>
  20. (cherry picked from commit ac4be10f62ef72962d9cf0e6f2619e1e1c370d62)
  21. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  22. diff --git a/src/pattern.c b/src/pattern.c
  23. index 7eea9d96..21639569 100644
  24. --- a/src/pattern.c
  25. +++ b/src/pattern.c
  26. @@ -1651,7 +1651,7 @@ int pat_ref_delete_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt)
  27. LIST_DEL(&bref->users);
  28. LIST_INIT(&bref->users);
  29. if (elt->list.n != &ref->head)
  30. - LIST_ADDQ(&LIST_ELEM(elt->list.n, struct stream *, list)->back_refs, &bref->users);
  31. + LIST_ADDQ(&LIST_ELEM(elt->list.n, typeof(elt), list)->back_refs, &bref->users);
  32. bref->ref = elt->list.n;
  33. }
  34. list_for_each_entry(expr, &ref->pat, list)
  35. @@ -1691,7 +1691,7 @@ int pat_ref_delete(struct pat_ref *ref, const char *key)
  36. LIST_DEL(&bref->users);
  37. LIST_INIT(&bref->users);
  38. if (elt->list.n != &ref->head)
  39. - LIST_ADDQ(&LIST_ELEM(elt->list.n, struct stream *, list)->back_refs, &bref->users);
  40. + LIST_ADDQ(&LIST_ELEM(elt->list.n, typeof(elt), list)->back_refs, &bref->users);
  41. bref->ref = elt->list.n;
  42. }
  43. list_for_each_entry(expr, &ref->pat, list)
  44. @@ -2086,7 +2086,7 @@ void pat_ref_reload(struct pat_ref *ref, struct pat_ref *replace)
  45. LIST_DEL(&bref->users);
  46. LIST_INIT(&bref->users);
  47. if (elt->list.n != &ref->head)
  48. - LIST_ADDQ(&LIST_ELEM(elt->list.n, struct stream *, list)->back_refs, &bref->users);
  49. + LIST_ADDQ(&LIST_ELEM(elt->list.n, typeof(elt), list)->back_refs, &bref->users);
  50. bref->ref = elt->list.n;
  51. }
  52. LIST_DEL(&elt->list);
  53. @@ -2175,7 +2175,7 @@ void pat_ref_prune(struct pat_ref *ref)
  54. LIST_DEL(&bref->users);
  55. LIST_INIT(&bref->users);
  56. if (elt->list.n != &ref->head)
  57. - LIST_ADDQ(&LIST_ELEM(elt->list.n, struct stream *, list)->back_refs, &bref->users);
  58. + LIST_ADDQ(&LIST_ELEM(elt->list.n, typeof(elt), list)->back_refs, &bref->users);
  59. bref->ref = elt->list.n;
  60. }
  61. LIST_DEL(&elt->list);