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 128921E0DD5 for ; Mon, 21 Oct 2024 20:11:33 +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=1729541493; cv=none; b=qmbjSqvX0LdrgHovnaHbec88htw2wStOAsepUDxsswrB9vL8r3VPUKGQzFgSTv33a+EqKF+ppw56jq9/Myum0xBnV0UhRxhRqgEgLoKmCqSVhNxsWkWQo/pTR/2kdl6LIMpMqw5cQSbZ2CiydkDZl8lLGs40sVJSdl0jJkWzgNU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729541493; c=relaxed/simple; bh=3CYA7HK6mXOIWAjj1ttNkg7ZLVqTa3vxLmVAvc7ELIo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dygfP5ggSn3dRIup8GEmmP+jRTBRI+iX5H3ARhQiC31Gpa1zLmxGsx7995MsZR/HAUfTT2ULvgRirucNYzEKNwkB46rRAjFnOkvh3wLWGlUW3U9VrejCedpIxVq/Gv2dCKii8198Sf6GN9/jXMZ6QhH5HVqdguijkWJRLjJd8ho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=02lXwxGV; 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="02lXwxGV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 882AAC4CEC3; Mon, 21 Oct 2024 20:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729541492; bh=3CYA7HK6mXOIWAjj1ttNkg7ZLVqTa3vxLmVAvc7ELIo=; h=From:To:Cc:Subject:Date:Reply-to:From; b=02lXwxGVgrH7x/9T1jBDOZEa5yr3hcCHdRQeIJM9fAWbcI35MnOUK/x6o9218ZsKo 9XIeQRfN99g8Erpn0Dl6oYz+lvjLH9WRD8KZyoIOTAmc7FDmZuI/434iL6MJ7AVSFg R4bJ7zVtW3g89SmRAbZxkOrZCUcSb82bFHqoy6wg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-48980: net: dsa: sja1105: avoid out of bounds access in sja1105_init_l2_policing() Date: Mon, 21 Oct 2024 22:06:12 +0200 Message-ID: <2024102146-CVE-2022-48980-0fec@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=4040; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=3CYA7HK6mXOIWAjj1ttNkg7ZLVqTa3vxLmVAvc7ELIo=; b=owGbwMvMwCRo6H6F97bub03G02pJDOliW6S2NOa48SxxtvC0vSZSmenaNufq9DuFQraaSZMZ6 usi++o6YlkYBJkYZMUUWb5s4zm6v+KQopeh7WmYOaxMIEMYuDgFYCI3+BgWLGmdb1Zs235Y6KFb UbVK9eu9fm5xDAsO5Kjqnhde+IHz0KwHt0wEAnsstSYBAA== 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: net: dsa: sja1105: avoid out of bounds access in sja1105_init_l2_policing() The SJA1105 family has 45 L2 policing table entries (SJA1105_MAX_L2_POLICING_COUNT) and SJA1110 has 110 (SJA1110_MAX_L2_POLICING_COUNT). Keeping the table structure but accounting for the difference in port count (5 in SJA1105 vs 10 in SJA1110) does not fully explain the difference. Rather, the SJA1110 also has L2 ingress policers for multicast traffic. If a packet is classified as multicast, it will be processed by the policer index 99 + SRCPORT. The sja1105_init_l2_policing() function initializes all L2 policers such that they don't interfere with normal packet reception by default. To have a common code between SJA1105 and SJA1110, the index of the multicast policer for the port is calculated because it's an index that is out of bounds for SJA1105 but in bounds for SJA1110, and a bounds check is performed. The code fails to do the proper thing when determining what to do with the multicast policer of port 0 on SJA1105 (ds->num_ports = 5). The "mcast" index will be equal to 45, which is also equal to table->ops->max_entry_count (SJA1105_MAX_L2_POLICING_COUNT). So it passes through the check. But at the same time, SJA1105 doesn't have multicast policers. So the code programs the SHARINDX field of an out-of-bounds element in the L2 Policing table of the static config. The comparison between index 45 and 45 entries should have determined the code to not access this policer index on SJA1105, since its memory wasn't even allocated. With enough bad luck, the out-of-bounds write could even overwrite other valid kernel data, but in this case, the issue was detected using KASAN. Kernel log: sja1105 spi5.0: Probed switch chip: SJA1105Q ================================================================== BUG: KASAN: slab-out-of-bounds in sja1105_setup+0x1cbc/0x2340 Write of size 8 at addr ffffff880bd57708 by task kworker/u8:0/8 ... Workqueue: events_unbound deferred_probe_work_func Call trace: ... sja1105_setup+0x1cbc/0x2340 dsa_register_switch+0x1284/0x18d0 sja1105_probe+0x748/0x840 ... Allocated by task 8: ... sja1105_setup+0x1bcc/0x2340 dsa_register_switch+0x1284/0x18d0 sja1105_probe+0x748/0x840 ... The Linux kernel CVE team has assigned CVE-2022-48980 to this issue. Affected and fixed versions =========================== Issue introduced in 5.14 with commit 38fbe91f2287 and fixed in 5.15.83 with commit 5e88c6f4aaa7 Issue introduced in 5.14 with commit 38fbe91f2287 and fixed in 6.0.13 with commit 147f3e3d8405 Issue introduced in 5.14 with commit 38fbe91f2287 and fixed in 6.1 with commit f8bac7f9fdb0 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-48980 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/dsa/sja1105/sja1105_main.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/5e88c6f4aaa70c542e59e5a9d2244bcc99cd245d https://git.kernel.org/stable/c/147f3e3d84054117ae6b9bf317ec4fda9f991192 https://git.kernel.org/stable/c/f8bac7f9fdb0017b32157957ffffd490f95faa07