ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
b677e7
From 51737206afaa10d902c86ec9b5ec97cf425039c2 Mon Sep 17 00:00:00 2001
b677e7
From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= <msekleta@redhat.com>
b677e7
Date: Thu, 9 Jul 2020 18:16:44 +0200
b677e7
Subject: [PATCH] core: prevent excessive /proc/self/mountinfo parsing
b677e7
b677e7
(cherry picked from commit d586f642fd90e3bb378f7b6d3e3a64a753e51756)
b677e7
b677e7
Resolves: #1819868
b677e7
---
b677e7
 src/core/mount.c | 6 ++++++
b677e7
 1 file changed, 6 insertions(+)
b677e7
b677e7
diff --git a/src/core/mount.c b/src/core/mount.c
b677e7
index 2746372db2..076dfd06a3 100644
b677e7
--- a/src/core/mount.c
b677e7
+++ b/src/core/mount.c
b677e7
@@ -1763,6 +1763,12 @@ static void mount_enumerate(Manager *m) {
b677e7
                         goto fail;
b677e7
                 }
b677e7
 
b677e7
+                r = sd_event_source_set_ratelimit(m->mount_event_source, 1 * USEC_PER_SEC, 5);
b677e7
+                if (r < 0) {
b677e7
+                        log_error_errno(r, "Failed to enable rate limit for mount events: %m");
b677e7
+                        goto fail;
b677e7
+                }
b677e7
+
b677e7
                 (void) sd_event_source_set_description(m->mount_event_source, "mount-monitor-dispatch");
b677e7
         }
b677e7