Message ID | 20230202184850.29882-1-n.zhandarovich@fintech.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp421286wrn; Thu, 2 Feb 2023 11:11:49 -0800 (PST) X-Google-Smtp-Source: AK7set8D2yChXQeDisuwiHSRbp0Xeaz1nkNEfEPXAQTBSMMIbThnVqq9wrD8XpxkVIHAnJ1lVmbN X-Received: by 2002:a17:90a:730c:b0:22c:8ba1:bd70 with SMTP id m12-20020a17090a730c00b0022c8ba1bd70mr7424731pjk.19.1675365108747; Thu, 02 Feb 2023 11:11:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675365108; cv=none; d=google.com; s=arc-20160816; b=mqLkGf4Jdq3QHxJuf8/46yT8w1062IHQGW2uIr4KN+c5eSUVHUPoq14qtYhzCudi/C dQy03wNHY0LKm3SN9nPJfYAv73VuovNfmUpXenydF+mkk6Wvb0eSKAW4QMIbx7h7mk6M Acbk5QkN55aB8BU+QsPTBf2l+yPzAv25D8ncJHRmUcqeheYqRTI/VruBHz8jiyCYOHMP 9gUgP7Bxe9gjcjyFN6/w6lUWxWZwEHdW4FKU2ZOtNqOWBhVedjImEQvoktA3KHkpEsbD N+kjsC7SeS3uLBOGq0uRzeK0zkhs2HyKP2t7AEmhLMPAdh+y4JzvMyLtc4M+1iBdsW9c UvCw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Aqfd7D++32zkaiB4uGkYD1cYmzQDXA+jylvr2t0Fa9I=; b=XZ35XvJdPsViJsZJ2afuj+lxNXfiVgAc8qHacOqV3+cRdlxOHyMeShlf4sqSqDBgbK 0vSW9Cg7aTFUrYQHkiyFpUPVVMhGdhDxFxhBZxkXHSe/Nb44sFkmt1Haz2deBt++nJRd gkTfAF0K/CczxUS9gKFTsS61IngUBosjqKE8D3SPzOkUYy0jbKPag8BNGk+gZYSR8EoK sCT6q5uK8AG5EV69CBThDMuENeRJCsP37Kp6ExLidvsqxNgtDtx1IP6fD8jXe3Vmagzm XhJ9PsBGwsb31Q1phLDGXABeHFuiRSeic9BvQj8iYh5JGVT7vq9YXRxpsTpOHUpdjghd A3zA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds16-20020a17090b08d000b0021a1261c317si5215069pjb.126.2023.02.02.11.11.33; Thu, 02 Feb 2023 11:11:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232262AbjBBSs7 (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); Thu, 2 Feb 2023 13:48:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbjBBSs6 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Feb 2023 13:48:58 -0500 Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6E83D4; Thu, 2 Feb 2023 10:48:55 -0800 (PST) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Thu, 2 Feb 2023 21:48:54 +0300 Received: from localhost (10.0.253.157) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Thu, 2 Feb 2023 21:48:53 +0300 From: Nikita Zhandarovich <n.zhandarovich@fintech.ru> To: Potnuri Bharat Teja <bharat@chelsio.com> CC: Nikita Zhandarovich <n.zhandarovich@fintech.ru>, Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>, <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org> Subject: [PATCH v2] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish() Date: Thu, 2 Feb 2023 10:48:50 -0800 Message-ID: <20230202184850.29882-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <Y9vdndjG0e9cCaI/@ziepe.ca> References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.157] X-ClientProxiedBy: Ex16-01.fintech.ru (10.0.10.18) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756731507567939309?= X-GMAIL-MSGID: =?utf-8?q?1756747644039894224?= |
Series |
[v2] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()
|
|
Commit Message
Nikita Zhandarovich
Feb. 2, 2023, 6:48 p.m. UTC
If get_ep_from_tid() fails to lookup non-NULL value for ep, ep is
dereferenced later regardless of whether it is empty.
This patch adds a simple sanity check to fix the issue.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 944661dd97f4 ("RDMA/iw_cxgb4: atomically lookup ep and get a reference")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
---
v2: do not use pr_warn() when get_ep_from_tid() returns NULL as
Jason Gunthorpe <jgg@ziepe.ca> suggested.
drivers/infiniband/hw/cxgb4/cm.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Thu, Feb 02, 2023 at 10:48:50AM -0800, Nikita Zhandarovich wrote: > If get_ep_from_tid() fails to lookup non-NULL value for ep, ep is > dereferenced later regardless of whether it is empty. > This patch adds a simple sanity check to fix the issue. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 944661dd97f4 ("RDMA/iw_cxgb4: atomically lookup ep and get a reference") > Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru> > --- > v2: do not use pr_warn() when get_ep_from_tid() returns NULL as > Jason Gunthorpe <jgg@ziepe.ca> suggested. > > drivers/infiniband/hw/cxgb4/cm.c | 2 ++ > 1 file changed, 2 insertions(+) I applied, but please next time. 1. Don't send patches as reply-to. It messes whole patch flow. 2. Use target in subject line, e.g. [PATCH rdma-next] or [PATCH rdma-rc] Thanks > > diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c > index 499a425a3379..f5f4579f037c 100644 > --- a/drivers/infiniband/hw/cxgb4/cm.c > +++ b/drivers/infiniband/hw/cxgb4/cm.c > @@ -2676,6 +2676,8 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb) > u16 tcp_opt = ntohs(req->tcp_opt); > > ep = get_ep_from_tid(dev, tid); > + if (!ep) > + return 0; > pr_debug("ep %p tid %u\n", ep, ep->hwtid); > ep->snd_seq = be32_to_cpu(req->snd_isn); > ep->rcv_seq = be32_to_cpu(req->rcv_isn); > -- > 2.25.1 >
On Thu, 02 Feb 2023 10:48:50 -0800, Nikita Zhandarovich wrote: > If get_ep_from_tid() fails to lookup non-NULL value for ep, ep is > dereferenced later regardless of whether it is empty. > This patch adds a simple sanity check to fix the issue. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > > [...] Applied, thanks! [1/1] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish() https://git.kernel.org/rdma/rdma/c/283861a4c52c1e Best regards,
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index 499a425a3379..f5f4579f037c 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -2676,6 +2676,8 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb) u16 tcp_opt = ntohs(req->tcp_opt); ep = get_ep_from_tid(dev, tid); + if (!ep) + return 0; pr_debug("ep %p tid %u\n", ep, ep->hwtid); ep->snd_seq = be32_to_cpu(req->snd_isn); ep->rcv_seq = be32_to_cpu(req->rcv_isn);