]> git.itanic.dy.fi Git - linux-stable/commit
net/sched: act_ipt: add sanity checks on skb before calling target
authorFlorian Westphal <fw@strlen.de>
Tue, 27 Jun 2023 12:38:12 +0000 (14:38 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 29 Jun 2023 10:10:37 +0000 (12:10 +0200)
commitb2dc32dcba08bf55cec600caa76f4afd2e3614df
tree1129caad3cfbe540d33c1f4723182a63e612582c
parentb4ee93380b3c891fea996af8d1d3ca0e36ad31f0
net/sched: act_ipt: add sanity checks on skb before calling target

Netfilter targets make assumptions on the skb state, for example
iphdr is supposed to be in the linear area.

This is normally done by IP stack, but in act_ipt case no
such checks are made.

Some targets can even assume that skb_dst will be valid.
Make a minimum effort to check for this:

- Don't call the targets eval function for non-ipv4 skbs.
- Don't call the targets eval function for POSTROUTING
  emulation when the skb has no dst set.

v3: use skb_protocol helper (Davide Caratti)

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/sched/act_ipt.c