Skip to contentSkip to conversation

CVE-2026-98015: net/mlx5: E-Switch: fix use-after-free in mlx5_eswitch_termtbl_put

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Sep 25

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

net/mlx5: E-Switch: fix use-after-free in mlx5_eswitch_termtbl_put

In mlx5_eswitch_termtbl_put(), the zero-ref cleanup check reads tt->ref_count after termtbl_mutex has been released. Two concurrent callers on the same mlx5_termtbl_handle race: one decrements ref_count to zero, removes the hash entry, and calls kfree(tt) while the other has already dropped the mutex and is about to evaluate
if (!tt->ref_count), producing a use-after-free.

Fix this by capturing the result of the decrement into a stack-local last variable before dropping the mutex. The cleanup decision is now made entirely under termtbl_mutex, and tt is not touched after kfree.

The Linux kernel CVE team has assigned CVE-2026-98015 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.3 with commit 10caabdaad5ace85577a453da97d1f8d3b944427 and fixed in 6.12.111 with commit 304ea40ef4561671503c36e47da44a0a31b71e36
	Issue introduced in 5.3 with commit 10caabdaad5ace85577a453da97d1f8d3b944427 and fixed in 6.18.53 with commit e393789e92310d7c66f57c876101779c90816a12
	Issue introduced in 5.3 with commit 10caabdaad5ace85577a453da97d1f8d3b944427 and fixed in 7.2.7 with commit 18b2969073879b9cce24e1a78b118bdad54518d1
	Issue introduced in 5.3 with commit 10caabdaad5ace85577a453da97d1f8d3b944427 and fixed in 7.3-rc3 with commit 7ee07f601f8f507c9faf25c68a49396ab8950596

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-2026-98015

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/mellanox/mlx5/core/eswitch_offloads_termtbl.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/304ea40ef4561671503c36e47da44a0a31b71e36
	https://git.kernel.org/stable/c/e393789e92310d7c66f57c876101779c90816a12
	https://git.kernel.org/stable/c/18b2969073879b9cce24e1a78b118bdad54518d1
	https://git.kernel.org/stable/c/7ee07f601f8f507c9faf25c68a49396ab8950596