From patchwork Thu Feb 2 14:52:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Zhandarovich X-Patchwork-Id: 51977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp284018wrn; Thu, 2 Feb 2023 06:55:20 -0800 (PST) X-Google-Smtp-Source: AK7set+9wrrQ9qbODF/Onuk39DbT3pIEELUpQPRRLrMCub7SzO3xHCRv/MKrSYBomKb7JTAXFKCz X-Received: by 2002:a05:6a21:3990:b0:bf:8840:ffd0 with SMTP id ad16-20020a056a21399000b000bf8840ffd0mr3348728pzc.29.1675349719995; Thu, 02 Feb 2023 06:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675349719; cv=none; d=google.com; s=arc-20160816; b=BEbR8C10LVTwdSUR08s8juSGKEgZ1GxkZzbEFX7lYVOTdxjPD7riUAA948nq+HWuZl j7DdHN8cPa1pMWY9yBzA6MD+bsDas7UQ6VjsadcirnDtEMI9U6N/reFYcnvxaToxehCL 5+3WeL17vBUSOyt+B/zoMajn/5xwXe8uFUJKbATpcNG2t4AT39Ik2N0vVRuPEvHWMOvd G5B4gJNNQ6MHc29rEksXdvFXiysyU9AIZrzhc8ln+vrKKRclNxqt5lH8+WYGF+Oj7m0r 4snRRvSn7IVQmdzNGOMeqo5vs2xGxV5ldQ0gZL1Z9gdPym/dOe8rYbrt3YTi1f1BGSKJ vWGQ== 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 :message-id:date:subject:cc:to:from; bh=gnwvpLt1B0ZMiHq9VgPLeVJ8ClUaSdfxYl4dx2wR5bo=; b=lza6W/hLwkOd23bshzakGw7JpaaWXIVdJYNU4Z/cFVxf8CeYE08WysiHXNpCBrx1Q4 sLanckG9X8bxidhPaMpAn6yY3GXPJWhwwv8lUSrWo8iwJTrPTDE62Q4kqvEWuXj4VwvC JxxjAHBmmATgSqzHp4F2AzNn/52H7+p+Bwvxi6SjL8A0/ctJ9HNnI7XjsKjcFEKxO+PB iwhIBi5SOvIh3TrnknbiJm1aknW5Kv8ZRzkdG57qzqTCnVNnDczL3UohPbHriA2tTTkl 50Dsbd8b37mEqIdt6r6yEIibRj0CNdsIjyGW6cOY3MSk29Sg577dswZ3mUdsBU1tXJFg iQLQ== 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 e25-20020a637459000000b004a5c9673b66si23598192pgn.323.2023.02.02.06.55.07; Thu, 02 Feb 2023 06:55:19 -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 S231895AbjBBOx4 (ORCPT + 99 others); Thu, 2 Feb 2023 09:53:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232677AbjBBOxT (ORCPT ); Thu, 2 Feb 2023 09:53:19 -0500 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22CA8C150; Thu, 2 Feb 2023 06:53:01 -0800 (PST) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Thu, 2 Feb 2023 17:52:46 +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 17:52:46 +0300 From: Nikita Zhandarovich To: Potnuri Bharat Teja CC: Nikita Zhandarovich , Jason Gunthorpe , Leon Romanovsky , , , Subject: [PATCH] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish() Date: Thu, 2 Feb 2023 06:52:22 -0800 Message-ID: <20230202145222.25571-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: 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?1756731507567939309?= 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 --- drivers/infiniband/hw/cxgb4/cm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index c16017f6e8db..f4a02c2ec02f 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -2683,6 +2683,10 @@ 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) { + pr_warn("%s tid %d lookup failure!\n", __func__, tid); + 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);