lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <150937789693.31781.1027077289972169712.stgit@warthog.procyon.org.uk>
Date:   Mon, 30 Oct 2017 15:38:16 +0000
From:   David Howells <dhowells@...hat.com>
To:     tglx@...utronix.de
Cc:     dhowells@...hat.com, keyrings@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-afs@...ts.infradead.org
Subject: [PATCH 4/4] KEYS: Use reduce_timer() to shorten gc timeout

Use reduce_timer() to shorten the garbage collector timeout instead of
checking the old timeout and overwriting it without using a lock.  This
should avoid timeout-updating races causing timeouts to get extended.

Signed-off-by: David Howells <dhowells@...hat.com>
---

 security/keys/gc.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/security/keys/gc.c b/security/keys/gc.c
index c99700e82ad6..4e3407c16e5d 100644
--- a/security/keys/gc.c
+++ b/security/keys/gc.c
@@ -32,7 +32,6 @@ DECLARE_WORK(key_gc_work, key_garbage_collector);
 static void key_gc_timer_func(unsigned long);
 static DEFINE_TIMER(key_gc_timer, key_gc_timer_func, 0, 0);
 
-static time64_t key_gc_next_run = TIME64_MAX;
 static struct key_type *key_gc_dead_keytype;
 
 static unsigned long key_gc_flags;
@@ -63,11 +62,10 @@ void key_schedule_gc(time64_t gc_at)
 	if (gc_at <= now || test_bit(KEY_GC_REAP_KEYTYPE, &key_gc_flags)) {
 		kdebug("IMMEDIATE");
 		schedule_work(&key_gc_work);
-	} else if (gc_at < key_gc_next_run) {
+	} else {
 		kdebug("DEFERRED");
-		key_gc_next_run = gc_at;
 		expires = jiffies + (gc_at - now) * HZ;
-		mod_timer(&key_gc_timer, expires);
+		reduce_timer(&key_gc_timer, expires);
 	}
 }
 
@@ -87,7 +85,6 @@ void key_schedule_gc_links(void)
 static void key_gc_timer_func(unsigned long data)
 {
 	kenter("");
-	key_gc_next_run = TIME64_MAX;
 	key_schedule_gc_links();
 }
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ