]> git.itanic.dy.fi Git - linux-stable/commit
net: sched: protect against stack overflow in TC act_mirred
authorJohn Hurley <john.hurley@netronome.com>
Mon, 24 Jun 2019 22:13:36 +0000 (23:13 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Jun 2019 21:36:25 +0000 (14:36 -0700)
commite2ca070f89ecd983bd98e05d936a678a4151f2fd
tree34edd6aff8120550564d0818bcc0cc5b26bc48f1
parent720f22fed81bc6fd1765db7014651b6718887bea
net: sched: protect against stack overflow in TC act_mirred

TC hooks allow the application of filters and actions to packets at both
ingress and egress of the network stack. It is possible, with poor
configuration, that this can produce loops whereby an ingress hook calls
a mirred egress action that has an egress hook that redirects back to
the first ingress etc. The TC core classifier protects against loops when
doing reclassifies but there is no protection against a packet looping
between multiple hooks and recursively calling act_mirred. This can lead
to stack overflow panics.

Add a per CPU counter to act_mirred that is incremented for each recursive
call of the action function when processing a packet. If a limit is passed
then the packet is dropped and CPU counter reset.

Note that this patch does not protect against loops in TC datapaths. Its
aim is to prevent stack overflow kernel panics that can be a consequence
of such loops.

Signed-off-by: John Hurley <john.hurley@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_mirred.c