Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp887235ybl; Fri, 13 Dec 2019 06:12:44 -0800 (PST) X-Google-Smtp-Source: APXvYqz4HzhhMCt8ISJbAlfyvFDt/FNuWAHMTmMsqmW/HzjluZDrGTZGU+5K6FVynQdJmw6y6obs X-Received: by 2002:a9d:7:: with SMTP id 7mr13928385ota.26.1576246364687; Fri, 13 Dec 2019 06:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576246364; cv=none; d=google.com; s=arc-20160816; b=nh95OrigR8OhOTvG6ie2z8wG5g+diWu5boBCnreAtiW9hoboIiyG0Tb11u4jtmY0Qd S0m4y33cfHUoDYpvVHRt1+LnNQ2fQAv70rwpBDO/QVbwROqWjkF1ckef7jSg+edMMRuH QiaBFGVHJ3EhxRRSMakrLPE0K191GUEN3/FoGLscQs/6g7TeWFqzS0USXQIq2HEWW/P+ YW8fsjwsz/uCTZr0TAnn9DzOsi74km75UFne0NR9eWrZ6lEJVzp03lz/7XmYIJdMtOX9 Yy8ztsPz24EdQRgQhWOV75ukejfiNu+M7KTuECYFvLPzEYxeYZwM7qQPoduEvnCUat3K spoQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yCkOUOxe/xOr/m6eSZ/KCRrd05m6b6n9pwvS8zWyVIQ=; b=ltgkNtI0Id6eUtHXnY614cVpwZSiAcQ22KtM4cQPY1WA2kBiuOrVO/KKnA+2wuZM5T Q1YMOaqwAxhLj9RXSrN0gwFxz2ZcQl/MmWSkP28OsbBM8vipcPvEaakP/plcY2oL2QIv exPSkLxkOXT8cHDJlSH0y0Cg3h5kFHoJdI14Jl5GPVHkeo9LhivwmaW/JkgkAosSEZi1 jzqc89lJyeYcMOdw8dIzYZfHg9ejUQNRJWd0r+0Ft9XBItAq/+RyBPZPbCgGufSlOqaj ve4AFhqt0WSI8tkUqUr/XA4p04kXiZgxr9Cq95d+n6A2Z+B50/0eEzP90i2MSsr8w3lM lduQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22si5102879otq.10.2019.12.13.06.12.34; Fri, 13 Dec 2019 06:12:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727573AbfLMOLm (ORCPT + 99 others); Fri, 13 Dec 2019 09:11:42 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:34193 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727572AbfLMOLC (ORCPT ); Fri, 13 Dec 2019 09:11:02 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MmU9R-1hxOHO3fnt-00iVR1; Fri, 13 Dec 2019 15:10:55 +0100 From: Arnd Bergmann To: "J. Bruce Fields" , Chuck Lever Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, y2038@lists.linaro.org, Arnd Bergmann Subject: [PATCH v2 03/12] nfsd: handle nfs3 timestamps as unsigned Date: Fri, 13 Dec 2019 15:10:37 +0100 Message-Id: <20191213141046.1770441-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213141046.1770441-1-arnd@arndb.de> References: <20191213141046.1770441-1-arnd@arndb.de> MIME-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Kudl8xf8R I/v7yXERCFOg6ZOrjUoZjY9m531Il+o6AgLlNDqPWY6KFH11tSH9m+Rr79+UB6gFDn5JdkotO DfWtpEstSEUJ/4odyAAgbNlNPhpAfczvJjyaRKrG/Mw7qKr3g9k1i9XtVfykbiIzVU765X3ii VWIlLF7vHM26p4ZOWooA== Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The decode_time3 function behaves differently on 32-bit and 64-bit architectures: on the former, a 32-bit timestamp gets converted into an signed number and then into a timestamp between 1902 and 2038, while on the latter it is interpreted as unsigned in the range 1970-2106. Change all the remaining 'timespec' in nfsd to 'timespec64' to make the behavior the same, and use the current interpretation of the dominant 64-bit architectures. Signed-off-by: Arnd Bergmann --- fs/nfsd/nfs3xdr.c | 20 ++++++++------------ fs/nfsd/nfsfh.h | 4 ++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 195ab7a0fc89..c997b710af27 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -32,14 +32,14 @@ static u32 nfs3_ftypes[] = { * XDR functions for basic NFS types */ static __be32 * -encode_time3(__be32 *p, struct timespec *time) +encode_time3(__be32 *p, struct timespec64 *time) { *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec); return p; } static __be32 * -decode_time3(__be32 *p, struct timespec *time) +decode_time3(__be32 *p, struct timespec64 *time) { time->tv_sec = ntohl(*p++); time->tv_nsec = ntohl(*p++); @@ -167,7 +167,6 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat) { struct user_namespace *userns = nfsd_user_namespace(rqstp); - struct timespec ts; *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]); *p++ = htonl((u32) (stat->mode & S_IALLUGO)); *p++ = htonl((u32) stat->nlink); @@ -183,12 +182,9 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, *p++ = htonl((u32) MINOR(stat->rdev)); p = encode_fsid(p, fhp); p = xdr_encode_hyper(p, stat->ino); - ts = timespec64_to_timespec(stat->atime); - p = encode_time3(p, &ts); - ts = timespec64_to_timespec(stat->mtime); - p = encode_time3(p, &ts); - ts = timespec64_to_timespec(stat->ctime); - p = encode_time3(p, &ts); + p = encode_time3(p, &stat->atime); + p = encode_time3(p, &stat->mtime); + p = encode_time3(p, &stat->ctime); return p; } @@ -277,8 +273,8 @@ void fill_pre_wcc(struct svc_fh *fhp) stat.size = inode->i_size; } - fhp->fh_pre_mtime = timespec64_to_timespec(stat.mtime); - fhp->fh_pre_ctime = timespec64_to_timespec(stat.ctime); + fhp->fh_pre_mtime = stat.mtime; + fhp->fh_pre_ctime = stat.ctime; fhp->fh_pre_size = stat.size; fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode); fhp->fh_pre_saved = true; @@ -330,7 +326,7 @@ nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p) p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); if ((args->check_guard = ntohl(*p++)) != 0) { - struct timespec time; + struct timespec64 time; p = decode_time3(p, &time); args->guardtime = time.tv_sec; } diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h index 755e256a9103..495540a248a1 100644 --- a/fs/nfsd/nfsfh.h +++ b/fs/nfsd/nfsfh.h @@ -42,8 +42,8 @@ typedef struct svc_fh { /* Pre-op attributes saved during fh_lock */ __u64 fh_pre_size; /* size before operation */ - struct timespec fh_pre_mtime; /* mtime before oper */ - struct timespec fh_pre_ctime; /* ctime before oper */ + struct timespec64 fh_pre_mtime; /* mtime before oper */ + struct timespec64 fh_pre_ctime; /* ctime before oper */ /* * pre-op nfsv4 change attr: note must check IS_I_VERSION(inode) * to find out if it is valid. -- 2.20.0