Subject: CVE-2024-27397: netfilter: nf_tables: use timestamp to check for set element timeout

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

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

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

netfilter: nf_tables: use timestamp to check for set element timeout

Add a timestamp field at the beginning of the transaction, store it
in the nftables per-netns area.

Update set backend .insert, .deactivate and sync gc path to use the
timestamp, this avoids that an element expires while control plane
transaction is still unfinished.

.lookup and .update, which are used from packet path, still use the
current time to check if the element has expired. And .get path and dump
also since this runs lockless under rcu read size lock. Then, there is
async gc which also needs to check the current time since it runs
asynchronously from a workqueue.

The Linux kernel CVE team has assigned CVE-2024-27397 to this issue.

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

	Issue introduced in 4.1 with commit c3e1b005ed1c and fixed in 4.19.320 with commit f8dfda798650
	Issue introduced in 4.1 with commit c3e1b005ed1c and fixed in 5.4.282 with commit eaf1a29ea5d7
	Issue introduced in 4.1 with commit c3e1b005ed1c and fixed in 5.10.224 with commit 7b17de2a71e5
	Issue introduced in 4.1 with commit c3e1b005ed1c and fixed in 5.15.165 with commit 0d40e8cb1d1f
	Issue introduced in 4.1 with commit c3e1b005ed1c and fixed in 6.1.97 with commit b45176b86967
	Issue introduced in 4.1 with commit c3e1b005ed1c and fixed in 6.7.5 with commit 383182db8d58
	Issue introduced in 4.1 with commit c3e1b005ed1c and fixed in 6.8 with commit 7395dfacfff6

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-2024-27397
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:
	include/net/netfilter/nf_tables.h
	net/netfilter/nf_tables_api.c
	net/netfilter/nft_set_hash.c
	net/netfilter/nft_set_pipapo.c
	net/netfilter/nft_set_rbtree.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/f8dfda798650241c1692058713ca4fef8e429061
	https://git.kernel.org/stable/c/eaf1a29ea5d7dba8e84e9e9f3b3f47d0cd540bfe
	https://git.kernel.org/stable/c/7b17de2a71e56c10335b565cc7ad238e6d984379
	https://git.kernel.org/stable/c/0d40e8cb1d1f56a994cdd2e015af622fdca9ed4d
	https://git.kernel.org/stable/c/b45176b869673417ace338b87cf9cdb66e2eeb01
	https://git.kernel.org/stable/c/383182db8d58c4237772ba0764cded4938a235c3
	https://git.kernel.org/stable/c/7395dfacfff65e9938ac0889dafa1ab01e987d15