Skip to contentSkip to conversation

CVE-2026-31516: xfrm: prevent policy_hthresh.work from racing with netns teardown

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Apr 22

lore
Share & tools
lore
#0 lore raw

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

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

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

xfrm: prevent policy_hthresh.work from racing with netns teardown

A XFRM_MSG_NEWSPDINFO request can queue the per-net work item policy_hthresh.work onto the system workqueue.

The queued callback, xfrm_hash_rebuild(), retrieves the enclosing struct net via container_of(). If the net namespace is torn down before that work runs, the associated struct net may already have been freed, and xfrm_hash_rebuild() may then dereference stale memory.

xfrm_policy_fini() already flushes policy_hash_work during teardown, but it does not synchronize policy_hthresh.work.

Synchronize policy_hthresh.work in xfrm_policy_fini() as well, so the queued work cannot outlive the net namespace teardown and access a freed struct net.

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

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

	Issue introduced in 3.18 with commit 880a6fab8f6ba5b5abe59ea68533202ddea1012c and fixed in 6.12.80 with commit 56ea2257b83ee29a543f158159e3d1abc1e3e4fe
	Issue introduced in 3.18 with commit 880a6fab8f6ba5b5abe59ea68533202ddea1012c and fixed in 6.18.21 with commit 8854e9367465d784046362698731c1111e3b39b8
	Issue introduced in 3.18 with commit 880a6fab8f6ba5b5abe59ea68533202ddea1012c and fixed in 6.19.11 with commit 4e2e77843fef473ef47e322d52436d8308582a96
	Issue introduced in 3.18 with commit 880a6fab8f6ba5b5abe59ea68533202ddea1012c and fixed in 7.0 with commit 29fe3a61bcdce398ee3955101c39f89c01a8a77e

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-31516

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:
net/xfrm/xfrm_policy.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/56ea2257b83ee29a543f158159e3d1abc1e3e4fe
	https://git.kernel.org/stable/c/8854e9367465d784046362698731c1111e3b39b8
	https://git.kernel.org/stable/c/4e2e77843fef473ef47e322d52436d8308582a96
	https://git.kernel.org/stable/c/29fe3a61bcdce398ee3955101c39f89c01a8a77e