[LTS 9.2] netdevsim: Fix memory leak of nsim_dev->fa_cookie #340
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.
[LTS 9.2]
CVE-2022-49803
VULN-65792
Problem
https://www.cve.org/CVERecord?id=CVE-2022-49803
Background
The
netdevsim
is a module simulating a network device in Linux. It's a developer testing tool that can be used to test various control path networking APIs.The memory leak described in CVE occurs after unloading the module, provided that some data was written through debugfs to the "flow action cookie" metadata storage associated with the simulated device.
This CVE appears to be one of the retroactive CVEs, filed for bugs which were fixed long before (fix commit 064bc73 date 2022-11-16 vs CVE publication date 2025-05-01).
Applicability
The
netdevsim
module is enabled by theCONFIG_NETDEVSIM
option which ism
in all configurations of LTS 9.2:The d3cbb90 commit identified in the fix commit 064bc73 as introducing the bug is present in
ciqlts9_2
history, literallyThe fix commit 064bc73 (1) is not present in the history and neither it's backported.
The bug's replication on
ciqlts9_2
confirms the applicability.Solution
As mentioned before, the mainline fix is in the 064bc73 commit. It applies with cherry-pick to
ciqlts9_2
without modifications.kABI check: passed
Boot test: passed
boot-test.log
Kselftests: passed relative
Coverage
All net-related tests (except the unstable ones):
net/forwarding
(exceptmirror_gre_bridge_1d_vlan.sh
,ipip_hier_gre_keys.sh
,sch_ets.sh
,sch_tbf_prio.sh
,sch_tbf_ets.sh
,q_in_vni.sh
,tc_police.sh
,mirror_gre_vlan_bridge_1q.sh
,dual_vxlan_bridge.sh
,tc_actions.sh
,sch_tbf_root.sh
,sch_red.sh
,vxlan_bridge_1d_ipv6.sh
),net/mptcp
(exceptsimult_flows.sh
,userspace_pm.sh
),net
(exceptgro.sh
,txtimestamp.sh
,xfrm_policy.sh
,udpgro_fwd.sh
,fib_nexthops.sh
,udpgso_bench.sh
,reuseport_addr_any.sh
,reuseaddr_conflict
,ip_defrag.sh
),netfilter
(exceptnft_trans_stress.sh
)Reference
kselftests–ciqlts9_2–run1.log
kselftests–ciqlts9_2–run2.log
kselftests–ciqlts9_2–run3.log
Patch
kselftests–ciqlts9_2-CVE-2022-49803–run1.log
kselftests–ciqlts9_2-CVE-2022-49803–run2.log
kselftests–ciqlts9_2-CVE-2022-49803–run3.log
Comparison
The results for the reference and patched kernel are the same.
Specific tests: passed
The bug replication steps are hinted in the fix commit 064bc73 message:
Reference
The bug was successfully replicated on
ciqlts9_2
compiled with theCONFIG_DEBUG_KMEMLEAK
option set. The steps:Load the
netdevsim
moduleCreate a new netdevsim device with index 0
Write "abc" encoded in hex to the flow action cookie
Remove the device
Unload the
netdevsim
moduleTrigger memory leaks scan
Check the leaks report
Patch
The same steps as done on the reference kernel produced no memory leak logs on the patched kernel.