Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

As confirmed by David Howells, 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 since the files only exist in order to be deleted as quickly
as possible.

Moving to ktime_get_real_seconds() avoids the deprecated interface.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David Howells <dhowells@redhat.com>

authored by

Arnd Bergmann and committed by
David Howells
34e06fe4 b7e768b7

+1 -1
+1 -1
fs/cachefiles/namei.c
··· 338 338 try_again: 339 339 /* first step is to make up a grave dentry in the graveyard */ 340 340 sprintf(nbuffer, "%08x%08x", 341 - (uint32_t) get_seconds(), 341 + (uint32_t) ktime_get_real_seconds(), 342 342 (uint32_t) atomic_inc_return(&cache->gravecounter)); 343 343 344 344 /* do the multiway lock magic */