Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp23161pxb; Fri, 15 Jan 2021 04:58:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMU/sNw7jkHIt+hVncQIcEMClYNPN4cxL0GCghsLUbBfUvgWgYK+AzMrnHDmNzLztV4Ela X-Received: by 2002:a17:906:af49:: with SMTP id ly9mr8453154ejb.38.1610715506017; Fri, 15 Jan 2021 04:58:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715506; cv=none; d=google.com; s=arc-20160816; b=NnZloVpID64HcIcvttUxxJAj9xy0nXmo1ITjVQOJA7mWRR+incz6CyV/d/DTu1xFWu 360Lq9BiAYb4dYWfUTFsqC7WWKwbllEVGC1SdVSv8T9EgtXhNzBB1v9o5DS3+VIQaPD/ g2NiDvLKskPgVk9YPT6a60n1YI2qYC7HN968QCSFVJ9XxRlY17EUnQccS/efmSUKkCal fmmkcuCQYBNNZjGoYLEIW1HKIg0bJCvyrf44t5qaDUSiITpnbN4sB1Je2EFGHo4lbJ6T xDAtAgqX1TctR7hssXzGV+8X0MplayypXCQiVIoyIk1nR1WXh8M3RDf5qUIu4lNvV8eb A4wA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zpj6naBbJX433rEU5pw1zpNnOSrLwHJu1cBmLhrkhCc=; b=vgZD/XA4U0sZ0KDSv4r+92PHzNYIIrtvDCR8egEmFdWeMsZDGWaiPrpo78rDaWOF53 uKqQV4sBlAAXlKQLm9MAG+13pWb6xHqEypJ+QdruuaRZrY//+RJozIQcz6laAnJ0Y1ce 3newHY/eruw6nb+PKTUrDUGv0e9hyvAgf0QPqaKEq4V16xoKG2T8qUODG80AIPt8rIVE XqjKvOHCWN8Nhyqw8w6oDLM7z12vwPPqrKHbdiy9XWVLUmZVe4ArEHp8hc+IlqJxgwck xXLwwx5OKAt9S4EZUP0Hq+Axl+vvhHB6ermvPQ6mY8yLBVBwcYhw+gQ9dArBQaTt3sfs 0wew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="EXz+/S1y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si4465538edd.509.2021.01.15.04.58.02; Fri, 15 Jan 2021 04:58:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="EXz+/S1y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733121AbhAOM5K (ORCPT + 99 others); Fri, 15 Jan 2021 07:57:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:40776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387444AbhAOMeX (ORCPT ); Fri, 15 Jan 2021 07:34:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E11B23136; Fri, 15 Jan 2021 12:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714047; bh=FOF83rE0CsDT5m7dDfLkq5nxSueUVP1YTUqnm0XU+6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EXz+/S1y7Z7lMFEIhuk9mMKMTBZjOMuD5kKfJNV8dv2tb4Gv4odcQnWcd0I5fA2ts cB1f3Ntozk3CtMFIez7sdBRDjaSr+1VNCXA/ffwfyIP1AlVCzzIs8AMp0GHqav0Jyn CLXyvKP25eH1iPnEBoZJrTxuqRT5NXnInNE64vLg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rohit Maheshwari , Ayush Sawal , Jakub Kicinski Subject: [PATCH 5.4 23/62] chtls: Fix panic when route to peer not configured Date: Fri, 15 Jan 2021 13:27:45 +0100 Message-Id: <20210115121959.532751577@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121958.391610178@linuxfoundation.org> References: <20210115121958.391610178@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ayush Sawal [ Upstream commit 5a5fac9966bb6d513198634b0b1357be7e8447d2 ] If route to peer is not configured, we might get non tls devices from dst_neigh_lookup() which is invalid, adding a check to avoid it. Fixes: cc35c88ae4db ("crypto : chtls - CPL handler definition") Signed-off-by: Rohit Maheshwari Signed-off-by: Ayush Sawal Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/chelsio/chtls/chtls_cm.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/drivers/crypto/chelsio/chtls/chtls_cm.c +++ b/drivers/crypto/chelsio/chtls/chtls_cm.c @@ -1021,6 +1021,7 @@ static struct sock *chtls_recv_sock(stru const struct cpl_pass_accept_req *req, struct chtls_dev *cdev) { + struct adapter *adap = pci_get_drvdata(cdev->pdev); struct inet_sock *newinet; const struct iphdr *iph; struct tls_context *ctx; @@ -1030,9 +1031,10 @@ static struct sock *chtls_recv_sock(stru struct neighbour *n; struct tcp_sock *tp; struct sock *newsk; + bool found = false; u16 port_id; int rxq_idx; - int step; + int step, i; iph = (const struct iphdr *)network_hdr; newsk = tcp_create_openreq_child(lsk, oreq, cdev->askb); @@ -1044,7 +1046,7 @@ static struct sock *chtls_recv_sock(stru goto free_sk; n = dst_neigh_lookup(dst, &iph->saddr); - if (!n) + if (!n || !n->dev) goto free_sk; ndev = n->dev; @@ -1053,6 +1055,13 @@ static struct sock *chtls_recv_sock(stru if (is_vlan_dev(ndev)) ndev = vlan_dev_real_dev(ndev); + for_each_port(adap, i) + if (cdev->ports[i] == ndev) + found = true; + + if (!found) + goto free_dst; + port_id = cxgb4_port_idx(ndev); csk = chtls_sock_create(cdev); @@ -1108,6 +1117,7 @@ static struct sock *chtls_recv_sock(stru free_csk: chtls_sock_release(&csk->kref); free_dst: + neigh_release(n); dst_release(dst); free_sk: inet_csk_prepare_forced_close(newsk);