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 398A7270569 for ; Sat, 4 Oct 2025 15:18:51 +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=1759591132; cv=none; b=V46P3nyWaCGaw6L4uRYwWt6kkBfSCoTMvinpT9gwC3n5N+3rlrXQW0GF4Gemgn4MYXcRsMsw+H9aOYSlKWkHcgF5ucc6tSBKEHf9ASDTlJDEqOCLC8S/ymZdM9mPEdn5ILC4rANGDHMOhg5NbHRLIdpNkUSv3JfFWWeQC1cZX3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759591132; c=relaxed/simple; bh=/i3TLfgMnZb7vYn62w88bcQFKYrdR0FNsnoqC2YYa54=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kYLn6MUIp9aVQtnqdrm5Tw7GcFb66Kkbcau6Cc7W9NB39jNE1qMqx/tk3WwoMzOVNls7rW3BxPXQnyMxoBiIFOR1D2Gs42H5p4wqNOyfw7MnNFD55nv/e82qudpUn1HBgxsQX3hAXaF2kR4DqhRmEtGVpWiV/1J+0Jl7TiyexIo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CHtYaTrV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="CHtYaTrV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55270C4CEF9; Sat, 4 Oct 2025 15:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759591131; bh=/i3TLfgMnZb7vYn62w88bcQFKYrdR0FNsnoqC2YYa54=; h=From:To:Cc:Subject:Date:Reply-to:From; b=CHtYaTrV95jQS3UoQdWmUVh7OL0vS1D1IuaDshWk0RQ8mSUwxs95SqJ6DyzMxTG+M E4PWHNQDjr6krFOJX3L9zMeCBAq6fHOVpjDxwQmeKyXiUVf6Bvq8pDNZAtNonAboPi Efy47bDxzi0I5f2BZ4sGnl3AX8ahe0Wp9w7elZYw= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50483: net: enetc: avoid buffer leaks on xdp_do_redirect() failure Date: Sat, 4 Oct 2025 17:16:42 +0200 Message-ID: <2025100440-CVE-2022-50483-b6b2@gregkh> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=5555; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=2j/IpxDyU8LQLVFoB/ApxQkc2a4Df5qgW6BWFNT+V1w=; b=owGbwMvMwCRo6H6F97bub03G02pJDBkPrSLeqB9h2HPkCF/fjYJNU/Y+XZY+k8OZXzyBQ1due 4NUNMv8jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjI0i8M82yMWPNUqrfuKepm i1kTXH6/P3KiL8M8nR/zp19YKskm9vxv9cPeqqUnhfjyAQ== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: net: enetc: avoid buffer leaks on xdp_do_redirect() failure Before enetc_clean_rx_ring_xdp() calls xdp_do_redirect(), each software BD in the RX ring between index orig_i and i can have one of 2 refcount values on its page. We are the owner of the current buffer that is being processed, so the refcount will be at least 1. If the current owner of the buffer at the diametrically opposed index in the RX ring (i.o.w, the other half of this page) has not yet called kfree(), this page's refcount could even be 2. enetc_page_reusable() in enetc_flip_rx_buff() tests for the page refcount against 1, and [ if it's 2 ] does not attempt to reuse it. But if enetc_flip_rx_buff() is put after the xdp_do_redirect() call, the page refcount can have one of 3 values. It can also be 0, if there is no owner of the other page half, and xdp_do_redirect() for this buffer ran so far that it triggered a flush of the devmap/cpumap bulk queue, and the consumers of those bulk queues also freed the buffer, all by the time xdp_do_redirect() returns the execution back to enetc. This is the reason why enetc_flip_rx_buff() is called before xdp_do_redirect(), but there is a big flaw with that reasoning: enetc_flip_rx_buff() will set rx_swbd->page = NULL on both sides of the enetc_page_reusable() branch, and if xdp_do_redirect() returns an error, we call enetc_xdp_free(), which does not deal gracefully with that. In fact, what happens is quite special. The page refcounts start as 1. enetc_flip_rx_buff() figures they're reusable, transfers these rx_swbd->page pointers to a different rx_swbd in enetc_reuse_page(), and bumps the refcount to 2. When xdp_do_redirect() later returns an error, we call the no-op enetc_xdp_free(), but we still haven't lost the reference to that page. A copy of it is still at rx_ring->next_to_alloc, but that has refcount 2 (and there are no concurrent owners of it in flight, to drop the refcount). What really kills the system is when we'll flip the rx_swbd->page the second time around. With an updated refcount of 2, the page will not be reusable and we'll really leak it. Then enetc_new_page() will have to allocate more pages, which will then eventually leak again on further errors from xdp_do_redirect(). The problem, summarized, is that we zeroize rx_swbd->page before we're completely done with it, and this makes it impossible for the error path to do something with it. Since the packet is potentially multi-buffer and therefore the rx_swbd->page is potentially an array, manual passing of the old pointers between enetc_flip_rx_buff() and enetc_xdp_free() is a bit difficult. For the sake of going with a simple solution, we accept the possibility of racing with xdp_do_redirect(), and we move the flip procedure to execute only on the redirect success path. By racing, I mean that the page may be deemed as not reusable by enetc (having a refcount of 0), but there will be no leak in that case, either. Once we accept that, we have something better to do with buffers on XDP_REDIRECT failure. Since we haven't performed half-page flipping yet, we won't, either (and this way, we can avoid enetc_xdp_free() completely, which gives the entire page to the slab allocator). Instead, we'll call enetc_xdp_drop(), which will recycle this half of the buffer back to the RX ring. The Linux kernel CVE team has assigned CVE-2022-50483 to this issue. Affected and fixed versions =========================== Issue introduced in 5.13 with commit 9d2b68cc108db2fdb35022ed2d88cfb305c441a6 and fixed in 5.15.86 with commit bcf2c1dc5358dcf7e34a68cdb6b0bbf967801efa Issue introduced in 5.13 with commit 9d2b68cc108db2fdb35022ed2d88cfb305c441a6 and fixed in 6.0.16 with commit 7fba523b51ccce5f7981f8a43ad84d664da68131 Issue introduced in 5.13 with commit 9d2b68cc108db2fdb35022ed2d88cfb305c441a6 and fixed in 6.1.2 with commit 306526331e7a37e714e11ab7c6d73eb004745224 Issue introduced in 5.13 with commit 9d2b68cc108db2fdb35022ed2d88cfb305c441a6 and fixed in 6.2 with commit 628050ec952d2e2e46ec9fb6aa07e41139e030c8 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2022-50483 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/net/ethernet/freescale/enetc/enetc.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/bcf2c1dc5358dcf7e34a68cdb6b0bbf967801efa https://git.kernel.org/stable/c/7fba523b51ccce5f7981f8a43ad84d664da68131 https://git.kernel.org/stable/c/306526331e7a37e714e11ab7c6d73eb004745224 https://git.kernel.org/stable/c/628050ec952d2e2e46ec9fb6aa07e41139e030c8