Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2556526lqp; Mon, 25 Mar 2024 02:29:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWOjn8vpCcuAlXeZeW+iuLWgZAHhevsTnNPAvqCMlsh5mE16uL0nRKygqACzVFXDQ/poqeCBCchr3BYT2IH2FEVCCNV29R+0dX7lV0t8Q== X-Google-Smtp-Source: AGHT+IGe7SgIkmf2ioH6BoJ9bL3F7UKCw1lzPFkknyn4TVU2muTGi4w597J3zeq2vjXBFz2nCqeO X-Received: by 2002:ac8:59ca:0:b0:431:4f1b:51c5 with SMTP id f10-20020ac859ca000000b004314f1b51c5mr4859306qtf.45.1711358975084; Mon, 25 Mar 2024 02:29:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711358975; cv=pass; d=google.com; s=arc-20160816; b=qrmJ7iHfTstRe1DreLGubuSHTB1frjrOK4w9JqyLb9h3Ic7yhF/R8G/ovOSTSdqAhs QZfm/lhOrtC01tXqZOf/HN+4qAvtevWUAe06WkK3Xzn6lQe+lgt8xURWQ1BndCybvWGu tnb15qe/4/Meed6HVr3m70+whdVKlSChRrszxm8lZ6kyhLli7zoem4c/ydI0tjXlyMMl drp0F8sWSuPtFRx4vp7DJkKTK/PKfj3zVkXXGVTesTX9QoLyOnI1m817wxhwcoiD3MHy R0MDxQcgZfX+WFIbkkLDIIAY4/xro1FBD21ts2qdHM8lVlabkytw3/I9uc0g5ZXJNiBw P7vw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xtFSBxK8dCy3xcVbX1S857Y9l8QeWjuV3K24FHjZCAo=; fh=C39YxOUu0MEt+A4ogj3RoXCugNP49SYe90aljUE3UQs=; b=YlB/0y/DQFv+DKWc6cqAolJRSoczHrsB5bevzMP8sHCTCF4fFIHUyGynai+gGNQCWb b4c26lrYGDD74Dv03am/HxoWTyKjeombvJk5LDPaiFA6B/satIZrrxMzleC3c/xwhP32 s4lZ6L+V9t/MEd6LYyMVDRTfHolUn1glVRY5qWGQTp3Hx7E62mXBFd/EyrIpoyKy+X1F IBtahdjnwMrHqauiEtlVC2U0vWYDqxsU25rmmcbxOzqSfwsza0gg5HZ2rCY0zm3QnaTG gkYTpNptmbH11WJb50n96AoU57BsMX/rM/ztPN+CVdkXj9m+bNq59NQxBDBR4gwPqCsB DFwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WwiYv+Ph; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115828-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115828-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o22-20020ac85a56000000b00431605e06b9si459524qta.285.2024.03.25.02.29.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:29:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115828-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WwiYv+Ph; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115828-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115828-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C96811C22027 for ; Mon, 25 Mar 2024 09:29:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 314BF378C51; Mon, 25 Mar 2024 03:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WwiYv+Ph" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80F59145357; Sun, 24 Mar 2024 23:13:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322003; cv=none; b=JbYAf+wI6V3svjy6alcXR7vsuRMsheeuqM37cMtEXyT/sdZzEkpQFklSqixMxSSJMxQlFjADyXaEL1Kv9gavRIG3YJymU7Ly1vuR4IR0FTWVpnO0IPm3qXyVUN2I2Kepq9FxbBjxm8kv2Yxlul1o4AJoguY1hj5rR/QyW0XYvHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322003; c=relaxed/simple; bh=MQ8BlB4JG1jjZwfj5Rva8ULNhjxYa7cmFF0KVqjjOCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T0MwoscRgmQqophvRjPm9oZUz4+MX3Iwy85ObRtKBQMMM+jMPYeq3z6ZPzYI7gwKMpgi9xpjy1i7GCKp2s7IzEkfpYC2Ghg1hasGUR6HnYsJ1EG64ejob19gZCRLHh4PQvP7wgn7YengEk9z8GWn5k4S1axmK2igq53pBX69W14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WwiYv+Ph; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2EB1C43399; Sun, 24 Mar 2024 23:13:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322003; bh=MQ8BlB4JG1jjZwfj5Rva8ULNhjxYa7cmFF0KVqjjOCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WwiYv+Phx1la0tp5hbhgALGo40PZ1f7GYzd8pj+nKBxEhCTHEe0FpBlgTV+Vyzy0E NlLq1vXlpu61iN5nbZSXebfE9IhOLKqMO3J76V2y/Yej6yKTap50WvOdsoGRTJNcdy 7NaOdClHkloyBnLfu79BsNhibEg+4P7Cs+GJJoHqUNd4UyQZVCdHXokRXhSEnZXoun a7s/aeToGvFKSSreV3iYQaPsagswveJgfn0mklXEe/HEXW7bBBUMBHFahdzdJ/n+71 7u9Prs4ktafOafN2Ji3mIZNw3SChoQXAJFlwSqzEnlSs7EyLx3siqgRs+7y9FP+OPE wWNsd5gP0D5xg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chun-Yi Lee , Jens Axboe , Sasha Levin Subject: [PATCH 6.1 075/451] aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts Date: Sun, 24 Mar 2024 19:05:51 -0400 Message-ID: <20240324231207.1351418-76-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Chun-Yi Lee [ Upstream commit f98364e926626c678fb4b9004b75cacf92ff0662 ] This patch is against CVE-2023-6270. The description of cve is: A flaw was found in the ATA over Ethernet (AoE) driver in the Linux kernel. The aoecmd_cfg_pkts() function improperly updates the refcnt on `struct net_device`, and a use-after-free can be triggered by racing between the free on the struct and the access through the `skbtxq` global queue. This could lead to a denial of service condition or potential code execution. In aoecmd_cfg_pkts(), it always calls dev_put(ifp) when skb initial code is finished. But the net_device ifp will still be used in later tx()->dev_queue_xmit() in kthread. Which means that the dev_put(ifp) should NOT be called in the success path of skb initial code in aoecmd_cfg_pkts(). Otherwise tx() may run into use-after-free because the net_device is freed. This patch removed the dev_put(ifp) in the success path in aoecmd_cfg_pkts(), and added dev_put() after skb xmit in tx(). Link: https://nvd.nist.gov/vuln/detail/CVE-2023-6270 Fixes: 7562f876cd93 ("[NET]: Rework dev_base via list_head (v3)") Signed-off-by: Chun-Yi Lee Link: https://lore.kernel.org/r/20240305082048.25526-1-jlee@suse.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/aoe/aoecmd.c | 12 ++++++------ drivers/block/aoe/aoenet.c | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index d7317425be510..cc9077b588d7e 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c @@ -419,13 +419,16 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu rcu_read_lock(); for_each_netdev_rcu(&init_net, ifp) { dev_hold(ifp); - if (!is_aoe_netif(ifp)) - goto cont; + if (!is_aoe_netif(ifp)) { + dev_put(ifp); + continue; + } skb = new_skb(sizeof *h + sizeof *ch); if (skb == NULL) { printk(KERN_INFO "aoe: skb alloc failure\n"); - goto cont; + dev_put(ifp); + continue; } skb_put(skb, sizeof *h + sizeof *ch); skb->dev = ifp; @@ -440,9 +443,6 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu h->major = cpu_to_be16(aoemajor); h->minor = aoeminor; h->cmd = AOECMD_CFG; - -cont: - dev_put(ifp); } rcu_read_unlock(); } diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c index 63773a90581dd..1e66c7a188a12 100644 --- a/drivers/block/aoe/aoenet.c +++ b/drivers/block/aoe/aoenet.c @@ -64,6 +64,7 @@ tx(int id) __must_hold(&txlock) pr_warn("aoe: packet could not be sent on %s. %s\n", ifp ? ifp->name : "netif", "consider increasing tx_queue_len"); + dev_put(ifp); spin_lock_irq(&txlock); } return 0; -- 2.43.0