From patchwork Sat Feb 5 17:04:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12736152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F07E8C433F5 for ; Sat, 5 Feb 2022 17:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380522AbiBERET (ORCPT ); Sat, 5 Feb 2022 12:04:19 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:39856 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380520AbiBERES (ORCPT ); Sat, 5 Feb 2022 12:04:18 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 61A8060F35; Sat, 5 Feb 2022 17:04:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DA4BC340E8; Sat, 5 Feb 2022 17:04:17 +0000 (UTC) From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 1/7] NFSD: Fix the behavior of READ near OFFSET_MAX Date: Sat, 5 Feb 2022 12:04:16 -0500 Message-Id: <164408065651.3707.4991448334075576326.stgit@bazille.1015granger.net> X-Mailer: git-send-email 2.35.0 In-Reply-To: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> References: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4153; h=from:subject:message-id; bh=mb0hVoMUywrkxJabWUlyIKENjk3YXQvFJ5VJMWyoMF4=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBh/q4QZGekyBIb5oYjRAcjCqCy5s0MoLzhiIClRHoy zy8zMnyJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCYf6uEAAKCRAzarMzb2Z/l0UHEA CdC09XeyoJtNDZ5cFOhJVx16XQDxS3VF9Rv8DCd0wMcjXQ6i7ANVFg6BIfnfMPVGTdG4+VosC8H8Hr z/S2RO8dKbeqriEE9wrqUFNhoDA6fGohrKEi3CkmuNyPs0fZTb4xssVXvWa/S4FAqgt27mlLDEEuM9 dBb0EiaWNJ5QeSu34OMitpk/K9t8jElvWBgpFG9Jhss4ConpHf8lujjGEiRzByI2sXzmuIRIakIyge 0g2vrqiIBnRWxkxj6OkGMxIUcmGnlRIe4s6w2oOJUiyCoK66IHeMUrWXScEyfjqdiAcsCz3jB28jU6 qPcQaZMZbQ8OZPRTCrLqgiOKsTzqQcZVEoJ84+wN4vvnjq2HyrNfgZpk1nLFngQt8q+PB9gRZGBaSv vg73KG9DCWimXJTqPCP6JUjU/8R6aiW/kMa1VaLRJzZjdiFMzfN6FvZ0Ykpjm7k8meUN/YE0s6vqHM eZovQa/m6XYlLi+qAvHoLvNhtMYvmRH5rDSBZK6CHWDrb2ywUzpl0CnmYr2LYBfrjHBkIBBnbtUrYV lxuSAO7Hel+H762350ua/cKKoZ+FddIt5QEgdQx5HkWL9HQ8dlSlQVWM9PwoLpPtpot2X4fwUYb3J5 zfFOs59tasbtFQmvKRpEd61gX2OVPrUtMTZlLWGr+zqg9bEEvts5aBM++1QA== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Dan Aloni reports: > Due to commit 8cfb9015280d ("NFS: Always provide aligned buffers to > the RPC read layers") on the client, a read of 0xfff is aligned up > to server rsize of 0x1000. > > As a result, in a test where the server has a file of size > 0x7fffffffffffffff, and the client tries to read from the offset > 0x7ffffffffffff000, the read causes loff_t overflow in the server > and it returns an NFS code of EINVAL to the client. The client as > a result indefinitely retries the request. The Linux NFS client does not handle NFS?ERR_INVAL, even though all NFS specifications permit servers to return that status code for a READ. Instead of NFS?ERR_INVAL, have out-of-range READ requests succeed and return a short result. Set the EOF flag in the result to prevent the client from retrying the READ request. This behavior appears to be consistent with Solaris NFS servers. Note that NFSv3 and NFSv4 use u64 offset values on the wire. These must be converted to loff_t internally before use -- an implicit type cast is not adequate for this purpose. Otherwise VFS checks against sb->s_maxbytes do not work properly. Reported-by: Dan Aloni Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 8 ++++++-- fs/nfsd/nfs4proc.c | 8 ++++++-- fs/nfsd/nfs4xdr.c | 8 ++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 2c681785186f..b5a52528f19f 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -150,13 +150,17 @@ nfsd3_proc_read(struct svc_rqst *rqstp) unsigned int len; int v; - argp->count = min_t(u32, argp->count, max_blocksize); - dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n", SVCFH_fmt(&argp->fh), (unsigned long) argp->count, (unsigned long long) argp->offset); + argp->count = min_t(u32, argp->count, max_blocksize); + if (argp->offset > (u64)OFFSET_MAX) + argp->offset = (u64)OFFSET_MAX; + if (argp->offset + argp->count > (u64)OFFSET_MAX) + argp->count = (u64)OFFSET_MAX - argp->offset; + v = 0; len = argp->count; resp->pages = rqstp->rq_next_page; diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index ed1ee25647be..71d735b125a0 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -782,12 +782,16 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, __be32 status; read->rd_nf = NULL; - if (read->rd_offset >= OFFSET_MAX) - return nfserr_inval; trace_nfsd_read_start(rqstp, &cstate->current_fh, read->rd_offset, read->rd_length); + read->rd_length = min_t(u32, read->rd_length, svc_max_payload(rqstp)); + if (read->rd_offset > (u64)OFFSET_MAX) + read->rd_offset = (u64)OFFSET_MAX; + if (read->rd_offset + read->rd_length > (u64)OFFSET_MAX) + read->rd_length = (u64)OFFSET_MAX - read->rd_offset; + /* * If we do a zero copy read, then a client will see read data * that reflects the state of the file *after* performing the diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 899de438e529..f5e3430bb6ff 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3986,10 +3986,8 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, } xdr_commit_encode(xdr); - maxcount = svc_max_payload(resp->rqstp); - maxcount = min_t(unsigned long, maxcount, + maxcount = min_t(unsigned long, read->rd_length, (xdr->buf->buflen - xdr->buf->len)); - maxcount = min_t(unsigned long, maxcount, read->rd_length); if (file->f_op->splice_read && test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) @@ -4826,10 +4824,8 @@ nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr, return nfserr_resource; xdr_commit_encode(xdr); - maxcount = svc_max_payload(resp->rqstp); - maxcount = min_t(unsigned long, maxcount, + maxcount = min_t(unsigned long, read->rd_length, (xdr->buf->buflen - xdr->buf->len)); - maxcount = min_t(unsigned long, maxcount, read->rd_length); count = maxcount; eof = read->rd_offset >= i_size_read(file_inode(file)); From patchwork Sat Feb 5 17:04:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12736153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A151C433FE for ; Sat, 5 Feb 2022 17:04:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380525AbiBERE2 (ORCPT ); Sat, 5 Feb 2022 12:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380520AbiBERE1 (ORCPT ); Sat, 5 Feb 2022 12:04:27 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF7CC061348; Sat, 5 Feb 2022 09:04:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1DE6C60F35; Sat, 5 Feb 2022 17:04:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49CCEC340E8; Sat, 5 Feb 2022 17:04:24 +0000 (UTC) From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 2/7] NFSD: Fix ia_size underflow Date: Sat, 5 Feb 2022 12:04:23 -0500 Message-Id: <164408066303.3707.7534844149556688938.stgit@bazille.1015granger.net> X-Mailer: git-send-email 2.35.0 In-Reply-To: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> References: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1081; h=from:subject:message-id; bh=PKE7EX542q+oCOuAqPrZqoJscmIsNzGDaCx3tCm9R6s=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBh/q4XNLfMp7qYgQpJd8CcNgvglwi0Kt4ImQoDVzf/ ZLKg10eJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCYf6uFwAKCRAzarMzb2Z/l2riD/ 9pSi4MYB8Y0r/G5X7d120oPA3awT5guDUXXMO0yBRagibeKNh1YWqDhRTnoSKyAIH3dvHoZr10xt2J aRB9Q+1++iwR2fdYfM0yPnMxB57RIekW2lr9vubGQOecH5uA4ANfXAB1UKM7tCa9HPPqW85G+rnirW JyCa57RrCBLvc/dKE2Y1bjVnYt3/EqwtzOHJBEjE10VlyldnbbgeiBmZ5/olr8L+yhsjvcKtlyAEEG 4+ArDgLW7V+egXWDH/forv+KEJvqYVk5ETBGfsC154CUplv2mrEat91ahhQ8/pSqkgXUWLNvhn+vRl pm/A8WInRHu2Y3nJnFCRjUHjJtaiA1Getd41fhajIVENxe4QHNuou1R7o/kC+/NElUkQgpPmnV7iR7 Slj8De0bfsyVHvMAFTnP6dEAb5sYo+Bu8RY4gidk/RZLBvEksmnAbd+tu0Pvtfz9VJPbHBc/u80h2a bUEvCxvXjr1ijNzKElZ9p972QetLIJC8TaxtXnuFoUcZvobg2ymwGl1RX1yqQ7Hy3+2r6S2OyVub9v nCOIUUu1OS6oSgbkXoExlFJQ/X39uU/GUtpTU6336pom+YZnOIXQY8I5oW+ZiBOCBgjePwpGva2ePA 0xshXYliLd1O3VV9XTxcUu1X8ZeLikpfKPMuzPDZTEKV0XPgtJfNOctnkxgQ== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org iattr::ia_size is a loff_t, which is a signed 64-bit type. NFSv3 and NFSv4 both define file size as an unsigned 64-bit type. Thus there is a range of valid file size values an NFS client can send that is already larger than Linux can handle. Currently decode_fattr4() dumps a full u64 value into ia_size. If that value happens to be larger than S64_MAX, then ia_size underflows. I'm about to fix up the NFSv3 behavior as well, so let's catch the underflow in the common code path: nfsd_setattr(). Signed-off-by: Chuck Lever --- fs/nfsd/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 99c2b9dfbb10..0cccceb105e7 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -435,6 +435,10 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, .ia_size = iap->ia_size, }; + host_err = -EFBIG; + if (iap->ia_size < 0) + goto out_unlock; + host_err = notify_change(&init_user_ns, dentry, &size_attr, NULL); if (host_err) goto out_unlock; From patchwork Sat Feb 5 17:04:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12736154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E976DC433F5 for ; Sat, 5 Feb 2022 17:04:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380528AbiBEREd (ORCPT ); Sat, 5 Feb 2022 12:04:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380520AbiBEREc (ORCPT ); Sat, 5 Feb 2022 12:04:32 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C46EC061348; Sat, 5 Feb 2022 09:04:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 95C2361113; Sat, 5 Feb 2022 17:04:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2294C340E8; Sat, 5 Feb 2022 17:04:30 +0000 (UTC) From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 3/7] NFSD: Fix NFSv3 SETATTR/CREATE's handling of large file sizes Date: Sat, 5 Feb 2022 12:04:29 -0500 Message-Id: <164408066975.3707.17686323228643818652.stgit@bazille.1015granger.net> X-Mailer: git-send-email 2.35.0 In-Reply-To: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> References: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1156; h=from:subject:message-id; bh=JvwdN/hMjxDOVzCApefTJrDnpUJjGi+Sb1bkoJN+VGk=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBh/q4d/SpzJCaqxrqjXnUv0En8Q9o9DHJ5QOXIq2og MWdRGXqJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCYf6uHQAKCRAzarMzb2Z/l2/fD/ 95oQVZnNCYSjhgXUqY1OWMrb8oUOD78+ewcFpNnKmn1cDtGKOFayc6xw85QN8i2Jk/7tLHUB9URC7J yqec1aQRm9jVdd6dQ2+Ub2Rny+SiiZ6zWxN6S/bDRDv5yeJTHhBgJ0l2GKCkubkWZWaUWPNLhHPpuR v63w1IVmBFXVxHpsfvUm5PXG1ZIcUrY2g2VK6SyD5IOaYntLym3zC/PSwqILDLj5WgQg7gmfbpeMME mZwyaD7Z13OoAuXYJZU6MwKAQ+Bx64ncWxkql0jzLFLIfZST6EMDDrV/o0lmxUisompzluf0dq1cgH s5HiICmeu0EIUjbbjDQnFf20qFWjPTQl6TV/03pY6mLfW5t8Pc+1E+OhVpj49pfNs1EHkW/m3TQBa8 Hoj5eR/j8OLEwLQ/2Wnw8XL1X39vtaoCX9KIQWbaWaIzDyGSpJbQvgpIANBz5JolZE0C0ORJQenH8T hyd7NpQwrA9bU2BEP1RqdtfdoPJkMfJ0YbPbSFAH4BXBRv9GiGMeOUMZBh/vEnVkVnBtEZ/QXBnxNl EU5lW8dB5ERIaMmlE/tKU1d2ctdxlQl5q4iAbflX/i0oNc/sdbV/yABoalmwSgUHNKm/72z4BiJmSA 7kHIFX+Gwitov0bjgjtOzRrAwornAvUHPXDtPbYJgTC8WTnCkQwkASTvxzhg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org iattr::ia_size is a loff_t, so these NFSv3 procedures must be careful to deal with incoming client size values that are larger than s64_max without corrupting the value. Silently capping the value results in storing a different value than the client passed in which is unexpected behavior, so remove the min_t() check in decode_sattr3(). Note that RFC 1813 permits only the WRITE procedure to return NFS3ERR_FBIG. We believe that NFSv3 reference implementations also return NFS3ERR_FBIG when ia_size is too large. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 7c45ba4db61b..2e47a07029f1 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -254,7 +254,7 @@ svcxdr_decode_sattr3(struct svc_rqst *rqstp, struct xdr_stream *xdr, if (xdr_stream_decode_u64(xdr, &newsize) < 0) return false; iap->ia_valid |= ATTR_SIZE; - iap->ia_size = min_t(u64, newsize, NFS_OFFSET_MAX); + iap->ia_size = newsize; } if (xdr_stream_decode_u32(xdr, &set_it) < 0) return false; From patchwork Sat Feb 5 17:04:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12736155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4B13C433F5 for ; Sat, 5 Feb 2022 17:04:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380531AbiBEREi (ORCPT ); Sat, 5 Feb 2022 12:04:38 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:40006 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380520AbiBEREi (ORCPT ); Sat, 5 Feb 2022 12:04:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1DE1E60F35; Sat, 5 Feb 2022 17:04:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 588BFC340E8; Sat, 5 Feb 2022 17:04:37 +0000 (UTC) From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 4/7] NFSD: Clamp WRITE offsets Date: Sat, 5 Feb 2022 12:04:36 -0500 Message-Id: <164408067623.3707.13921614193946451246.stgit@bazille.1015granger.net> X-Mailer: git-send-email 2.35.0 In-Reply-To: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> References: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1621; h=from:subject:message-id; bh=B0duDWfPZ7mlJ6eFB+7wW3BAunsL5CqPdWmsMKiIVa0=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBh/q4krTl/Po8hZI9mZ/n3SphGph+V9J1tsCF5f1rv lNrU8PaJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCYf6uJAAKCRAzarMzb2Z/l+MLEA CdMqWFBPODjbXr2JvjM0iakT/mpXP+46gZ62/ZQxiGDUK2qzyTfi6vHNZVsqXJDK4k+FlGUIsGREuI T1XVJuekHyLjjvQmdJD8B+PXQw2U9t6cCnrbog6nVYKMA/vfQUs2Hk9qd8QWp6S7j7eEPqAMyYphW9 CPzjyJkuznWujYZqInc2CqoPZzTEw9sJOdyLczKFNrsn9FRVLRo5jVewOhtr0DM+nbMH9+AXJJyhS9 CMGfwSOKpJ3fNbf+gNWuoUA+qxMkikluDAqKEC6K9hXKPeKg150AOnBGTXTbWEvsxY5KzBJdSZnm+V wlb4csSkrTF/jhIri7pY6yr8Yt6V0orfieapj85QGwyZmzh6E8pSAVFr51qrM8+/xFGqLlpIZaNvdh LjxuQgIJnknAHKdvpf8q/L1N7mXs115wlVhZezANZT4wtTe2pr+LjAT3E3DWzOpK0IptyVdfcgjor8 5arxQTiMXs/klzZ9TDT+BHs4py4i/dWsEkGWbbVOtujOc0y3hojqdtqh851loe9sxZ9N/9olP9BK78 sNaCsmOttZjjRuO8Z5vZHuXQlGATX29eNMN4G6ZU4KnLWFbf8VXt9Vc/DciDVC7S/srFUigX6KMQPJ GC4oJSAfkN8KbHIDy1YrSMFXMyi7/URWeJ6qQ++Rf8ICnrSmUfFWSsCNvjHA== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Ensure that a client cannot specify a WRITE range that falls in a byte range outside what the kernel's internal types (such as loff_t, which is signed) can represent. The kiocb iterators, invoked in nfsd_vfs_write(), should properly limit write operations to within the underlying file system's s_maxbytes. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 5 +++++ fs/nfsd/nfs4proc.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index b5a52528f19f..aca38ed1526e 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -203,6 +203,11 @@ nfsd3_proc_write(struct svc_rqst *rqstp) (unsigned long long) argp->offset, argp->stable? " stable" : ""); + resp->status = nfserr_fbig; + if (argp->offset > (u64)OFFSET_MAX || + argp->offset + argp->len > (u64)OFFSET_MAX) + return rpc_success; + fh_copy(&resp->fh, &argp->fh); resp->committed = argp->stable; nvecs = svc_fill_write_vector(rqstp, &argp->payload); diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 71d735b125a0..b207c76a873f 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1022,8 +1022,9 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, unsigned long cnt; int nvecs; - if (write->wr_offset >= OFFSET_MAX) - return nfserr_inval; + if (write->wr_offset > (u64)OFFSET_MAX || + write->wr_offset + write->wr_buflen > (u64)OFFSET_MAX) + return nfserr_fbig; cnt = write->wr_buflen; trace_nfsd_write_start(rqstp, &cstate->current_fh, From patchwork Sat Feb 5 17:04:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12736156 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4932C433FE for ; Sat, 5 Feb 2022 17:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380534AbiBEREq (ORCPT ); Sat, 5 Feb 2022 12:04:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380520AbiBEREp (ORCPT ); Sat, 5 Feb 2022 12:04:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0992DC061348; Sat, 5 Feb 2022 09:04:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 96FB860F35; Sat, 5 Feb 2022 17:04:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D316EC340E8; Sat, 5 Feb 2022 17:04:43 +0000 (UTC) From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 5/7] NFSD: COMMIT operations must not return NFS?ERR_INVAL Date: Sat, 5 Feb 2022 12:04:42 -0500 Message-Id: <164408068274.3707.4173748066154177725.stgit@bazille.1015granger.net> X-Mailer: git-send-email 2.35.0 In-Reply-To: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> References: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5848; h=from:subject:message-id; bh=rsSbzFt2WJOkmNkHrPfSS0ZKRcrncjEkq8LHuRxJpvI=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBh/q4qErm18C58TUOilXT07ZFNvmX/TyP5PE2C5z1i 6iwAAliJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCYf6uKgAKCRAzarMzb2Z/l1alD/ 9JTF+18UALcBpEO8oEBakfY9ld2OqkTotsGnwau5SW0uQlH6phZ0KWKnJ3eLfik78x8Wn7eo+drx3O 7iWY1uO6gCoqvKmXnCHR54rxdLIyo5bKkqWjQlz84xuRLjLGd86jy7+rqgfPfHQJJmtVA7ld6AfUo8 l/zyoXGdgBav3Aoc3SewoeCRCxFr9Y3HDWt5ojHQAbdToScniVjIjlXhHm5rlu7eSyB3v6EjJq5M5Y V8vcVcTpg6bdmcTC0+fRj4ZhK+SoTZcymY6wkYvF8EjuYRHr4kWxEogJm/ddKes4XWJzEInD2FRwbQ axwBlF+4SXaQ8ba6zN07idkO9eSxnd/JVLVnSzjUQnQIbTmw1cSlYRAz6EDCFkjjKzfgWMRojtIdl5 Wr8MjFgUVkoI4Q4wEupVTpLACoRFdFtZ34rbBRqZHyfEiUI8ABVgrPajkSlg13VgvtbEDJ5tAD8rWB 3sxinmSnoVOZXwRY4SBlANEvzP/oEgsGWRgDDUKAlAMDOL1AlgFIZjfRjxLM+n41WxQ86LmFjYiriq uu0Dv8P1lRyf13i/lYsEs3z7mP8AMG9Tj5pfGUCDwEee2eslPbBIFmELlsszPAY15JWdkkVJOf+0Ll +O2D3YHKxGBxJi4R9eI2nBlD4J8ISZlwAvM9lEHNbs3t3aE/DNO5s1qbDtVg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Since, well, forever, the Linux NFS server's nfsd_commit() function has returned nfserr_inval when the passed-in byte range arguments were non-sensical. However, according to RFC 1813 section 3.3.21, NFSv3 COMMIT requests are permitted to return only the following non-zero status codes: NFS3ERR_IO NFS3ERR_STALE NFS3ERR_BADHANDLE NFS3ERR_SERVERFAULT NFS3ERR_INVAL is not included in that list. Likewise, NFS4ERR_INVAL is not listed in the COMMIT row of Table 6 in RFC 8881. RFC 7530 does permit COMMIT to return NFS4ERR_INVAL, but does not specify when it can or should be used. Instead of dropping or failing a COMMIT request in a byte range that is not supported, turn it into a valid request by treating one or both arguments as zero. Offset zero means start-of-file, count zero means until-end-of-file, so we only ever extend the commit range. NFS servers are always allowed to commit more and sooner than requested. The range check is no longer bounded by NFS_OFFSET_MAX, but rather by the value that is returned in the maxfilesize field of the NFSv3 FSINFO procedure or the NFSv4 maxfilesize file attribute. Note that this change results in a new pynfs failure: CMT4 st_commit.testCommitOverflow : RUNNING CMT4 st_commit.testCommitOverflow : FAILURE COMMIT with offset + count overflow should return NFS4ERR_INVAL, instead got NFS4_OK IMO the test is not correct as written: RFC 8881 does not allow the COMMIT operation to return NFS4ERR_INVAL. Reported-by: Dan Aloni Signed-off-by: Chuck Lever Reviewed-by: Bruce Fields --- fs/nfsd/nfs3proc.c | 6 ------ fs/nfsd/vfs.c | 53 +++++++++++++++++++++++++++++++++++----------------- fs/nfsd/vfs.h | 4 ++-- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index aca38ed1526e..52ad1972cc33 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -663,15 +663,9 @@ nfsd3_proc_commit(struct svc_rqst *rqstp) argp->count, (unsigned long long) argp->offset); - if (argp->offset > NFS_OFFSET_MAX) { - resp->status = nfserr_inval; - goto out; - } - fh_copy(&resp->fh, &argp->fh); resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count, resp->verf); -out: return rpc_success; } diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 0cccceb105e7..91600e71be19 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1114,42 +1114,61 @@ nfsd_write(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, } #ifdef CONFIG_NFSD_V3 -/* - * Commit all pending writes to stable storage. +/** + * nfsd_commit - Commit pending writes to stable storage + * @rqstp: RPC request being processed + * @fhp: NFS filehandle + * @offset: raw offset from beginning of file + * @count: raw count of bytes to sync + * @verf: filled in with the server's current write verifier * - * Note: we only guarantee that data that lies within the range specified - * by the 'offset' and 'count' parameters will be synced. + * Note: we guarantee that data that lies within the range specified + * by the 'offset' and 'count' parameters will be synced. The server + * is permitted to sync data that lies outside this range at the + * same time. * * Unfortunately we cannot lock the file to make sure we return full WCC * data to the client, as locking happens lower down in the filesystem. + * + * Return values: + * An nfsstat value in network byte order. */ __be32 -nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, - loff_t offset, unsigned long count, __be32 *verf) +nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, u64 offset, + u32 count, __be32 *verf) { + u64 maxbytes; + loff_t start, end; struct nfsd_net *nn; struct nfsd_file *nf; - loff_t end = LLONG_MAX; - __be32 err = nfserr_inval; - - if (offset < 0) - goto out; - if (count != 0) { - end = offset + (loff_t)count - 1; - if (end < offset) - goto out; - } + __be32 err; err = nfsd_file_acquire(rqstp, fhp, NFSD_MAY_WRITE|NFSD_MAY_NOT_BREAK_LEASE, &nf); if (err) goto out; + + /* + * Convert the client-provided (offset, count) range to a + * (start, end) range. If the client-provided range falls + * outside the maximum file size of the underlying FS, + * clamp the sync range appropriately. + */ + start = 0; + end = LLONG_MAX; + maxbytes = (u64)fhp->fh_dentry->d_sb->s_maxbytes; + if (offset < maxbytes) { + start = offset; + if (count && (offset + count - 1 < maxbytes)) + end = offset + count - 1; + } + nn = net_generic(nf->nf_net, nfsd_net_id); if (EX_ISSYNC(fhp->fh_export)) { errseq_t since = READ_ONCE(nf->nf_file->f_wb_err); int err2; - err2 = vfs_fsync_range(nf->nf_file, offset, end, 0); + err2 = vfs_fsync_range(nf->nf_file, start, end, 0); switch (err2) { case 0: nfsd_copy_write_verifier(verf, nn); diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index 9f56dcb22ff7..2c43d10e3cab 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -74,8 +74,8 @@ __be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *, char *name, int len, struct iattr *attrs, struct svc_fh *res, int createmode, u32 *verifier, bool *truncp, bool *created); -__be32 nfsd_commit(struct svc_rqst *, struct svc_fh *, - loff_t, unsigned long, __be32 *verf); +__be32 nfsd_commit(struct svc_rqst *rqst, struct svc_fh *fhp, + u64 offset, u32 count, __be32 *verf); #endif /* CONFIG_NFSD_V3 */ #ifdef CONFIG_NFSD_V4 __be32 nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, From patchwork Sat Feb 5 17:04:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12736157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4A44C433FE for ; Sat, 5 Feb 2022 17:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380535AbiBEREy (ORCPT ); Sat, 5 Feb 2022 12:04:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380519AbiBEREy (ORCPT ); Sat, 5 Feb 2022 12:04:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FAB4C061348; Sat, 5 Feb 2022 09:04:53 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C90C5B80B0F; Sat, 5 Feb 2022 17:04:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56F92C340ED; Sat, 5 Feb 2022 17:04:50 +0000 (UTC) From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 6/7] NFSD: Fix offset type in I/O trace points Date: Sat, 5 Feb 2022 12:04:49 -0500 Message-Id: <164408068923.3707.10673224104877827331.stgit@bazille.1015granger.net> X-Mailer: git-send-email 2.35.0 In-Reply-To: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> References: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1582; h=from:subject:message-id; bh=kOvp2gyNzLt2NM6Eqtt34OIlG/FKm/CYAEE71D+71MM=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBh/q4xOBmUCF0roANFEY7wLQsUPHPLJa5PmS9sX1No X7kfaaaJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCYf6uMQAKCRAzarMzb2Z/l1vpEA CMT2pi2Vj18oem5IyUwTujQB3HOGmVYgc7XJKAiu02G0WquNIKTbgG12TuTn9KMMxCiIL6fR38Vtit kU/thF6tHeevZJPQWfxe1DXIWBQTnJUBoLfBEOJ+xZLeoDbkblHVoj/ENj02rKDaLz3UBsGHVUj6wq GB/BwARr+lZxaL+f3R+Bmt0yiFSBQg+HJjUiVgxb6yDDBtso6d3Vf5E41r0ftf7efe5/UEd3qwF3mE q9y3TETUSIigE9uuEZ5AoxwAVJDiMjKfBbQo4bzkg2rLBw1eLqWvdu+SzqL954hPoOYU8d0eQ1cHUX kcJTzAZUYfXzHGoFzc6m2XPWlqvB3OoWQkSwhZUtZxMdRrcNBAPj4579NAtgZ71PYouOd4UnvTQIX0 lIXZf3drml1VAu4OSXSy5/E7TxntzQDp/BXqX0DHtaKyQl6kTEpRH3xORAm7SPYTvAtcRDv7XF1xq7 ThjQR54k3X0YVpqN3oDP1lcF+F0RGdEI+vZiUOs17rn5qi8dWWEewTjq7/DsT9oOso63E+3zH8CRrk ewxxGIYoko+fTGSZhl12Ng7SzqKHvCQstPYLQypNBj7YZRyx0nd1gWdqmdqnvKBdvl7M3cP9XLoaqk xW9TNYo8kC+8vsHrzBVt+hBfofKwOfDfzKn9ePiVegH4Oa0ACisTrX3gT1ew== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org NFSv3 and NFSv4 use u64 offset values on the wire. Record these values verbatim without the implicit type case to loff_t. Signed-off-by: Chuck Lever --- fs/nfsd/trace.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index c4cf56327843..5889db66409d 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -306,14 +306,14 @@ TRACE_EVENT(nfsd_export_update, DECLARE_EVENT_CLASS(nfsd_io_class, TP_PROTO(struct svc_rqst *rqstp, struct svc_fh *fhp, - loff_t offset, - unsigned long len), + u64 offset, + u32 len), TP_ARGS(rqstp, fhp, offset, len), TP_STRUCT__entry( __field(u32, xid) __field(u32, fh_hash) - __field(loff_t, offset) - __field(unsigned long, len) + __field(u64, offset) + __field(u32, len) ), TP_fast_assign( __entry->xid = be32_to_cpu(rqstp->rq_xid); @@ -321,7 +321,7 @@ DECLARE_EVENT_CLASS(nfsd_io_class, __entry->offset = offset; __entry->len = len; ), - TP_printk("xid=0x%08x fh_hash=0x%08x offset=%lld len=%lu", + TP_printk("xid=0x%08x fh_hash=0x%08x offset=%llu len=%u", __entry->xid, __entry->fh_hash, __entry->offset, __entry->len) ) @@ -330,8 +330,8 @@ DECLARE_EVENT_CLASS(nfsd_io_class, DEFINE_EVENT(nfsd_io_class, nfsd_##name, \ TP_PROTO(struct svc_rqst *rqstp, \ struct svc_fh *fhp, \ - loff_t offset, \ - unsigned long len), \ + u64 offset, \ + u32 len), \ TP_ARGS(rqstp, fhp, offset, len)) DEFINE_NFSD_IO_EVENT(read_start); From patchwork Sat Feb 5 17:04:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 12736158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 138B6C433EF for ; Sat, 5 Feb 2022 17:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380539AbiBERE6 (ORCPT ); Sat, 5 Feb 2022 12:04:58 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:40182 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380519AbiBERE5 (ORCPT ); Sat, 5 Feb 2022 12:04:57 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9785861113; Sat, 5 Feb 2022 17:04:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D19D4C340E8; Sat, 5 Feb 2022 17:04:56 +0000 (UTC) From: Chuck Lever To: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 7/7] NFSD: Deprecate NFS_OFFSET_MAX Date: Sat, 5 Feb 2022 12:04:55 -0500 Message-Id: <164408069573.3707.2101485349960133054.stgit@bazille.1015granger.net> X-Mailer: git-send-email 2.35.0 In-Reply-To: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> References: <164408013367.3707.1739092698555505020.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2051; h=from:subject:message-id; bh=pkUTaosNQpKBg00uOuMM1iODPE3WLgAG/zzVyufdti4=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBh/q43hquHoEoRzj2ab/E8M5Y18D1ZSul26IJfwEkD u9jUNtqJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCYf6uNwAKCRAzarMzb2Z/l3u+D/ 9pv3RmL1noi50Ox7vvCSYlSi+se0UR5tAGlOO0Qtn54YtVbdfgUefeCno6qJTDJioLmcnbl5LDJH+g RFGh6JrsLE5BgqwjPuSDGJ7zD3bZWA1vyOpIdaoET/FTm12+bM1vlj3eaus/wIRM7b9d2/ZxHvp1+B TuZyicULUKggw5AHEPmsIuUugKhZpxtU20UNN0dc+tNXjr+TzKTCY8QN3Yhd+yawn7ERjrcgokkYBj CS3p9WLA6wRz15oM0N+wlJlVcr63vnwVP341Ga29BptT2dFlufHBcEI47LbpfSZtvLT4NkAs97I9G+ HCEoJic4yQHb+lFZbFudxeay4swSAQV9dEWH0ITFqnhcj7SKSGozwvkpEgo1kNzZ4X1hZXpM4/umzT BmD8thyJNfsvVDzUXq5mlevLL5K/HyAITlLc13ABSbtV8FiXgGL4Pt1AgyCxQi3hcoYNIt0KUPHbP5 t4Rouc+KF/yqm4bYpByAbWPx5ZLEUD0to8XkFBxaVUSPLxf9cS0XfrQ0kNmUJH9DKlf1QJOPyHusbk iPtyk+6vORKcshu+kkbuxTbKljAnKdPpmDLIlBQr1WPrtMQ3Dw++XSesNAL+8qb2vLPUIUd6mcxwoJ DKrdkRHN8tByHBvYwh8FZtaFW7cl3RibnpS6C0OMeJk7wwbfI+UXN4lWIk4A== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org NFS_OFFSET_MAX was introduced way back in Linux v2.3.y before there was a kernel-wide OFFSET_MAX value. As a clean up, replace the last few uses of it with its generic equivalent, and get rid of it. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3xdr.c | 2 +- fs/nfsd/nfs4xdr.c | 2 +- include/linux/nfs.h | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 2e47a07029f1..0293b8d65f10 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -1060,7 +1060,7 @@ svcxdr_encode_entry3_common(struct nfsd3_readdirres *resp, const char *name, return false; /* cookie */ resp->cookie_offset = dirlist->len; - if (xdr_stream_encode_u64(xdr, NFS_OFFSET_MAX) < 0) + if (xdr_stream_encode_u64(xdr, OFFSET_MAX) < 0) return false; return true; diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index f5e3430bb6ff..714a3a3bd50c 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3495,7 +3495,7 @@ nfsd4_encode_dirent(void *ccdv, const char *name, int namlen, p = xdr_reserve_space(xdr, 3*4 + namlen); if (!p) goto fail; - p = xdr_encode_hyper(p, NFS_OFFSET_MAX); /* offset of next entry */ + p = xdr_encode_hyper(p, OFFSET_MAX); /* offset of next entry */ p = xdr_encode_array(p, name, namlen); /* name length & name */ nfserr = nfsd4_encode_dirent_fattr(xdr, cd, name, namlen); diff --git a/include/linux/nfs.h b/include/linux/nfs.h index 0dc7ad38a0da..b06375e88e58 100644 --- a/include/linux/nfs.h +++ b/include/linux/nfs.h @@ -36,14 +36,6 @@ static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *sourc memcpy(target->data, source->data, source->size); } - -/* - * This is really a general kernel constant, but since nothing like - * this is defined in the kernel headers, I have to do it here. - */ -#define NFS_OFFSET_MAX ((__s64)((~(__u64)0) >> 1)) - - enum nfs3_stable_how { NFS_UNSTABLE = 0, NFS_DATA_SYNC = 1,