Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2075245ybp; Thu, 10 Oct 2019 01:44:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVZOHPc8vXMVg4T3uJ0nuQr5m7rxRjkiOX71nWf9NyFjE1faNKB7JPzAWoarCg2zbaYFfk X-Received: by 2002:a17:906:4d85:: with SMTP id s5mr7147125eju.192.1570697063808; Thu, 10 Oct 2019 01:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697063; cv=none; d=google.com; s=arc-20160816; b=IX1JfNWLTYMIgCRCNDABIGHGWbTCo/9dwxE8wiLeNBP5xOwNtVmggxy4fm/+C05Fas uV8z3fkp2bf5XFaccjkkOH9LQ3jIr3iWybsW+1zdcvkZ3fcnJepw7JD+w7L6AefXDftd ar9O17y8lbHVS5yNgvZg7Dl9QGZuVDylhBwYr+Qb4An2l0YtbC/4+I25BsrNktOEGKpc XdoxDl97xFg4ykytqzDLV4n1XlNCzM4ciKDeXX+4Y3biB/5NAZsmf5xJehbQ4xQYFnR9 ifLvmtt4PZLE03dVcGj59N5Jd4bVGEb8FeL6nH0/pedEQhe0AQvpKjWher80PAQyGaBL ntgA== 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:subject:cc:to :from:dkim-signature; bh=54ypLr8K4O6tdyz0LyA347gkAtz+MyK5W8cJITP3mlg=; b=iv3HQ+8G3mt0DJzjQpuLyrx/QCrx8CPEQav43/isQH5n3ti/sDH2eIFsRNz8YIj2pr caHg/4zEMB7yZPbUw+S3CgnsgMsTqmbDTRtpjmQ60lv/6cp6W9ByTxfAzi7K9rUJJsyu U8Ioeu1biFyQsMQHJ76rjM9z52kLWtRWTxLTKB7RoGe77WFSXk4eezz4Bd1JI+/cKeQk dC6S3coavBS3SaInME+EaOevN17r7Thf8vyh+rzvhONE1Jm/MB5Px9ktKSoU35lcNIoV 4SP2rs0SCtGCzubOhEqTINPHjarT8Ii6oI/m0uIekkMiy70UzqAN+Wt5FIcnTpLZTh6G 62kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KVSBX+7Z; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si2785254edx.223.2019.10.10.01.44.00; Thu, 10 Oct 2019 01:44:23 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=KVSBX+7Z; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388537AbfJJImW (ORCPT + 99 others); Thu, 10 Oct 2019 04:42:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:46886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388511AbfJJImU (ORCPT ); Thu, 10 Oct 2019 04:42:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C61CE2190F; Thu, 10 Oct 2019 08:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570696939; bh=Y9uQYymY0eFnLevhi+Oh+Vqc/2hn+dwDMy63dOaerEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KVSBX+7Z41l/GG5m4TpsawKvOJJmMaANGz0rDYp3jf03SZdRzUyxLC8G+7LqEUVnB rzIHriLEWNrlnvh1jUkTURh5vEBDQw/6keCxFoo4EM4jeqfaQwnQHcZfsBzIoO8pgq Cc9rHdsr8QmbW5U9450NYtSzxSxSJKXbIvckHuf8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Anna Schumaker , Sasha Levin Subject: [PATCH 5.3 108/148] SUNRPC: Dont try to parse incomplete RPC messages Date: Thu, 10 Oct 2019 10:36:09 +0200 Message-Id: <20191010083617.709024171@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083609.660878383@linuxfoundation.org> References: <20191010083609.660878383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit 9ba828861c56a21d211d5d10f5643774b1ea330d ] If the copy of the RPC reply into our buffers did not complete, and we could end up with a truncated message. In that case, just resend the call. Fixes: a0584ee9aed80 ("SUNRPC: Use struct xdr_stream when decoding...") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- net/sunrpc/clnt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index e7fdc400506e8..f7f78566be463 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2482,6 +2482,7 @@ call_decode(struct rpc_task *task) struct rpc_clnt *clnt = task->tk_client; struct rpc_rqst *req = task->tk_rqstp; struct xdr_stream xdr; + int err; dprint_status(task); @@ -2504,6 +2505,15 @@ call_decode(struct rpc_task *task) * before it changed req->rq_reply_bytes_recvd. */ smp_rmb(); + + /* + * Did we ever call xprt_complete_rqst()? If not, we should assume + * the message is incomplete. + */ + err = -EAGAIN; + if (!req->rq_reply_bytes_recvd) + goto out; + req->rq_rcv_buf.len = req->rq_private_buf.len; /* Check that the softirq receive buffer is valid */ @@ -2512,7 +2522,9 @@ call_decode(struct rpc_task *task) xdr_init_decode(&xdr, &req->rq_rcv_buf, req->rq_rcv_buf.head[0].iov_base, req); - switch (rpc_decode_header(task, &xdr)) { + err = rpc_decode_header(task, &xdr); +out: + switch (err) { case 0: task->tk_action = rpc_exit_task; task->tk_status = rpcauth_unwrap_resp(task, &xdr); -- 2.20.1