Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CEADCC4332F for ; Sun, 18 Dec 2022 16:16:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 68C518141C; Sun, 18 Dec 2022 16:16:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 68C518141C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1671380216; bh=31LYitE2iL0W4k2MM/S0+eh8E8w4wyfKwKG7Cr67m+s=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Ky9m84iqD19ejuQoJA3uWIFmOolM1c0aw5fJc/ckIE7b0xzYN2CwJIH0iaJbHoL0r 44AUDIQgh+KqORTzFaZdQys9NmuWltP9yVcKRKsmDti5V7q8bDHxXYJ2Mk0KuBrjv8 fEZ1tD67J5+rXHQRaSZYaS7ibUbH15i0C4hXp8PNNePF+H1+VWc4CFQnZKx103eIjR eBaVlHHlPjpclvZQHpxd3cGD2/TsdO9W5vpVO0j9bmYa37vONt2CmYKHilxFLobu4S haSRmpU8H2Mjg+dhwExKgpbDoIgk9iwVhiSjSy5g0cRmSobyUr+IBK79vMOAR0fuAu RM1IidUoTVKFQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id twrUbfAyVMWD; Sun, 18 Dec 2022 16:16:55 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 5EAB781420; Sun, 18 Dec 2022 16:16:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 5EAB781420 Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 4CF641BF3A3 for ; Sun, 18 Dec 2022 16:16:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 34835607E3 for ; Sun, 18 Dec 2022 16:16:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 34835607E3 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J9dqn1LCdn4h for ; Sun, 18 Dec 2022 16:16:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7A8EA605A9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by smtp3.osuosl.org (Postfix) with ESMTPS id 7A8EA605A9 for ; Sun, 18 Dec 2022 16:16:53 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9FC460DB4; Sun, 18 Dec 2022 16:16:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9B59C433EF; Sun, 18 Dec 2022 16:16:50 +0000 (UTC) From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Sun, 18 Dec 2022 11:15:33 -0500 Message-Id: <20221218161559.932604-13-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218161559.932604-1-sashal@kernel.org> References: <20221218161559.932604-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380212; bh=sE4hrr5Z9y8FJNwHZ0rPPc/HvQ6jdCGqKbBbYo6socc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qceLxy8YdYcV1A/FgcwOzFupt32rnAJCyu0cQAdFRop/mlGtWCu0ZY+ZR9CzJaXpv E7i/BtAsOIYZPOpJwa6a0MTg9a6J2AulhgKXKA3/cZcry/JJ7GUhItoHfkyopNZCXP kr0/lU/6xrMkvCElEbkqsIMuzVloqUUUY20HSo4M++p33fOZienV/HAXo5fCxzIFFn e0M10UQNWj2qpu7hHsV2ThC+xrk1HGbUlUoNv8AlfvSQmwgmgHwn/3xisSU56IljSC HBSyHrX2FcmI5cZK5apoENZ3r2x3BBo7hqc+1cVx+de8XzC6B6s9J3R/Dl3Sof9E70 zcphrpmVtNJpg== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=qceLxy8Y Subject: [Intel-wired-lan] [PATCH AUTOSEL 5.10 13/39] igb: Do not free q_vector unless new one was allocated X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Kees Cook , intel-wired-lan@lists.osuosl.org, Jesse Brandeburg , "Michael J . Ruhl" , Eric Dumazet , Tony Nguyen , netdev@vger.kernel.org, Jakub Kicinski , Paolo Abeni , "David S. Miller" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Kees Cook [ Upstream commit 0668716506ca66f90d395f36ccdaebc3e0e84801 ] Avoid potential use-after-free condition under memory pressure. If the kzalloc() fails, q_vector will be freed but left in the original adapter->q_vector[v_idx] array position. Cc: Jesse Brandeburg Cc: Tony Nguyen Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Michael J. Ruhl Reviewed-by: Jacob Keller Tested-by: Gurucharan (A Contingent worker at Intel) Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/igb/igb_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 327196d15a6a..eed8274f5f79 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -1204,8 +1204,12 @@ static int igb_alloc_q_vector(struct igb_adapter *adapter, if (!q_vector) { q_vector = kzalloc(size, GFP_KERNEL); } else if (size > ksize(q_vector)) { - kfree_rcu(q_vector, rcu); - q_vector = kzalloc(size, GFP_KERNEL); + struct igb_q_vector *new_q_vector; + + new_q_vector = kzalloc(size, GFP_KERNEL); + if (new_q_vector) + kfree_rcu(q_vector, rcu); + q_vector = new_q_vector; } else { memset(q_vector, 0, size); } -- 2.35.1 _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan