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 7686AC4332F for ; Sun, 18 Dec 2022 16:03:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 009CA81415; Sun, 18 Dec 2022 16:03:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 009CA81415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1671379422; bh=60u53OM5Ckns2dNYmaXNZ1HH6yq3rsqHzU1vjlldyBs=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=9174az2TBNwlmR7oklveap3Hh8lVUmEMgG5kD8U7c7iu6M6ciIrAyMxnH0IA/TUMU YHBabwjqZh7WM5+odYgsgCnBTQUm4n4S2IELc5GzL8Wl3QBLakP7W2yVcv0ZgdTuaC Fs6k4/DJbA1RMJ7dOQbYcW8XHgDq8DMxBtRGfjIe82GTU3sxdpOyz2ja3LmRxzAcGb fgaoH6cq6cKJhuCir/P3SrTPC4d2BUIiNA9psgYLygI0KxWR+CAM6aL8ludcxdLCah eQDY2k/GNFaPSx/DDChTUfOimmAbpL+b3fvRuuc3gYQObwB7Gdlv3adQrUXhHi2FoH Y7cQM8mVy0r5A== 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 9cowu1vwxEwh; Sun, 18 Dec 2022 16:03:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id 1503B81418; Sun, 18 Dec 2022 16:03:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1503B81418 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id AFD0B1BF279 for ; Sun, 18 Dec 2022 16:03:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8509F408F4 for ; Sun, 18 Dec 2022 16:03:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8509F408F4 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Onsdj5D-tlm7 for ; Sun, 18 Dec 2022 16:03:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B41CD408BD Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by smtp4.osuosl.org (Postfix) with ESMTPS id B41CD408BD for ; Sun, 18 Dec 2022 16:03:38 +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 05CE660DC9; Sun, 18 Dec 2022 16:03:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C7D7C433F2; Sun, 18 Dec 2022 16:03:35 +0000 (UTC) From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Sun, 18 Dec 2022 11:00:47 -0500 Message-Id: <20221218160142.925394-30-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218160142.925394-1-sashal@kernel.org> References: <20221218160142.925394-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=1671379417; bh=OCBFqHeF2EByh+RikN1qAvcYV3x8f3DVPGaZCdxCnFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IF+6fz+ZBUJRAidmGKzvNLWi4QRvIx8dlAEJU8PLHY/lpyMOrEw9M7kOzspIC/fFL 6GVO7eoAhZDymMJwWPrtozJR2B1bcmr9sNuJ+TfWrwxtdSdf0RobjTkUw53eISf3SV xsFqT1J+JJl+ixH6QcxKeJ87OZ1nXNgkvTRJ8RJBHjRcHhGW1mXQo81U387AcPyl7O 574ed/+YLX2pdSHDKE/UdjTaY0j7whjhdUy6DzXtg5uBVk4vLjyd78cmXOoS9ZCD1m /c7JWkadYzbUvvjKeUZx5hfEzDI5UCE7x+ysoO+CO2L4Xuqbo4AEEakqEr09Z5OUt1 gN3QfvkyG5/SA== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=IF+6fz+Z Subject: [Intel-wired-lan] [PATCH AUTOSEL 6.1 30/85] 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 f8e32833226c..6256855d0f62 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -1202,8 +1202,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