Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp701495ybh; Tue, 10 Mar 2020 06:44:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvg0zH+hh7GMZck0uqUPbJDBPdh89Ao3LQcSg06E+rFDJclJIeUvf7I12UiZCAvbog7A6gT X-Received: by 2002:a9d:70c8:: with SMTP id w8mr17754393otj.144.1583847856781; Tue, 10 Mar 2020 06:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583847856; cv=none; d=google.com; s=arc-20160816; b=W3rTVIE1b/ME7VZvNi6aE1PBuxi0eKlMSYBk3otyYKk0AXNvzJBlvoiteuKiOlinRu JD/EF09UbKnW/MCEngIPAEbIbjsLrnCRB05e0opOlg4RtA4q1LHI9D4FMDnerK5rZ//e h0rTKIzMzwoZ1tB8Wi27GTkT/H5suOI1At8NnDMmEdrsKYHvPKzQUbuajgmss+Akd1bF O5hlNOUNffJeMLQLFt6M0Kfwa+wC3n2ZQAn4pcijgKHD2PPCaDr6RbnJHkZriD8W7Ob3 fofo7Xn4lqqGWtBMbFXPvWx3mCCwYJvIS022lR2Ieh6eT9sb+nopskfvVwza9j6Mru87 PZqA== 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:subject:cc:to :from:dkim-signature; bh=D6Q9+IHZM96DCO+KPHYi5h8sysPgERmqkF1QUXj4VRY=; b=QfZWg5EJ4K7JCxpTacihOMZm8xRAtw7oRcE+uRnhwfEGWHwRifWb0N8KB26IWAAVkP E1+LWiciRR48+AdO8UQMJebLfdUWhfzbcJg9xNpHrL6RNhWRQ+U3Oaai7uNE98nQVS9Q ZHRg/76hnB+tShuusBTp1dZ4n1jJgbfscdnZ6jkvLcPWwczNfryz/IDeXmXODc2TiS0c wxsrhrje/XqgSFBgC3s2zS4OjV2dRr0a4jdj6j8Vu4TZnwIOEiYQTOVgYPErIiv3pOdM 1W4F79x3vJZwyeTszK9jB/URQ3Cigs31fGFd9MBzZPWbtj/164ce1SrxBwS1fI7LRqac knEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wlUc5nrJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k98si8019270otk.61.2020.03.10.06.44.04; Tue, 10 Mar 2020 06:44:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wlUc5nrJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727706AbgCJNfs (ORCPT + 99 others); Tue, 10 Mar 2020 09:35:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727671AbgCJMoA (ORCPT ); Tue, 10 Mar 2020 08:44:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 94FF824693; Tue, 10 Mar 2020 12:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583844240; bh=rT/guU/aACRynQqnHmNwjF9jC3hiPxcb+PyGiqR+f/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wlUc5nrJ81XllAyIZ6N4zyu8SANDeQiRclsTFRQ8vePtq3naPYjvCsS0bQ8GGrNKp vPyoI2uUFFd1yk4OI2vM71LRSczMK+v2pLiG0Fw9eTdkvBRQ4oTJ4FnONIqeFMwLsj ALyurMWgYocSgGU4KcXzKWMvGm9X7uCNdCTIaUQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sameeh Jubran , Arthur Kiyanovski , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 10/88] net: ena: fix potential crash when rxfh key is NULL Date: Tue, 10 Mar 2020 13:38:18 +0100 Message-Id: <20200310123609.011583695@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123606.543939933@linuxfoundation.org> References: <20200310123606.543939933@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arthur Kiyanovski [ Upstream commit 91a65b7d3ed8450f31ab717a65dcb5f9ceb5ab02 ] When ethtool -X is called without an hkey, ena_com_fill_hash_function() is called with key=NULL, which is passed to memcpy causing a crash. This commit fixes this issue by checking key is not NULL. Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Sameeh Jubran Signed-off-by: Arthur Kiyanovski Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/amazon/ena/ena_com.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c index 912dc09bc7a74..f09b7887039a2 100644 --- a/drivers/net/ethernet/amazon/ena/ena_com.c +++ b/drivers/net/ethernet/amazon/ena/ena_com.c @@ -2034,15 +2034,16 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev, switch (func) { case ENA_ADMIN_TOEPLITZ: - if (key_len > sizeof(hash_key->key)) { - pr_err("key len (%hu) is bigger than the max supported (%zu)\n", - key_len, sizeof(hash_key->key)); - return -EINVAL; + if (key) { + if (key_len != sizeof(hash_key->key)) { + pr_err("key len (%hu) doesn't equal the supported size (%zu)\n", + key_len, sizeof(hash_key->key)); + return -EINVAL; + } + memcpy(hash_key->key, key, key_len); + rss->hash_init_val = init_val; + hash_key->keys_num = key_len >> 2; } - - memcpy(hash_key->key, key, key_len); - rss->hash_init_val = init_val; - hash_key->keys_num = key_len >> 2; break; case ENA_ADMIN_CRC32: rss->hash_init_val = init_val; -- 2.20.1