OSDN Git Service

netfilter: nf_tables: avoid skb access on nf_stolen
authorFlorian Westphal <fw@strlen.de>
Wed, 22 Jun 2022 14:43:57 +0000 (16:43 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 27 Jun 2022 17:22:54 +0000 (19:22 +0200)
commite34b9ed96ce3b06c79bf884009b16961ca478f87
tree24f0f95c0c661f65112d97d7d77c3ccf709f1408
parent05907f10e235680cc7fb196810e4ad3215d5e648
netfilter: nf_tables: avoid skb access on nf_stolen

When verdict is NF_STOLEN, the skb might have been freed.

When tracing is enabled, this can result in a use-after-free:
1. access to skb->nf_trace
2. access to skb->mark
3. computation of trace id
4. dump of packet payload

To avoid 1, keep a cached copy of skb->nf_trace in the
trace state struct.
Refresh this copy whenever verdict is != STOLEN.

Avoid 2 by skipping skb->mark access if verdict is STOLEN.

3 is avoided by precomputing the trace id.

Only dump the packet when verdict is not "STOLEN".

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_core.c
net/netfilter/nf_tables_trace.c