Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4576954ybi; Tue, 11 Jun 2019 08:53:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyobC+hyB+FEpvkIyhMphoD4JcGTpWWnE/RKaOYU36pu1cFlKAbZGHGAkUXHPtEt8aQ+egW X-Received: by 2002:a17:90a:d817:: with SMTP id a23mr12100050pjv.54.1560268409060; Tue, 11 Jun 2019 08:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560268409; cv=none; d=google.com; s=arc-20160816; b=cZOWZOSmWlFzHrk13HTjOpFKZwd0NsI1yeXDCOv6FKyhEQFEre8pVgq15JYowQ3OqP +g4nF6ggEmwb4qJGJtb/Os4gZZD6NKgkhwcrGo3V8kJXJJL0pSg5EsVjs1tcG1cWHW1Q IO/9PRdaEy8alcfH3PNDSRP6CPh+lfOAWNxE0Obnp4gx6sjghyTJM1emVOFJiy3P7Gv/ vpfE7SYCwxkO+Xk/to1wZWSLi1rA25zO3ZqQtwSYqF25lqsx0czOpaq9vPhQuCf9Jkxd BZ3VSOqlTF+o+Niit7ue6nJMgkCUN9RnR9L7oD86ToiC1/VyNCgitIDWOJ04L65GPj2o S81Q== 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:to:from:subject :dkim-signature; bh=6zZ4tkwEhPr42aF/uPwSUocP/SoqMOuOJIwVpK5kan0=; b=rqbmuquaNZ982qvajm4THKQt4SnsKpEhsHiVYCH48OWIhTEL6GCGPjH7lBcBuBk88T fi7LX76cLMs1wH6+qIe/0e7kEW9VygkBTc4PmisG8s5XWl5y0wyKc06agQ5KRlupLJ6P m4A81yVPmdWbGAh5q7frYlV+Ur3mXzUNYtHTNV7ZBJaAyFeFDC4AAmACHMl/xz4fCW8V 7xSI24+/+UWDyrATK9YfinU659XVuz/6RpIY6te/mbeTaR/HKfDsy86WWrJLNiZdZ7mN v4vv+BUBIRFqRKdQIDpSk6J4LvPzFdGFNM/nHXURDAlEGCcarNAfau7dhHwb5Xn1XOPR yseg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rGnBHQhl; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go22si11734738plb.150.2019.06.11.08.53.14; Tue, 11 Jun 2019 08:53:29 -0700 (PDT) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rGnBHQhl; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391648AbfFKPIQ (ORCPT + 99 others); Tue, 11 Jun 2019 11:08:16 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:39157 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391203AbfFKPIQ (ORCPT ); Tue, 11 Jun 2019 11:08:16 -0400 Received: by mail-it1-f195.google.com with SMTP id j204so5287486ite.4; Tue, 11 Jun 2019 08:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=6zZ4tkwEhPr42aF/uPwSUocP/SoqMOuOJIwVpK5kan0=; b=rGnBHQhlBD1dDFyz/GH5KsrGyDAxzPkz8EbkrR80YVx9WXF2/NywEqGIob3cYkpAwJ cXAI+PB+6S+kmfteKipMgdJvAxZ1xKOg5yz18tk8OsVOQgG1jqKXBwAhJMfMC1lpELEX 4WpUTeISm72Jw2WdUuNujpM5QJG9wPKS5QzrTdIldRECIbUZWRvsJSYtjFQ17He4hZj1 Wb88FwQHpQUTnB5DpoyvokFt3gzNMKZmHKF1dX9in9c3J5muFpPXxVK1/63Jalf6Ohje BfdYyNp7aJji9jVqz3FFfEQGa/6UBZRK0JfVbInVIm+YB9/Qxv59kZCGqM9ABQxn3cEW HJqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=6zZ4tkwEhPr42aF/uPwSUocP/SoqMOuOJIwVpK5kan0=; b=AvjCRCiRpp4j/e2AYFJUaE6xZUoDr18Fxe843ryy5rFjIpWq1hZIQUZ/Zdgmo2tBfn /YyxhEvwZc+2pD6Oj+qFo4t9gTaJz6K+TzkqR5fh4FO6+PztFVNLHF616ckkxXKJTOSf vuOadyglIgvgmZ81ZWgoFsYubpdVFJ6AkEb+RfVDsKxLWDScGIJ4q5wG5FWyKjvaPp7c +L0RyMlRFlQnJgSfz7EzlUtv22k3wUVnceNgn3Or6HntGdeUPCSzBrgiX/f94iMvbzVy 62f/LTvaxaGRO7u9dvYQ75Et63I16oAMxGsKBEZCDUt5r5FNMjj19XiCkkOb8dyHECaJ zLNA== X-Gm-Message-State: APjAAAXCJDPcA2iPjnSTYyYIi1Rgdatj20Ra2QHYDjo7LZDC6NwzIJH/ vSpZG8xnpv976JoVO+D5twx2vd+y X-Received: by 2002:a24:6885:: with SMTP id v127mr18457554itb.177.1560265695441; Tue, 11 Jun 2019 08:08:15 -0700 (PDT) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id d3sm1384827itg.9.2019.06.11.08.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 08:08:15 -0700 (PDT) Received: from manet.1015granger.net (manet.1015granger.net [192.168.1.51]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id x5BF8Elv021734; Tue, 11 Jun 2019 15:08:14 GMT Subject: [PATCH v2 03/19] xprtrdma: Replace use of xdr_stream_pos in rpcrdma_marshal_req From: Chuck Lever To: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Tue, 11 Jun 2019 11:08:14 -0400 Message-ID: <20190611150814.2877.87715.stgit@manet.1015granger.net> In-Reply-To: <20190611150445.2877.8656.stgit@manet.1015granger.net> References: <20190611150445.2877.8656.stgit@manet.1015granger.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This is a latent bug. xdr_stream_pos works by subtracting xdr_stream::nwords from xdr_buf::len. But xdr_stream::nwords is not initialized by xdr_init_encode(). It works today only because all fields in rpcrdma_req::rl_stream are initialized to zero by rpcrdma_req_create, making the subtraction in xdr_stream_pos always a no-op. I found this issue via code inspection. It was introduced by commit 39f4cd9e9982 ("xprtrdma: Harden chunk list encoding against send buffer overflow"), but the code has changed enough since then that this fix can't be automatically applied to stable. Signed-off-by: Chuck Lever --- include/trace/events/rpcrdma.h | 9 +++++---- net/sunrpc/xprtrdma/rpc_rdma.c | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/trace/events/rpcrdma.h b/include/trace/events/rpcrdma.h index f0678e3..59492a93 100644 --- a/include/trace/events/rpcrdma.h +++ b/include/trace/events/rpcrdma.h @@ -470,13 +470,12 @@ TRACE_EVENT(xprtrdma_marshal, TP_PROTO( - const struct rpc_rqst *rqst, - unsigned int hdrlen, + const struct rpcrdma_req *req, unsigned int rtype, unsigned int wtype ), - TP_ARGS(rqst, hdrlen, rtype, wtype), + TP_ARGS(req, rtype, wtype), TP_STRUCT__entry( __field(unsigned int, task_id) @@ -491,10 +490,12 @@ ), TP_fast_assign( + const struct rpc_rqst *rqst = &req->rl_slot; + __entry->task_id = rqst->rq_task->tk_pid; __entry->client_id = rqst->rq_task->tk_client->cl_clid; __entry->xid = be32_to_cpu(rqst->rq_xid); - __entry->hdrlen = hdrlen; + __entry->hdrlen = req->rl_hdrbuf.len; __entry->headlen = rqst->rq_snd_buf.head[0].iov_len; __entry->pagelen = rqst->rq_snd_buf.page_len; __entry->taillen = rqst->rq_snd_buf.tail[0].iov_len; diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c index 85115a2..97bfb80 100644 --- a/net/sunrpc/xprtrdma/rpc_rdma.c +++ b/net/sunrpc/xprtrdma/rpc_rdma.c @@ -867,12 +867,12 @@ static bool rpcrdma_prepare_msg_sges(struct rpcrdma_xprt *r_xprt, if (ret) goto out_err; - trace_xprtrdma_marshal(rqst, xdr_stream_pos(xdr), rtype, wtype); - - ret = rpcrdma_prepare_send_sges(r_xprt, req, xdr_stream_pos(xdr), + ret = rpcrdma_prepare_send_sges(r_xprt, req, req->rl_hdrbuf.len, &rqst->rq_snd_buf, rtype); if (ret) goto out_err; + + trace_xprtrdma_marshal(req, rtype, wtype); return 0; out_err: