From patchwork Sat Oct 1 23:46:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 9359497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 89FCF6075E for ; Sat, 1 Oct 2016 23:46:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6541E28BCB for ; Sat, 1 Oct 2016 23:46:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 556F128BF2; Sat, 1 Oct 2016 23:46:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4F9628BCB for ; Sat, 1 Oct 2016 23:46:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751824AbcJAXqe (ORCPT ); Sat, 1 Oct 2016 19:46:34 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:36705 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751389AbcJAXqd (ORCPT ); Sat, 1 Oct 2016 19:46:33 -0400 Received: by mail-pa0-f65.google.com with SMTP id cd13so4631259pac.3; Sat, 01 Oct 2016 16:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=IFK8D4IqgJq2DXuFiKYmf11dgVTJSRj2hKY23WtDU6c=; b=EwtebkA9bMpcABE/Y2jIqSZO9/AbXzp1wBBgQT9ha66Giz3TT4GWsckZM/JK0WFs2E iGz+so7gN4wAITLUWLxhka1pbujpSqKTBpk4H5ot70CsEBbUgnj4ECMJlKeYrCzr1Q0o //NAoGWFAHxc6YTawQC6DDyvyh08pKD8dwI25f5hdBny3oKi+LiMbJxJAE5RfAPz6Zzc S5A4DVYgee+UV8cvrT0BAyWV32D1XDQH8+LY1plnecE0m5VB9yEPQ7iM/qVvhtvx2sV9 Pur2IIN0KvxKl4C+BbUcSzaXDli+hVe3As7lurhk+yPReJtjIcjd1LoPyYCP/yJLRI/p sc4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IFK8D4IqgJq2DXuFiKYmf11dgVTJSRj2hKY23WtDU6c=; b=ClG6Oa57FM4int9vDjwovnbci2+YSxI58tDYTFHODdx7aMEKxZBn5EHN5vfsdK9p/u CclsHxnmXfbeygVP1F7nb06DgLdb4nmyhUnKVxUbZVfBGKkNc6JGkM6grAXIEVd+ApyH ZInU9e3vqQGcLMyCViFuN8zTly9cACP1z32UWBAnfUfVMmX7d1/ulwIlhKZpeXie6W5v 2G9ZHkIfXSpP5vu1HvqeLcO5LVhl3p2PahE9kpLwnv4Sh9R6P+2x+KqF7iyZRSlVvmTz UkoSnHCH8Wo3ADjDcmCqwQGINcDrdC3HT3/HDjmfdtvOFm3qKUUr+Mu9MxmYy+/86TmW ovVA== X-Gm-Message-State: AA6/9RnhXcZXWKm/dycRbz+ZagRCVnTyPypCrvYivcs1b1GcryWsc31YdGmHLAx94JvD6Q== X-Received: by 10.66.119.136 with SMTP id ku8mr24341859pab.6.1475365592579; Sat, 01 Oct 2016 16:46:32 -0700 (PDT) Received: from deepa-ubuntu.hsd1.ca.comcast.net ([2601:647:5000:6620:35af:2ada:b4f5:75ba]) by smtp.gmail.com with ESMTPSA id s82sm37160343pfg.42.2016.10.01.16.46.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Oct 2016 16:46:32 -0700 (PDT) From: Deepa Dinamani To: linux-kernel@vger.kernel.org Cc: arnd@arndb.de, y2038@lists.linaro.org, Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH] fs: nfs: Make nfs boot time y2038 safe Date: Sat, 1 Oct 2016 16:46:26 -0700 Message-Id: <1475365586-5504-1-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP boot_time is represented as a struct timespec. struct timespec and CURRENT_TIME are not y2038 safe. Overall, the plan is to use timespec64 and ktime_t for all internal kernel representation of timestamps. CURRENT_TIME will also be removed. boot_time is used to construct the nfs client boot verifier. Use ktime_t to represent boot_time and ktime_get_real() for the boot_time value. Following Trond's request https://lkml.org/lkml/2016/6/9/22 , use ktime_t instead of converting to struct timespec64. Use higher and lower 32 bit parts of ktime_t for the boot verifier. Use the lower 32 bit part of ktime_t for the authsys_parms stamp field. Signed-off-by: Deepa Dinamani Reviewed-by: Arnd Bergmann Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-nfs@vger.kernel.org --- fs/nfs/client.c | 2 +- fs/nfs/netns.h | 2 +- fs/nfs/nfs4proc.c | 10 ++++++---- fs/nfs/nfs4xdr.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 1e10678..44d42a4 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1078,7 +1078,7 @@ void nfs_clients_init(struct net *net) idr_init(&nn->cb_ident_idr); #endif spin_lock_init(&nn->nfs_client_lock); - nn->boot_time = CURRENT_TIME; + nn->boot_time = ktime_get_real(); } #ifdef CONFIG_PROC_FS diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h index f0e06e4..fbce0d8 100644 --- a/fs/nfs/netns.h +++ b/fs/nfs/netns.h @@ -29,7 +29,7 @@ struct nfs_net { int cb_users[NFS4_MAX_MINOR_VERSION + 1]; #endif spinlock_t nfs_client_lock; - struct timespec boot_time; + ktime_t boot_time; #ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_nfsfs; #endif diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index a9dec32..b517cc2 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5123,12 +5123,14 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp, if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) { /* An impossible timestamp guarantees this value * will never match a generated boot time. */ - verf[0] = 0; - verf[1] = cpu_to_be32(NSEC_PER_SEC + 1); + verf[0] = cpu_to_be32(U32_MAX); + verf[1] = cpu_to_be32(U32_MAX); } else { struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id); - verf[0] = cpu_to_be32(nn->boot_time.tv_sec); - verf[1] = cpu_to_be32(nn->boot_time.tv_nsec); + u64 ns = ktime_to_ns(nn->boot_time); + + verf[0] = cpu_to_be32(ns >> 32); + verf[1] = cpu_to_be32(ns); } memcpy(bootverf->data, verf, sizeof(bootverf->data)); } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 7bd3a5c..a961e15 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr, *p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */ /* authsys_parms rfc1831 */ - *p++ = cpu_to_be32(nn->boot_time.tv_nsec); /* stamp */ + *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */ p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen); *p++ = cpu_to_be32(0); /* UID */ *p++ = cpu_to_be32(0); /* GID */