]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Lower the minimum value for MaxMemInQueues to 64 MB for relays.
authorNick Mathewson <nickm@torproject.org>
Tue, 11 Aug 2020 21:01:49 +0000 (17:01 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 11 Aug 2020 21:01:49 +0000 (17:01 -0400)
For clients, there is no minimum value; in both cases, we warn if
the value seems too low.

Closes ticket 24308.

changes/ticket24308 [new file with mode: 0644]
src/app/config/config.c

diff --git a/changes/ticket24308 b/changes/ticket24308
new file mode 100644 (file)
index 0000000..e614785
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor features (denial-of-service memory limiter):
+    - Allow the user to configure even lower values for the MaxMemInQueues
+      parameter.  Relays now enforce a minimum of 64 MB, when previously
+      the minimum was 256 MB.  On clients, there is no minimum. Relays and
+      clients will both warn if the value is set so low that Tor is likely
+      to stop working. Closes ticket 24308.
index 8e21d67f23868f5ac2ba5d37688cde56795012e0..94971e3bfd3d5fd5237d6c4578573f9a0bda7e46 100644 (file)
@@ -4585,6 +4585,9 @@ options_validate(or_options_t *old_options, or_options_t *options,
 STATIC uint64_t
 compute_real_max_mem_in_queues(const uint64_t val, bool is_server)
 {
+#define MIN_SERVER_MB 64
+#define MIN_UNWARNED_SERVER_MB 256
+#define MIN_UNWARNED_CLIENT_MB 64
   uint64_t result;
 
   if (val == 0) {
@@ -4650,10 +4653,24 @@ compute_real_max_mem_in_queues(const uint64_t val, bool is_server)
       notice_sent = 1;
     }
     return result;
-  } else if (val < ONE_GIGABYTE / 4) {
-    log_warn(LD_CONFIG, "MaxMemInQueues must be at least 256 MB for now. "
-             "Ideally, have it as large as you can afford.");
-    return ONE_GIGABYTE / 4;
+  } else if (is_server && val < ONE_MEGABYTE * MIN_SERVER_MB) {
+    /* We can't configure less than this much on a server.  */
+    log_warn(LD_CONFIG, "MaxMemInQueues must be at least %d MB on servers "
+             "for now. Ideally, have it as large as you can afford.",
+             MIN_SERVER_MB);
+    return MIN_SERVER_MB * ONE_MEGABYTE;
+  } else if (is_server && val < ONE_MEGABYTE * MIN_UNWARNED_SERVER_MB) {
+    /* On a server, if it's less than this much, we warn that things
+     * may go badly. */
+    log_warn(LD_CONFIG, "MaxMemInQueues is set to a low value; if your "
+             "relay doesn't work, this may be the reason why.");
+    return val;
+  } else if (! is_server && val < ONE_MEGABYTE * MIN_UNWARNED_CLIENT_MB) {
+    /* On a client, if it's less than this much, we warn that things
+     * may go badly. */
+    log_warn(LD_CONFIG, "MaxMemInQueues is set to a low value; if your "
+             "client doesn't work, this may be the reason why.");
+    return val;
   } else {
     /* The value was fine all along */
     return val;