[CBR 7.9] net/sched: Retire tcindex classifier #411
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[CBR 7.9]
CVE-2023-1829
VULN-7630
Problem
https://nvd.nist.gov/vuln/detail/CVE-2023-1829
The commit 8c710f7 recommended to upgrade past simply removes the
tcindex
traffic control filter.Applicability: yes
The
tcindex
filter is enabled inconfigs/kernel-3.10.0-x86_64.config
The CVE doesn't follow the typical bug-patch scheme, with the 8c710f7 fix not indicating any "fixes" commit. The brief, official bug description
along with the third party analysis https://starlabs.sg/blog/2023/06-breaking-the-code-exploiting-and-examining-cve-2023-1829-in-cls_tcindex-classifier-vulnerability/#vulnerability-analysis was used to assess the applicability.
Out of four functions playing their part in creating the use-after-free scenario mentioned in the article -
tcindex_delete
,tcindex_destroy_rexts_work
,__tcindex_destroy_rexts
,tcf_exts_destroy
- two differ slightly in the CBR 7.9 version:__tcindex_destroy_rexts
Star Lab analysis:
CBR 7.9:
kernel-src-tree/net/sched/cls_tcindex.c
Lines 140 to 144 in 3067830
tcf_exts_destroy
Star Lab analysis:
CBR 7.9:
kernel-src-tree/net/sched/cls_api.c
Lines 1592 to 1603 in 3067830
However, the execution path leading to the error remains in place. Following Star Lab analysis
The
tcindex_delete
function is exactly the same inciqcbr7_9
, so this part applies directly. (The last "imperfect" was probably a typo, asf
is never set in the case of perfect hashes, which are also the subject of the bug.)Despite
__tcindex_destroy_rexts
andtcf_exts_destroy
being different, the problematictcindex_destroy_rexts_work
→__tcindex_destroy_rexts
→tcf_exts_destroy
→kfree
call chain remains in place.Based on this, and on the bug replication given later in this PR, it was assessed that CVE-2023-1829 applies to CBR 7.9.
Solution
It was chosen to follow the upstream policy and "fix" this bug by removing the
cls_tcindex
module as it's done in 8c710f7. This solution was also used by Debian (https://lists.debian.org/debian-lts-announce/2023/05/msg00005.html):Some changes relative to the upstream 8c710f7 were introduced:
ciqcbr7_9
:include/net/tc_wrapper.h
as this file was introduced much later, in v6.2, and has no predecessor inciqcbr7_9
.tools/testing/selftests/tc-testing/tc-tests/filters/tcindex.json
as this file is part oftc
testing whichciqcbr7_9
lack entirely.CONFIG_NET_CLS_TCINDEX
options from the files inconfigs/*
- kernel.org doesn't keep config files under version control, unlike CIQ.kABI check: passed
Boot test: passed
boot-test.log
Kselftests: passed relative
Reference
kselftests–ciqcbr7_9–run1.log
kselftests–ciqcbr7_9–run2.log
kselftests–ciqcbr7_9–run3.log
Patch
kselftests–ciqcbr7_9-CVE-2023-1829–run1.log
kselftests–ciqcbr7_9-CVE-2023-1829–run2.log
kselftests–ciqcbr7_9-CVE-2023-1829–run3.log
Comparison
The results were compared manually with Meld. No changes indicative of some newly introduced malfunctions were found.
Specific tests: passed
Bug replication (reference)
A simple bash script to replicate the CVE-2023-1829 bug can be found at https://mpdesouza.com/blog/five-commands-to-crash-the-kernel/:
The bug trigger isn't deterministic and the
for
loop is simply to increase the likelihood of a crash.The author of the script reports the following output on his system:
This kind of ouput requires KASAN (Kernel Address Sanitizer) to be enabled. Unfortunately, it was introduced in version 4.18 and is unavailable in CBR 7.9 (v 3.18).
The bug, of course, would occur regardless of KASAN enabled or not, it just may not be so easily triggered and so clearly reported. Instead of explicit "use-after-free" messages some memory-adjacent, but otherwise seemingly unrelated, kernel crashes are expected to occur when using-after-free didn't get away with it and caused some actual issues. This is exactly what was observed when running the script multiple times.
Example 1:
Example 2:
Patch
As expected, the bug-replicating script doesn't even run on the patched kernel:
The
cls_tcindex
module is missing: