From patchwork Fri Nov 30 16:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 152572 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3870033ljp; Fri, 30 Nov 2018 08:41:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/W/Kf6eH9CVXieig6N5N9NGK6osFEYFMOUzA3hhf+txWEFxqt+hvZ5Fp3OvWQPEK/05BLZ5 X-Received: by 2002:a17:902:201:: with SMTP id 1mr6295634plc.62.1543596070937; Fri, 30 Nov 2018 08:41:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543596070; cv=none; d=google.com; s=arc-20160816; b=aHWkRDpLU2HQxSF6odllr1HUfttrYUPXfzEgn1434JjL9xG92yQh2F6Qe+fhSiYpPn 6J9oh0vn4KsqhaS/bNasabRaEeNuOWJpYe5wNdI/Z9U68nm2c7Y6FHy/KYriOn85P+VE Ec0BAcQfVSWRLL1XugXdffKrlZV9OI33dj1FHiNymE3IvXuT9vtvj0uL9pw+5BSGgCPC wwgXEJFm3HVXDaPG6QDxS7BGj0CFoOekON5aTO7yBg0rEUKyZEmfOQrkOaEngr+1JDDV iG71Obn4XiLCz4O98mT7+g8/G9o3WxJHumfQry5aENDC7MQddEejDw13UXmIjnizmXHu BbNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization; bh=aD5YFEGx/gaFWelMvK0CeAVxzySZgsrJLffJ9XIaGbg=; b=LdCXzeana91CWNF6Dr78S0mzPjhlblwtbJtPNvwjIB9qSE0+ofYROx6ooPlCe8G+IP soR4ekwkALcshIfHQlnpT84JiJmy3tHsAn5fsHi390MugP4XU2RwRV6VtH2K7OIZToIo wQMMxCGkLp7rtwq4NLdiPZdNRmihiPBXqVNbjdCjz2jGsOobzFVDsRPUJ1ZAkROjIHVG Cw67GAO0fr/h4NvRtithSdWNZLLQedvlOjt39WNa4dDq5bk8SwQMJ3lSpEPZD0vtlKem gBDcPJtQ95TPMraIs0tk+3oTTsdEvYUkqNez5CwNt6nCQ1L1WsOixgIUdlmda+QUfiOl PNfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e31si5531583pge.270.2018.11.30.08.41.10; Fri, 30 Nov 2018 08:41:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbeLADvC (ORCPT + 32 others); Fri, 30 Nov 2018 22:51:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46786 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbeLADvC (ORCPT ); Fri, 30 Nov 2018 22:51:02 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA1A653F5; Fri, 30 Nov 2018 16:41:08 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-113.rdu2.redhat.com [10.10.120.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52C715D9CD; Fri, 30 Nov 2018 16:41:04 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 6/7] cachefiles: avoid deprecated get_seconds() From: David Howells To: torvalds@linux-foundation.org Cc: Arnd Bergmann , dhowells@redhat.com, linux-cachefs@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 30 Nov 2018 16:41:03 +0000 Message-ID: <154359606362.18703.14445019258226218319.stgit@warthog.procyon.org.uk> In-Reply-To: <154359597927.18703.424445427183570230.stgit@warthog.procyon.org.uk> References: <154359597927.18703.424445427183570230.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 30 Nov 2018 16:41:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann 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 Signed-off-by: David Howells --- fs/cachefiles/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 5ab411d4bc59..1645fcfd9691 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -338,7 +338,7 @@ 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(), + (uint32_t) ktime_get_real_seconds(), (uint32_t) atomic_inc_return(&cache->gravecounter)); /* do the multiway lock magic */