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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180620083339.766780-1-arnd@arndb.de>
Date:   Wed, 20 Jun 2018 10:31:10 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     David Howells <dhowells@...hat.com>
Cc:     y2038@...ts.linaro.org, Arnd Bergmann <arnd@...db.de>,
        linux-cachefs@...hat.com, linux-kernel@...r.kernel.org
Subject: [PATCH] cachefiles: avoid deprecated get_seconds()

get_seconds() returns an unsigned long can overflow on some architectures
and is deprecated because of that. In cachefs, we cast that number to
a a 32-bit integer, which will overflow in year 2106 on all architectures.

The overflow probably isn't harmful in the end, since the timestamps are
only used to make the file names unique, but they don't strictly have to
be in monotonically increasing order. Moving to ktime_get_real_seconds()
avoids the deprecated interface, the question is whether we should still
truncate to 32 bits.

In this patch, I decided to not overflow, but instead to extend the
file names using the 64-bit timestamp, so they will be 17 characters
after 2106 rather than 16.

Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
 fs/cachefiles/namei.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index ab0bbe93b398..5705e29d4506 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -297,7 +297,7 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
 {
 	struct dentry *grave, *trap;
 	struct path path, path_to_graveyard;
-	char nbuffer[8 + 8 + 1];
+	char nbuffer[16 + 8 + 1];
 	int ret;
 
 	_enter(",'%pd','%pd'", dir, rep);
@@ -336,8 +336,8 @@ static int cachefiles_bury_object(struct cachefiles_cache *cache,
 
 try_again:
 	/* first step is to make up a grave dentry in the graveyard */
-	sprintf(nbuffer, "%08x%08x",
-		(uint32_t) get_seconds(),
+	sprintf(nbuffer, "%08llx%08x",
+		(uint64_t) ktime_get_real_seconds(),
 		(uint32_t) atomic_inc_return(&cache->gravecounter));
 
 	/* do the multiway lock magic */
-- 
2.9.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ