]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nft_inner: incorrect percpu area handling under softirq
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 27 Nov 2024 11:46:54 +0000 (12:46 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:03:07 +0000 (20:03 +0100)
commitda5cc778e7bf78fe525bc90ec2043f41415c31d9
tree952d22eb62a6e9974791ec08f73e440bb8d7a56d
parent992fd34122de377b45cb75b64fc7f17fc1e6ed2f
netfilter: nft_inner: incorrect percpu area handling under softirq

[ Upstream commit 7b1d83da254be3bf054965c8f3b1ad976f460ae5 ]

Softirq can interrupt ongoing packet from process context that is
walking over the percpu area that contains inner header offsets.

Disable bh and perform three checks before restoring the percpu inner
header offsets to validate that the percpu area is valid for this
skbuff:

1) If the NFT_PKTINFO_INNER_FULL flag is set on, then this skbuff
   has already been parsed before for inner header fetching to
   register.

2) Validate that the percpu area refers to this skbuff using the
   skbuff pointer as a cookie. If there is a cookie mismatch, then
   this skbuff needs to be parsed again.

3) Finally, validate if the percpu area refers to this tunnel type.

Only after these three checks the percpu area is restored to a on-stack
copy and bh is enabled again.

After inner header fetching, the on-stack copy is stored back to the
percpu area.

Fixes: 3a07327d10a0 ("netfilter: nft_inner: support for inner tunnel header matching")
Reported-by: syzbot+84d0441b9860f0d63285@syzkaller.appspotmail.com
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/netfilter/nf_tables_core.h
net/netfilter/nft_inner.c