Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2362931lqp; Sun, 24 Mar 2024 15:52:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzbmcgrCz7Jc5G4iM+uUqJmY4no6tJ9pma6Xv/3IggTj8WSLAPSNgeQx2ZK6SvW/iD7HBwfewncV01gHdD/Xk7NeerAOsQ/xsoV1CwLw== X-Google-Smtp-Source: AGHT+IF5Co1MQ4/F9vmdEKMrkTEla+H957crhwy91hh/9lMVsdFC383QVkZ4qWOVs3jXsFgx7qPf X-Received: by 2002:a50:cd9c:0:b0:566:d333:45e8 with SMTP id p28-20020a50cd9c000000b00566d33345e8mr4240689edi.20.1711320729199; Sun, 24 Mar 2024 15:52:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711320729; cv=pass; d=google.com; s=arc-20160816; b=0Lei+hly9zwEbkRAKwxKwsgDz2jPgSaOU5BA9M+NyNVFl5kKsaR7yoY0vSgGbg6S7o Z1ezOoL1O/kUGz0hfGah8HWCD16VIoIUPKD2Le6HcBM/OeiM0RDyXwk3g/ZJQGEYYupD H885ht21c9jsgxWtVhX1HGJ/1X+nJ6/cXuS62BvUP7UR7dRdYnzP02q4DrYW/elF/4zd Jlkzq3p+8nidDd8gv7gXPBHBX/bfdLMYG7IlclXF4sapoNwL8IE0kNhrWbitqPwKdXEK WyvWhAj1Cg99hvYuBEAWpstmigcU+cDM/ZOqTZbjuG3MyyHwJts7VWe34yFxqfTCQPU5 glvw== 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=CL0Fe0qjYJiTt/9K/277q9P5Ey7R5GBrqz1vNTL/QPE=; fh=C39YxOUu0MEt+A4ogj3RoXCugNP49SYe90aljUE3UQs=; b=ZlVD9wK5ct0PaFC7XCRTeGVGyNi50aITKdnHG1/KWrHm4iYdBepK25XXvDi5Bfl+ev 5bVq4WxrllG77sU72GHo7TQy4zAMeAQtD5SIOgDee3AGPXSnQ5dFgi8Jxs4M1EmQDXR+ q7ak4CGbpBYJsvCXa7ri38NMBQ9ZHu3LoCJZVk2xT9HioD8oToqLQDqkNqMaTLZd4H8X +7YflRG77YW27RpXu9uxYKzZVz+592AMfxbxyV6z2qx0DNziAzn//hjZLEHc5ffi4XYs Lh3E67hdsQ+00dL1GZnDGUc7pYYORM7LNo7okZuTX4aE8tHQICGMJVQFpK+LhzYfG5mS DF4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="j/z6kTz5"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cb26-20020a0564020b7a00b0056b9c4821c2si2011766edb.459.2024.03.24.15.52.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="j/z6kTz5"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112930-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E200E1F219E1 for ; Sun, 24 Mar 2024 22:45:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7FE3D47796; Sun, 24 Mar 2024 22:35:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j/z6kTz5" 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 8C7C574404; Sun, 24 Mar 2024 22:35:42 +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=1711319742; cv=none; b=oH3JdvshWA2p3ro8JYmJtHwVBmt0qNcslAclOaWMCNIOoISPtLZM94Knd4SqyKt4sr4X2Vq4x3/RULQ2gNfi4Fv7w3iAT6zubzhQWQuue61Y50nv66XrBfGncWA4Pni0+HDaS+9/CMeeOFmqtkd4Ebhsz2lsD05qknWeNOHxYaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319742; c=relaxed/simple; bh=oR6kvkBMYS2cpiqZLlshxpoI6c+KY4+ToxoVOXN4ufk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q3kzZNDLrnXbZEW4+LbgalCapGpDO2CvqueQak33FzPlkNBUcWFCmWXJXWh7w1TCce1UXI2qgQ18HALm1Pb05tN5AifC7toXeBWJcR30ogpz+RlRPFVM+h4/Nap4il0oebbCZZxZOrdGZONyXfS6V/qJ4qfIoN7mByBkAM1/StE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j/z6kTz5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7348AC433C7; Sun, 24 Mar 2024 22:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319742; bh=oR6kvkBMYS2cpiqZLlshxpoI6c+KY4+ToxoVOXN4ufk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j/z6kTz5ghy3C+diuJQ6bcKQhjnrp8VrTpk8MRu0sHUGWC3IiOMnj5EvA+Tk8Hss3 FeCjXMm6kIXIiINbpal3mD0z7NeI1vTDjZPhiNGHoOlfodVr51meSS3HTm28TcOaa2 KKH8kMopbUu28tPrO5f4hDr6/1zn3Ov6P7kMpM6KsPN9dn0IRFPYI63osoL/twVaTd P/jwkTVehkXujeHUfiH7JqoNrU9NAsmjI54qI19e+b/HFHQEXOhuweQhCd0P5yrCZg Q7ua51O1bptmMmyK6DJrFwwN4YxIrv+CZIN9iU3ILbtC9dOfJ93KFOTBJz5pBlhqBG 9FuOp3WprJ05Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chun-Yi Lee , Jens Axboe , Sasha Levin Subject: [PATCH 6.8 043/715] aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts Date: Sun, 24 Mar 2024 18:23:42 -0400 Message-ID: <20240324223455.1342824-44-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 c51ea95bc2ce4..923a134fd7665 100644 --- a/drivers/block/aoe/aoenet.c +++ b/drivers/block/aoe/aoenet.c @@ -63,6 +63,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