Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4576927ybi; Tue, 11 Jun 2019 08:53:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIRtcGW0J7U110uGuxPaBrsDv3epof7K2AmTENm7V1uw9Z/F1DipFx1cHgRRjjxN/6VH5m X-Received: by 2002:a62:29c7:: with SMTP id p190mr79977382pfp.218.1560268407661; Tue, 11 Jun 2019 08:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560268407; cv=none; d=google.com; s=arc-20160816; b=sz4U6JFFifphPVlahsrnBQy0+1ect/wwBq7mKrzuBUFvXKRF0DAkMtLIXQW+DxR1Mx h3oJNHGXlY3dFYJmPNpzi7W/RU0gIH8Y0W0gtJUcXu8W+vpD858i5TyZ2ywG0dfW7LRo HfxVBg2RodUU45tBxyB6it8BP2C3WxSgLx2u65gPwLqjuFbRxLm77qVmUn7nG42SIu+t pW9QXS2SflVNmCvmOs5qRifdezUZPeInAme4Fy13xsVnxHxntWY8//CkitcA8VCjkAq7 mXTpH3YcqAxDmiILPshhMBti9kL+zmL8ALNgOQ2041UL0PMjBPAPqtHdF8Br+QExHUPE GSSQ== 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=to3mUAty1JalteouLQzDvBtpnJX/PiznlXHIlSo5tHE=; b=Rf8YTJJWSo9TMTgfezpeubEQZzqnRLmWdGVEsTTD42d3703kKDSM4HT3i5S2CHKIcp 7ALtivoLCytS7kicPd5+tct1PXrV9nS2RgKgN8HbRht4Wca/R2kz1unOAycX3cQ+P+Lp W/RmNO27vMK2FJEZ5XfspTXFsbEHnXuajDSdS5AShH9CiPjRo0J95L2lwhd7fFcwBXmi agwfaKZnfuCF/s1uustEkL53v7TT2hAujxGOUWy4ALGTzgczeGzdOjto6oC4E4gOMnJ1 B4Oh6AVrgcNIuNx2w8jKMUWzmJlKTap8cYay4dA4dy/8QOUnif4Bw7jPPO6GfA/+J4Gu KclA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=AMifTe6j; 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 j19si12385064pgh.483.2019.06.11.08.53.13; Tue, 11 Jun 2019 08:53:27 -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=AMifTe6j; 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 S2390926AbfFKPIL (ORCPT + 99 others); Tue, 11 Jun 2019 11:08:11 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:35996 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391648AbfFKPIL (ORCPT ); Tue, 11 Jun 2019 11:08:11 -0400 Received: by mail-io1-f66.google.com with SMTP id h6so10195742ioh.3; Tue, 11 Jun 2019 08:08:10 -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=to3mUAty1JalteouLQzDvBtpnJX/PiznlXHIlSo5tHE=; b=AMifTe6jgf8POrXtrV+PV8sA+N1SPCGFGgpuVVR6P5QNrcQnCYCAOcS0zyrg2qxZCr DKLiM5v76xlEyDhw12xKkHebfIC9Nxmz8f2Y+X947MNmFlgkpegE/L9BAVUec2IoUONu m1lAwn4SPHajNVSTICVAxUNhQnKE6RwPPvtojKZQdih0/8g2ySOdi1o/wHxTQxUVICOT ymwuln3QtkyD5qnLQPPPkKvWXGTPqVTPDkrXexv/TGFKVz9v325gwdsAoJ+M1BU1G5d1 T87v0wTgNNv6K2cmdwbPpzhRaoh8hzLwEOvWs/m9tBqS3+EdrP+O07glaU/O8vGH4ZJk sllg== 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=to3mUAty1JalteouLQzDvBtpnJX/PiznlXHIlSo5tHE=; b=MrCHBU9M0K1iG5n53bTnrZz7P60P6OR3rlp63NhFhuc7YmNowXI88C79SuslhWn1Yk 6pSCO8WECw9A+QISKgqhT6rytRJqR7/9IZ/d2nAiXklsPUNoiqstKVPib14H87HEbAka 3LoRApDsL+IsI0dXjOwtve3aoqONv4qr/sTD4nK58HsEBmQIshZlXwjpU9c6fGxSLXAk 2/7hbOLuNd4jzh7071OfVa77kuAGhcnohDd4Faeg1wC2rz2jKTy/AZkwQ/naZKPZQ2VM IfhVzDHaQCb+3ujZ7Kk0be7/ON5SlcipmowOqkkV9JrnuH1XDcj5Xc5nYZl3sHbyKObn RZVQ== X-Gm-Message-State: APjAAAU9ojGfIwP7UhSfIIiORv9MmyMIMKihj11axNwgyv175IJByD3c lNv5B+4YMRV4oZCZ0FCryLg4R+Nk X-Received: by 2002:a5e:db0a:: with SMTP id q10mr2313061iop.168.1560265690121; Tue, 11 Jun 2019 08:08:10 -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 h190sm1281313ita.22.2019.06.11.08.08.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 08:08:09 -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 x5BF88Nx021731; Tue, 11 Jun 2019 15:08:08 GMT Subject: [PATCH v2 02/19] xprtrdma: Fix use-after-free in rpcrdma_post_recvs From: Chuck Lever To: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org Date: Tue, 11 Jun 2019 11:08:08 -0400 Message-ID: <20190611150808.2877.90221.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 Dereference wr->next /before/ the memory backing wr has been released. This issue was found by code inspection. It is not expected to be a significant problem because it is in an error path that is almost never executed. Fixes: 7c8d9e7c8863 ("xprtrdma: Move Receive posting to ... ") Signed-off-by: Chuck Lever --- net/sunrpc/xprtrdma/verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index 84bb379..e71315e 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -1553,10 +1553,11 @@ static void rpcrdma_regbuf_free(struct rpcrdma_regbuf *rb) rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr, (const struct ib_recv_wr **)&bad_wr); if (rc) { - for (wr = bad_wr; wr; wr = wr->next) { + for (wr = bad_wr; wr;) { struct rpcrdma_rep *rep; rep = container_of(wr, struct rpcrdma_rep, rr_recv_wr); + wr = wr->next; rpcrdma_recv_buffer_put(rep); --count; }