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 32A3C225D7 for ; Wed, 19 Jun 2024 14:55:04 +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=1718808904; cv=none; b=RgfQaj+gp8f0NYsDzXVj5b9r4RTA2aO7QOXPBDikleJz1T4pXyWMAFq6FxEAk82V10bFtA8jB9oCpl2MUViBg3h83UPA3Knm/akNBLhcjSCSm/OIRVnwkbVYFVVaGxwOAybCte2joOgqQuRmDPF1CPCzI6RoaLMAvxRUs36KD6w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718808904; c=relaxed/simple; bh=X0Bp9+AijTXs09kwFMewtZMf9AxaYDhO25OmZrrApng=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uzpFA9/imP9ffeupvbNVk8vvizRoO8xGHMTbkqgTG7PGKeZNLWX1Pd+T9XA7Gz/VPNdBUg1iNSH6/muc0+Oex8kyppFo29MXS0gGDfXEqUkMdTvWSKTToSC09dWwoBbyJQiVooF+s5ZDXw73uL8KzXHMjAxxUhx7U5wdU37MdF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ytifwa/x; 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="ytifwa/x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACD84C2BBFC; Wed, 19 Jun 2024 14:55:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718808904; bh=X0Bp9+AijTXs09kwFMewtZMf9AxaYDhO25OmZrrApng=; h=From:To:Cc:Subject:Date:Reply-to:From; b=ytifwa/x/2HMMAm6mouJydM/5bS71pFF05ONh4RdQxhWMA6pq5eCh4CSHJoxFD3Vt FCYq7SUZpk4lh+YlXeOiUGYG9mlxFRt6ekQvPwqw6uJlVyKk3pBcxnMjPInn8jyqC3 YdT4dDaqHVlb1+sngU12lJeHFGCGsf9+LNACLihI= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47592: net: stmmac: fix tc flower deletion for VLAN priority Rx steering Date: Wed, 19 Jun 2024 16:54:31 +0200 Message-ID: <2024061919-CVE-2021-47592-7ca6@gregkh> X-Mailer: git-send-email 2.45.2 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=3910; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=X0Bp9+AijTXs09kwFMewtZMf9AxaYDhO25OmZrrApng=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlFH6X/mOmdY/lwRqCK0TYtY1Oc36agTnWPpU1xixbzf m9/9DamI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACYS7sEwPyBvndRKv2gHnkXr tHh51k/OPVmwiWF+9HlOj+5nxj8T9ydVHOY2jvHY56sPAA== 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: stmmac: fix tc flower deletion for VLAN priority Rx steering To replicate the issue:- 1) Add 1 flower filter for VLAN Priority based frame steering:- $ IFDEVNAME=eth0 $ tc qdisc add dev $IFDEVNAME ingress $ tc qdisc add dev $IFDEVNAME root mqprio num_tc 8 \ map 0 1 2 3 4 5 6 7 0 0 0 0 0 0 0 0 \ queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 hw 0 $ tc filter add dev $IFDEVNAME parent ffff: protocol 802.1Q \ flower vlan_prio 0 hw_tc 0 2) Get the 'pref' id $ tc filter show dev $IFDEVNAME ingress 3) Delete a specific tc flower record (say pref 49151) $ tc filter del dev $IFDEVNAME parent ffff: pref 49151 >From dmesg, we will observe kernel NULL pointer ooops [ 197.170464] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 197.171367] #PF: supervisor read access in kernel mode [ 197.171367] #PF: error_code(0x0000) - not-present page [ 197.171367] PGD 0 P4D 0 [ 197.171367] Oops: 0000 [#1] PREEMPT SMP NOPTI [ 197.171367] RIP: 0010:tc_setup_cls+0x20b/0x4a0 [stmmac] [ 197.171367] Call Trace: [ 197.171367] [ 197.171367] ? __stmmac_disable_all_queues+0xa8/0xe0 [stmmac] [ 197.171367] stmmac_setup_tc_block_cb+0x70/0x110 [stmmac] [ 197.171367] tc_setup_cb_destroy+0xb3/0x180 [ 197.171367] fl_hw_destroy_filter+0x94/0xc0 [cls_flower] The above issue is due to previous incorrect implementation of tc_del_vlan_flow(), shown below, that uses flow_cls_offload_flow_rule() to get struct flow_rule *rule which is no longer valid for tc filter delete operation. struct flow_rule *rule = flow_cls_offload_flow_rule(cls); struct flow_dissector *dissector = rule->match.dissector; So, to ensure tc_del_vlan_flow() deletes the right VLAN cls record for earlier configured RX queue (configured by hw_tc) in tc_add_vlan_flow(), this patch introduces stmmac_rfs_entry as driver-side flow_cls_offload record for 'RX frame steering' tc flower, currently used for VLAN priority. The implementation has taken consideration for future extension to include other type RX frame steering such as EtherType based. v2: - Clean up overly extensive backtrace and rewrite git message to better explain the kernel NULL pointer issue. The Linux kernel CVE team has assigned CVE-2021-47592 to this issue. Affected and fixed versions =========================== Issue introduced in 5.13 with commit 0e039f5cf86c and fixed in 5.15.11 with commit 97cb5c82aa1d Issue introduced in 5.13 with commit 0e039f5cf86c and fixed in 5.16 with commit aeb7c75cb774 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-2021-47592 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/stmicro/stmmac/stmmac.h drivers/net/ethernet/stmicro/stmmac/stmmac_tc.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/97cb5c82aa1dd85a39b1bd021c8b5f18af623779 https://git.kernel.org/stable/c/aeb7c75cb77478fdbf821628e9c95c4baa9adc63