Merge branch 'ppp-recursion'
authorDavid S. Miller <davem@davemloft.net>
Wed, 31 Aug 2016 21:33:09 +0000 (14:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 31 Aug 2016 21:33:09 +0000 (14:33 -0700)
commit127661a47915f7b4c46586d02d771c5ee9a803bb
tree6defcfe2dc7552fa5a45072339b1e81c851a5ce0
parentce0b15d1103102b78ad95739fa71e62fb16774bd
parent077127705acf80cdb9393b891d934509a7081d71
Merge branch 'ppp-recursion'

Guillaume Nault says:

====================
ppp: fix deadlock upon recursive xmit

This series fixes the issue reported by Feng where packets looping
through a ppp device makes the module deadlock:
https://marc.info/?l=linux-netdev&m=147134567319038&w=2

The problem can occur on virtual interfaces (e.g. PPP over L2TP, or
PPPoE on vxlan devices), when a PPP packet is routed back to the PPP
interface.

PPP's xmit path isn't reentrant, so patch #1 uses a per-cpu variable
to detect and break recursion. Patch #2 sets the NETIF_F_LLTX flag to
avoid lock inversion issues between ppp and txqueue locks.

There are multiple entry points to the PPP xmit path. This series has
been tested with lockdep and should address recursion issues no matter
how the packet entered the path.

A similar issue in L2TP is not covered by this series:
l2tp_xmit_skb() also isn't reentrant, and it can be called as part of
PPP's xmit path (pppol2tp_xmit()), or directly from the L2TP socket
(l2tp_ppp_sendmsg()). If a packet is sent by l2tp_ppp_sendmsg() and
routed to the parent PPP interface, then it's going to hit
l2tp_xmit_skb() again.

Breaking recursion as done in ppp_generic is not enough, because we'd
still have a lock inversion issue (locking in l2tp_xmit_skb() can
happen before or after locking in ppp_generic). The best approach would
be to use the ip_tunnel functions and remove the socket locking in
l2tp_xmit_skb(). But that'd be something for net-next.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>