Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp537026iog; Fri, 24 Jun 2022 08:49:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tTcFWE+/v+7BQ889oQP2oWBnwxgD+FTsKdaZGx0wKLnyr0eodzUu0zUlqOlpxLnGCaJdB4 X-Received: by 2002:a17:907:9706:b0:726:2cf4:6698 with SMTP id jg6-20020a170907970600b007262cf46698mr5004144ejc.619.1656085769184; Fri, 24 Jun 2022 08:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656085769; cv=none; d=google.com; s=arc-20160816; b=xhtV9KDqXqewQOcUqqNGkKPy3iU9Ftq12QUjXK16qTVYjfX03eCqO4P4tE0d4Ry5Wh otgof0b80U3QwcoEtGW6dnoVydai35S1jQfN6/fZGWQpk6OBU14XP8Njsy32osArNCd/ +v/o2WbpgAnxDgemthuxKY+pX3q3fWCw+qkmPy+kB+uxxUFMOtF98s3BJVLHjqIQQmNv STE8Ny8275FeRWiXYR8U4lmKvpEUxgcdT6jtmcoaQNd5wns0jK0o96paXgnQer9+fh8f aWQHfqNYG4+hCFgWK6WrWGl6FkXQgV/qWBB3m/IXECavVqABDu6OQ44jpmbrgBWBMlme 0lGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TIdm+G5fD60/GBEdBCNUorwjEZMGORrzAjwFh/SQQT8=; b=p9AvxjFhURRanRxgD6nxVdfvgRXBd3Uh4J5hOy4k0k+v2VwZSqj6Oqe+9UJ6LEaC+T NT+1etIQh342i9mGgTJuMyyUDRqNpU2TJ/hfEDdBkNL+YqgxeTK59AHwFOFwIAlUhol7 km1PiwRlV9Z54xFVprAr6V4DRDyFwIituyKZhyqTjacWPNwPseMcttDK1vuOfihf61Zn gwXC75fOQCkEF3MsNqJtpUhCmFKm7Fl/BllndCbpokUx/q3kf+OyzqskxctM9hkT5YLy 01ay/I5qTaOgTG16gPtotz6ui17lxhaTF7sUvQrRJVJTXzpSDwy1lAFrxRnJTv8qUi1O 7lvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GDkiBTZQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt7-20020a1709072d8700b006ff20273cccsi2472056ejc.231.2022.06.24.08.49.02; Fri, 24 Jun 2022 08:49:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GDkiBTZQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232059AbiFXPrl (ORCPT + 99 others); Fri, 24 Jun 2022 11:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbiFXPrl (ORCPT ); Fri, 24 Jun 2022 11:47:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C584ECDE for ; Fri, 24 Jun 2022 08:47:40 -0700 (PDT) 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 BC6546223F for ; Fri, 24 Jun 2022 15:47:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A035AC34114; Fri, 24 Jun 2022 15:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656085659; bh=TS+CxZ0WqrhvWZjuAMgnLJ6o6ro4DxzTwBC26BXgoHs=; h=From:To:Cc:Subject:Date:From; b=GDkiBTZQl0i44Fl4HEYoQM26C8mTfVQ/oU0VslBoNd1jTk+VAKEi6IoIawFFxgW8I y0fMndcnrlnQAmLUGR3hu7IZX9I/k1299O/NwC4iDfhMiU+H8LJB5Hr6WiwhycKGY+ /7DsbEel5TE4AtUF5kL0wQvBfFvWZ5w9ck4i1cDY1z+V3Q7oQlcpS22zXrAEChGtjq WhHPPfvzX7MXvX2H0m6DfkvF8jXw1/jXx6XyQEzoiihFl21dKHh8IBfdWI24c2CmFV jF1XYfSBoAGsZybIOMTMOBmUZr2Jq4Xvl2gg7YXgZ9Od+c4Rtn5tQXSqd1EqbgTDU0 RthRFPl1GnMVQ== From: Anna Schumaker To: linux-nfs@vger.kernel.org, chuck.lever@oracle.com Cc: anna@kernel.org, bfields@fieldses.org Subject: [PATCH] NFSD: Don't continue encoding if READ_PLUS gets confused Date: Fri, 24 Jun 2022 11:47:37 -0400 Message-Id: <20220624154737.1387850-1-anna@kernel.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker If we were in a HOLE segement, but vfs_llseek() claimed we were encoding DATA then we would switch over to the DATA encoding function. This conflicts with Chuck's latest xdr cleanup patches and can result in a crash or silent hang. Let's just return nfserr_io if we find we are in this situation, which will cause the encoder to return to the client with the number of segments already encoded. The client can then try the READ_PLUS call again. Fxes: 6c254bf3b637 (SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()) Signed-off-by: Anna Schumaker --- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 61b2aae81abb..dc97d7c7e595 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4792,7 +4792,7 @@ nfsd4_encode_read_plus_hole(struct nfsd4_compoundres *resp, if (data_pos == -ENXIO) data_pos = f_size; else if (data_pos <= read->rd_offset || (data_pos < f_size && data_pos % PAGE_SIZE)) - return nfsd4_encode_read_plus_data(resp, read, maxcount, eof, &f_size); + return nfserr_io; count = data_pos - read->rd_offset; /* Content type, offset, byte count */ -- 2.36.1