From c460c70ab745d68285b3de39da09751976e300ae Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 12 May 2021 10:17:47 +0200 Subject: [PATCH] BUG/MEDIUM: stick_table: fix crash when using tcp smp_fetch_src Since the introduction of bc_src, smp_fetch_src from tcp_sample inspect the kw argument to choose between the frontend or the backend source address. However, for the stick tables, the argument is left to NULL. This causes a segfault. Fix the crash by explicitely set the kw argument to "src" to retrieve the source address of the frontend side. This bug was introduced by the following commit : 7d081f02a43651d781a3a30a51ae19abdceb5683 MINOR: tcp_samples: Add samples to get src/dst info of the backend connection It does not need a backport as it is integrated in the current 2.4-dev branch. To reproduce the crash, I used the following config : frontend fe bind :20080 http-request track-sc0 src table foo http-request reject if { src_conn_rate(foo) gt 10 } use_backend h1 backend foo stick-table type ip size 200k expire 30s store conn_rate(60s) backend h1 server nginx 127.0.0.1:30080 check This should fix the github issue #1247. --- src/stick_table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stick_table.c b/src/stick_table.c index d16e1d01b..51aaef3d6 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -2362,7 +2362,7 @@ smp_fetch_sc_stkctr(struct session *sess, struct stream *strm, const struct arg smp.px = NULL; smp.sess = sess; smp.strm = strm; - if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, &smp, NULL, NULL)) + if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, &smp, "src", NULL)) return NULL; /* Converts into key. */ @@ -2427,7 +2427,7 @@ smp_create_src_stkctr(struct session *sess, struct stream *strm, const struct ar smp.px = NULL; smp.sess = sess; smp.strm = strm; - if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, &smp, NULL, NULL)) + if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, &smp, "src", NULL)) return NULL; /* Converts into key. */ @@ -2959,7 +2959,7 @@ smp_fetch_src_updt_conn_cnt(const struct arg *args, struct sample *smp, const ch return 0; /* Fetch source address in a sample. */ - if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, smp, NULL, NULL)) + if (!smp_fetch_src || !smp_fetch_src(empty_arg_list, smp, "src", NULL)) return 0; /* Converts into key. */