]> git.itanic.dy.fi Git - linux-stable/commit
net/sched: act_ipt: zero skb->cb before calling target
authorFlorian Westphal <fw@strlen.de>
Tue, 27 Jun 2023 12:38:13 +0000 (14:38 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 29 Jun 2023 10:10:37 +0000 (12:10 +0200)
commit93d75d475c5dc3404292976147d063ee4d808592
tree6422153615aedd6b04d7ed4b3e0345718a669afa
parentb2dc32dcba08bf55cec600caa76f4afd2e3614df
net/sched: act_ipt: zero skb->cb before calling target

xtables relies on skb being owned by ip stack, i.e. with ipv4
check in place skb->cb is supposed to be IPCB.

I don't see an immediate problem (REJECT target cannot be used anymore
now that PRE/POSTROUTING hook validation has been fixed), but better be
safe than sorry.

A much better patch would be to either mark act_ipt as
"depends on BROKEN" or remove it altogether. I plan to do this
for -next in the near future.

This tc extension is broken in the sense that tc lacks an
equivalent of NF_STOLEN verdict.

With NF_STOLEN, target function takes complete ownership of skb, caller
cannot dereference it anymore.

ACT_STOLEN cannot be used for this: it has a different meaning, caller
is allowed to dereference the skb.

At this time NF_STOLEN won't be returned by any targets as far as I can
see, but this may change in the future.

It might be possible to work around this via list of allowed
target extensions known to only return DROP or ACCEPT verdicts, but this
is error prone/fragile.

Existing selftest only validates xt_LOG and act_ipt is restricted
to ipv4 so I don't think this action is used widely.

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