Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2608640lqp; Mon, 25 Mar 2024 04:25:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUzgEKP07jKOegO4gue3qc5YN8JHe9tTv16z9VuUIgZAStBJbHxhyuPZnkKjYxaTvn9ezG8ZiqW1kUm5idNYYzKmXDK05ycJ3CUccoGbg== X-Google-Smtp-Source: AGHT+IFAleutZRH37DmlnpsW+JMU++Clvv4YlOHLRXScNHLg2k7OR6G9K8abJIFt24JhUrjzA10V X-Received: by 2002:a05:6870:d38c:b0:22a:1cd5:dd1 with SMTP id k12-20020a056870d38c00b0022a1cd50dd1mr5018126oag.9.1711365911670; Mon, 25 Mar 2024 04:25:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711365911; cv=pass; d=google.com; s=arc-20160816; b=ZIvJhAtO2G/pjHmfRAyWxn8WNTBC3ZSqA+C4t4WXvOxgbTkNUL8v86BbgME3kCXzDN 3jJem4i9dxHCOfpMt6Zhk3pO60rF81qWPRe7afWwdnpPM1b9TmVq/9EElmUaIGGHXVWd KnQhKvQ+DSd/QFZQhCXrilUSCTIWlvWlTjHmDMFnTyOXxnN1JUzQm3wVOcZewxsLc4Zp UKDwJ6lWlyCbHmSK7NLpOmBZLM7mtd2o7Cirbs4qvc8NLqvvAL2/dVLdqiObPAarSzLK aMpVlSSmNhkQfLLqk7FAakzXJtkWC10Wa/akUdIV3mP9atBrqQRkdXojiO3zOnw0BXyA K9rw== 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=Xe43OMYdDY4IYzXKiH/IK4gdm0Kw4zNqGm5YwziHjFs=; fh=C39YxOUu0MEt+A4ogj3RoXCugNP49SYe90aljUE3UQs=; b=XTQiVdwLsUTyYo14oLlyrMe+D2zHc1nZAe0dL3ZzbCOi9KEVTwAEp3X635Rpp29emT l8j0E0G7QCVY1Yc750zwiTkU6paP5aoWFZVZEMzNLh5ZxnZ26KVB0PZYvZ7DrFYzJ43X bHVUjg9J0aiHV6TY058kpKfYPYAdnbThYEmm59u+3Pe7jkl66I81MxILoH1muwI9tOir nXke9vjhVDs6kAfQQjNTYWNOsqLAX+sg1+ezcPkAg2pzJkscZ1blFKCXFA8Pnz+fECkv f2lMSsCe1pAM/uFSZrPOwUBsWmfqOyd3RgO7VDyIVxDEbf9Ks2EQo89YV6QPjMZ7vO2q ck9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l4c7SHC5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116013-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116013-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n33-20020a634d61000000b005dcc8a3fdc5si7355356pgl.485.2024.03.25.04.25.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:25:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116013-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l4c7SHC5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116013-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116013-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id E10FEB41F43 for ; Mon, 25 Mar 2024 10:01:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0656217C1BF; Mon, 25 Mar 2024 03:26:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l4c7SHC5" 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 0112B219521; Sun, 24 Mar 2024 23:35:45 +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=1711323346; cv=none; b=trI5K1Cp4UFdfW2OX9s28hLUAhVBPF0A2fEtTZlhr7zzSJczneJTVT3yv32LOo02JXz6sZsdSI4QMItl9eHwORlU3wNoaEmUHOpXewH0q72MQZoFj1EdHetzmxbzcmiqPn3wHsvIJWzj0M5iKuichaXsL0QnTo72mCJdUyZtZWI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323346; c=relaxed/simple; bh=tR+/pQgPNGlMpnpUddcw+FzraRN/IlRHOrQOqXly7Sk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HTUcp+5MS1J9tEsAelIHspZVjcJngGbyA7QCeTzNyK71t66zhJsIf5+GONk9y+/FUONHZKltH+hoMWGIA8vdXUko/MN7vlYN5Mp3pfe+ADVpyrZZ1k0du9Y3BHPIs++ex1BquY2QyR+WxHnKs4o0NynEX7n4hWfOGWXARqhlRmA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l4c7SHC5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2BE7C433C7; Sun, 24 Mar 2024 23:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323345; bh=tR+/pQgPNGlMpnpUddcw+FzraRN/IlRHOrQOqXly7Sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4c7SHC5XyYU7AGsVjZJHuLjUjVfW8huSzBMg4NM3QGPeF/sEo3T9UwGLItubwT4p 3TTSGU+lXq/woEuRcF0O0zg0+BVyKxYNIHjxkahfBHtvK3vhqLkrWL56P4z7mZOfnj iaREIn3R3bXPN1SJVeUro2IgBkUFOpct9fBRxAytadabkx+75Njtv1lEoZo6ZmWJ/f vamW9eAboujTU3goS3ctjanRgir+ozTxoJ/R96kwDRpfRkD2/7k0wIB0SNr91QlSQd zFtN/B6tcpEiBsY2o02GssG3X/X9DOVXgbe90L2iDbO2M4cBQ9Ms+n2DySn6bbN/6F djGO6e4e6O5aQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chun-Yi Lee , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 045/317] aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts Date: Sun, 24 Mar 2024 19:30:25 -0400 Message-ID: <20240324233458.1352854-46-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324233458.1352854-1-sashal@kernel.org> References: <20240324233458.1352854-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 588889bea7c30..a6e5306f725b3 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c @@ -420,13 +420,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; @@ -441,9 +444,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