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 6B92414A60A for ; Sat, 9 Nov 2024 10:18:29 +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=1731147509; cv=none; b=fZrShyDW+eFxuso365ECLsH8HeWgYMAUzx0AYhvBeLMYl65mAjdhuhq7uQGsQqMmVnLpRZhVY5Dx4uxXcTotmXxxJ/HDzp7NWdBKgxOekGyZ8L6vZxZp3LAe7ami+Yn1piIeygByI9FDghVBD/DAezdYlgYTBlTMj1x2isHp2Jc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731147509; c=relaxed/simple; bh=IkqwaLuDlwc8gtydd7mUCBHA4dzJOA2+N17hkgsb7FU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HGkV/9Hrs3Ug3Bc2HnPYz4ys3ziEm/Qc2pYDcMxh4osVoPBSxzZhXRrMVFpWSTwKjzaSJex8dOCqezHTOgpctS4elk+LZSvTY9rAwJvRHD1k5PepD3z6DIVM7h/MkHTanlzjrei4M8QmDgmvdH9SCoYMd+4Up38EpQ9nNxZa4Jo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QqcE7b7E; 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="QqcE7b7E" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DA21C4CECF; Sat, 9 Nov 2024 10:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1731147509; bh=IkqwaLuDlwc8gtydd7mUCBHA4dzJOA2+N17hkgsb7FU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=QqcE7b7EuDeGGXxJyqpjb2SgH/b74n5T8Rvp7W+PkhMuE4V+r5m3b3DpGKeu5oeRV 7NEvf4YununlR37prxoQYP9BiO7hfcsbBQSoZp7tl4fMk7bptmAm9huNmoe2Fv0qIq ROW15hWKvKL8lo3Vak+9aov6mApMXYofREonz6l0= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-50261: macsec: Fix use-after-free while sending the offloading packet Date: Sat, 9 Nov 2024 11:16:09 +0100 Message-ID: <2024110940-CVE-2024-50261-3a20@gregkh> X-Mailer: git-send-email 2.47.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=4565; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=IkqwaLuDlwc8gtydd7mUCBHA4dzJOA2+N17hkgsb7FU=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn6Zj5bzj8ymZabXWgh83M9l8v+P0Uf9mbtrvt65pdYP xNvXIxERywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEzE0IRhnu091QPzrc+8aAn+ GxoovklLLHHtRYY53Ld5dCRP24esWq26Jj29MKD+6dk8AA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: macsec: Fix use-after-free while sending the offloading packet KASAN reports the following UAF. The metadata_dst, which is used to store the SCI value for macsec offload, is already freed by metadata_dst_free() in macsec_free_netdev(), while driver still use it for sending the packet. To fix this issue, dst_release() is used instead to release metadata_dst. So it is not freed instantly in macsec_free_netdev() if still referenced by skb. BUG: KASAN: slab-use-after-free in mlx5e_xmit+0x1e8f/0x4190 [mlx5_core] Read of size 2 at addr ffff88813e42e038 by task kworker/7:2/714 [...] Workqueue: mld mld_ifc_work Call Trace: dump_stack_lvl+0x51/0x60 print_report+0xc1/0x600 kasan_report+0xab/0xe0 mlx5e_xmit+0x1e8f/0x4190 [mlx5_core] dev_hard_start_xmit+0x120/0x530 sch_direct_xmit+0x149/0x11e0 __qdisc_run+0x3ad/0x1730 __dev_queue_xmit+0x1196/0x2ed0 vlan_dev_hard_start_xmit+0x32e/0x510 [8021q] dev_hard_start_xmit+0x120/0x530 __dev_queue_xmit+0x14a7/0x2ed0 macsec_start_xmit+0x13e9/0x2340 dev_hard_start_xmit+0x120/0x530 __dev_queue_xmit+0x14a7/0x2ed0 ip6_finish_output2+0x923/0x1a70 ip6_finish_output+0x2d7/0x970 ip6_output+0x1ce/0x3a0 NF_HOOK.constprop.0+0x15f/0x190 mld_sendpack+0x59a/0xbd0 mld_ifc_work+0x48a/0xa80 process_one_work+0x5aa/0xe50 worker_thread+0x79c/0x1290 kthread+0x28f/0x350 ret_from_fork+0x2d/0x70 ret_from_fork_asm+0x11/0x20 Allocated by task 3922: kasan_save_stack+0x20/0x40 kasan_save_track+0x10/0x30 __kasan_kmalloc+0x77/0x90 __kmalloc_noprof+0x188/0x400 metadata_dst_alloc+0x1f/0x4e0 macsec_newlink+0x914/0x1410 __rtnl_newlink+0xe08/0x15b0 rtnl_newlink+0x5f/0x90 rtnetlink_rcv_msg+0x667/0xa80 netlink_rcv_skb+0x12c/0x360 netlink_unicast+0x551/0x770 netlink_sendmsg+0x72d/0xbd0 __sock_sendmsg+0xc5/0x190 ____sys_sendmsg+0x52e/0x6a0 ___sys_sendmsg+0xeb/0x170 __sys_sendmsg+0xb5/0x140 do_syscall_64+0x4c/0x100 entry_SYSCALL_64_after_hwframe+0x4b/0x53 Freed by task 4011: kasan_save_stack+0x20/0x40 kasan_save_track+0x10/0x30 kasan_save_free_info+0x37/0x50 poison_slab_object+0x10c/0x190 __kasan_slab_free+0x11/0x30 kfree+0xe0/0x290 macsec_free_netdev+0x3f/0x140 netdev_run_todo+0x450/0xc70 rtnetlink_rcv_msg+0x66f/0xa80 netlink_rcv_skb+0x12c/0x360 netlink_unicast+0x551/0x770 netlink_sendmsg+0x72d/0xbd0 __sock_sendmsg+0xc5/0x190 ____sys_sendmsg+0x52e/0x6a0 ___sys_sendmsg+0xeb/0x170 __sys_sendmsg+0xb5/0x140 do_syscall_64+0x4c/0x100 entry_SYSCALL_64_after_hwframe+0x4b/0x53 The Linux kernel CVE team has assigned CVE-2024-50261 to this issue. Affected and fixed versions =========================== Issue introduced in 6.1 with commit 0a28bfd4971f and fixed in 6.1.116 with commit 872932cf75cf Issue introduced in 6.1 with commit 0a28bfd4971f and fixed in 6.6.60 with commit 9f5ae743dbe9 Issue introduced in 6.1 with commit 0a28bfd4971f and fixed in 6.11.7 with commit 4614640f1d5c Issue introduced in 6.1 with commit 0a28bfd4971f and fixed in 6.12-rc6 with commit f1e54d11b210 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-2024-50261 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/macsec.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/872932cf75cf859804370a265dd58118129386fa https://git.kernel.org/stable/c/9f5ae743dbe9a2458540a7d35fff0f990df025cf https://git.kernel.org/stable/c/4614640f1d5c93c22272117dc256e9940ccac8e8 https://git.kernel.org/stable/c/f1e54d11b210b53d418ff1476c6b58a2f434dfc0