]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: map/cli: protect the backref list during "show map" errors
authorWilly Tarreau <w@1wt.eu>
Tue, 3 May 2022 13:19:49 +0000 (15:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 May 2022 16:13:35 +0000 (18:13 +0200)
In case of write error in "show map", the backref is detached but
the list wasn't locked when this is done. The risk is very low but
it may happen that two concurrent "show map" one of which would fail
or one "show map" failing while the same entry is being updated could
cause a crash.

This should be backported to all stable versions.

src/map.c

index 2a313f481f1a42f1534145cb27cff006766e01df..4c0b45b73d06e49e67e37d0c732a1339fbc90b4d 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -332,10 +332,12 @@ static int cli_io_handler_pat_list(struct appctx *appctx)
                 * reference to the last ref_elt being dumped.
                 */
                if (appctx->st2 == STAT_ST_LIST) {
+                       HA_SPIN_LOCK(PATREF_LOCK, &appctx->ctx.map.ref->lock);
                        if (!LIST_ISEMPTY(&appctx->ctx.map.bref.users)) {
                                LIST_DELETE(&appctx->ctx.map.bref.users);
                                LIST_INIT(&appctx->ctx.map.bref.users);
                        }
+                       HA_SPIN_UNLOCK(PATREF_LOCK, &appctx->ctx.map.ref->lock);
                }
                return 1;
        }