Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2574783lqp; Mon, 25 Mar 2024 03:11:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXoiFxAiTjhrIVaDgxHdFXC/Q/YVd+hl3IOON8ispJLH84Hqw4G8m+S9UdKH1qm1tEnxyjcXdV5cL0n87J0hVDsPidykoQoGfVJGfjiIg== X-Google-Smtp-Source: AGHT+IGM8qITWh6wkjdvlzeT3oevfyu/EN027SoKmMT2ixmYqgqZVb2aiekeOHRv9dIv6+38S1m4 X-Received: by 2002:a05:6808:1811:b0:3c3:cd7a:af8 with SMTP id bh17-20020a056808181100b003c3cd7a0af8mr3558453oib.35.1711361464296; Mon, 25 Mar 2024 03:11:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361464; cv=pass; d=google.com; s=arc-20160816; b=XcQqrWP1JgNpcltghymeu1blFQDYbSYEVJa9XuGvueiRgVEnjo6GYMfC3zZN2hWnCB ZM3yk8benMJ8bOBoV80j1mJvDmtdoIQK4BeOcgtpCllV4HOVHsN9ZDwsYGAWHpZwX+Yl 1RjX4rLEuo8WZ5cQgZLsaHHgrwpxlvHIjRv3VZ8NYDQMqEjO5/1tmFNGq0w8rdd+O1ep nzwi/wNjrAa5inF3bLb5TDoahLCd29SKJL9M4pnF3r1dd60nxwYmEWILXuRjXC060jj0 0CXP9NVXDXaMpMIUpmXojVsp30GJ2myNtS36P0aaZN0292cx8kvj96+gkNt25sqZ3nLM iSBA== 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=pSMbrxs2rVGmNOpOB8DVgtiEMIJJXkyb72eCzPCMF08=; fh=C39YxOUu0MEt+A4ogj3RoXCugNP49SYe90aljUE3UQs=; b=td9kglGM+3FYNk4QYyBjpBB4BhxHtuVsPsj38uKVIYcflTB3UkINU0u/hjV9g8sk3S qKvom//TF8rL1caB/Gn5m5qb3OxBBUvU/1OipUL4yeBJGjC/6x7m1/tADIszXlC+IwYI Nm3OxPDNQQaHur2GjiZ+0FNolJzdsRkIo1CU+gogaOnD5g+s2gTA2feCOLkAhA0Q4aKi w6QprVI4PvJqS1Ybju+o9e76GgKEy1YRtSfZ4pA8nH8F54aRzpdbWq21ID4PvBUnsdkO x8rqiUgQ9i51VTvWXx4J7xY154exznTg2mxeGdSbIXzB2hkBxstwD6YIqqUBZxKQTvGd CZbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Mxc/sWAV"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116128-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116128-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 a10-20020ac85b8a000000b0043160b2903esi471780qta.129.2024.03.25.03.11.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:11:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116128-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="Mxc/sWAV"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116128-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116128-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 DCF401C3270D for ; Mon, 25 Mar 2024 10:11:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B84D23AD95E; Mon, 25 Mar 2024 03:32:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mxc/sWAV" 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 990A3179FC9; Sun, 24 Mar 2024 23:41:03 +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=1711323663; cv=none; b=c/5g6CqAwdFtohL8RriNfLBBF8rbNZzL4A+4ljZuQGB6prspdGe404WxNIJPZR/aCHfnY3bFeqxap4hF4HtxQES8YOors4hLIJnLfMxRDddLZtca7whKEnhBgexNOw5eLfcCghUhpcYuaoTdt3Ib6OI/Ws4i2GnGtZwWyTfWbx4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323663; c=relaxed/simple; bh=NIoDcRpVejFLNVUkjop1RAxTn/B6sQZnq+VQSlo84Rc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uY2Fx+nROLPxxF2B9GMAGwelCTtBb9kzERNCrfIqG2o8q8Q9mA/f/DQRZ4l62SuIZheFA+UVi3GNwycQEmG169jr4rrzEK2aCl21p6tyRavgIoPiSfgu5C4yN7NZaBISfwVaN1ipJf7qPA6S+Psfva90vgo8f95Ge9M2BBpFEyA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mxc/sWAV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8117C43399; Sun, 24 Mar 2024 23:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323663; bh=NIoDcRpVejFLNVUkjop1RAxTn/B6sQZnq+VQSlo84Rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mxc/sWAVUnF8ICSFAzeu4KxUprDCmKZ2w5qfCpacLT8th3soy/nGfID063tqqia9k BPFqEKEBL7kmCRC87qJOrhAQL3BDX5Q4c8qggHg4mfV/2KMHyQjL81xR1b02NDV5gV fHWraPspch7AteuVW6EyMd3H5jHrNdLPr57c9dlagfoOn/k8L1ghSvpEvgZK+O6HhB fGLhCCMRcoyCdzki/jJ2IEbY0EjZ6FU0Q74Qt/7i0FUbmRk1LElAw4dRD2UJi8PJyM bhzpw16yg8gseEOsmop5+sdfoEzVfeKChMap3deVb/xKGGJAZzXD/Q9JU35nkoTMVX 8+yX3Rktw1kgg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chun-Yi Lee , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 035/238] aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts Date: Sun, 24 Mar 2024 19:37:03 -0400 Message-ID: <20240324234027.1354210-36-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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 313f0b946fe2b..c805909c8e775 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