[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240918150949.7089-2-n.zhandarovich@fintech.ru>
Date: Wed, 18 Sep 2024 08:09:49 -0700
From: Nikita Zhandarovich <n.zhandarovich@...tech.ru>
To: Steve Wise <swise@...lsio.com>
CC: Nikita Zhandarovich <n.zhandarovich@...tech.ru>, Doug Ledford
<dledford@...hat.com>, Jason Gunthorpe <jgg@...pe.ca>, Leon Romanovsky
<leon@...nel.org>, <linux-rdma@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <lvc-patches@...uxtesting.org>,
<lvc-project@...uxtesting.org>
Subject: [PATCH 4.19/5.4/5.10 1/1] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()
From: Nikita Zhandarovich <n.zhandarovich@...tech.ru>
commit 283861a4c52c1ea4df3dd1b6fc75a50796ce3524 upstream.
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@...tech.ru>
Link: https://lore.kernel.org/r/20230202184850.29882-1-n.zhandarovich@fintech.ru
Signed-off-by: Leon Romanovsky <leon@...nel.org>
---
drivers/infiniband/hw/cxgb4/cm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index ea3ddf0d241142..ced615b5ea096e 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -2676,6 +2676,9 @@ 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);
--
cgit 1.2.3-korg
Powered by blists - more mailing lists