netfilter: nft_socket: only do sk lookups when indev is available
authorFlorian Westphal <fw@strlen.de>
Thu, 28 Apr 2022 07:39:21 +0000 (09:39 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 28 Apr 2022 14:15:23 +0000 (16:15 +0200)
commit743b83f15d4069ea57c3e40996bf4a1077e0cdc1
tree9c5101d16e4a843aa728f348667bfe3a13c495cf
parent626873c446f7559d5af8b48cefad903ffd85cf4e
netfilter: nft_socket: only do sk lookups when indev is available

Check if the incoming interface is available and NFT_BREAK
in case neither skb->sk nor input device are set.

Because nf_sk_lookup_slow*() assume packet headers are in the
'in' direction, use in postrouting is not going to yield a meaningful
result.  Same is true for the forward chain, so restrict the use
to prerouting, input and output.

Use in output work if a socket is already attached to the skb.

Fixes: 554ced0a6e29 ("netfilter: nf_tables: add support for native socket matching")
Reported-and-tested-by: Topi Miettinen <toiwoton@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_socket.c