]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: config: Limit "tune.maxpollevents" parameter to 1000000
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Nov 2025 14:51:27 +0000 (15:51 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Nov 2025 14:56:21 +0000 (15:56 +0100)
"tune.maxpollevents" global parameter was not limited. It was possible to
set any integer value. But this value is used to allocate the array of
events used by epoll. With a huge value, it seems the allocation silently
fail, making haproxy totally unresponsive.

So let's to limit its value to 1 million. It is pretty high and it should
not be an issue to forbid greater values. The documentation was updated
accordingly.

This patch could be backported to all stable branches.

doc/configuration.txt
src/cfgparse-global.c

index 1f53e9bd6a193a5677cff49f8fbbd583cf9e80ec..70a1a81f9953c04945f42980b41214caf09972f8 100644 (file)
@@ -4612,7 +4612,8 @@ tune.maxpollevents <number>
   the polling system. The default value is adapted to the operating system. It
   has been noticed that reducing it below 200 tends to slightly decrease
   latency at the expense of network bandwidth, and increasing it above 200
-  tends to trade latency for slightly increased bandwidth.
+  tends to trade latency for slightly increased bandwidth. The configured value
+  must be lower than or equal to 1000000.
 
 tune.maxrewrite <number>
   Sets the reserved buffer space to this size in bytes. The reserved space is
index 28442c1b0d2c3f982d389850175c672a2be3bd91..2317cc5dd9f5149f8f1507baf756cbcf68f4f038 100644 (file)
@@ -1134,6 +1134,8 @@ static int cfg_parse_global_tune_opts(char **args, int section_type,
 
        }
        else if (strcmp(args[0], "tune.maxpollevents") == 0) {
+               long max;
+
                if (global.tune.maxpollevents != 0) {
                        memprintf(err, "'%s' already specified. Continuing.", args[0]);
                        return 1;
@@ -1142,8 +1144,12 @@ static int cfg_parse_global_tune_opts(char **args, int section_type,
                        memprintf(err, "'%s' expects an integer argument.", args[0]);
                        return -1;
                }
-               global.tune.maxpollevents = atol(args[1]);
-
+               max = atol(args[1]);
+               if (max > 1000000) {
+                       memprintf(err, "'%s' expects an integer value lower than or equal to 1000000.", args[0]);
+                       return -1;
+               }
+               global.tune.maxpollevents = max;
                return 0;
        }
        else if (strcmp(args[0], "tune.max-rules-at-once") == 0) {