Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1710064

[PATCH 4.9 02/16] ppp: fix xmit recursion detection on ppp channels

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.9 02/16] ppp: fix xmit recursion detection on ppp channels
Date 2017-08-12 00:20 +0200
Message-ID <udqrG-Hs-63@gated-at.bofh.it> (permalink)
References <udqhX-E7-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guillaume Nault <g.nault@alphalink.fr>


[ Upstream commit 0a0e1a85c83775a648041be2b15de6d0a2f2b8eb ]

Commit e5dadc65f9e0 ("ppp: Fix false xmit recursion detect with two ppp
devices") dropped the xmit_recursion counter incrementation in
ppp_channel_push() and relied on ppp_xmit_process() for this task.
But __ppp_channel_push() can also send packets directly (using the
.start_xmit() channel callback), in which case the xmit_recursion
counter isn't incremented anymore. If such packets get routed back to
the parent ppp unit, ppp_xmit_process() won't notice the recursion and
will call ppp_channel_push() on the same channel, effectively creating
the deadlock situation that the xmit_recursion mechanism was supposed
to prevent.

This patch re-introduces the xmit_recursion counter incrementation in
ppp_channel_push(). Since the xmit_recursion variable is now part of
the parent ppp unit, incrementation is skipped if the channel doesn't
have any. This is fine because only packets routed through the parent
unit may enter the channel recursively.

Finally, we have to ensure that pch->ppp is not going to be modified
while executing ppp_channel_push(). Instead of taking this lock only
while calling ppp_xmit_process(), we now have to hold it for the full
ppp_channel_push() execution. This respects the ppp locks ordering
which requires locking ->upl before ->downl.

Fixes: e5dadc65f9e0 ("ppp: Fix false xmit recursion detect with two ppp devices")
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ppp/ppp_generic.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1914,21 +1914,23 @@ static void __ppp_channel_push(struct ch
 	spin_unlock_bh(&pch->downl);
 	/* see if there is anything from the attached unit to be sent */
 	if (skb_queue_empty(&pch->file.xq)) {
-		read_lock_bh(&pch->upl);
 		ppp = pch->ppp;
 		if (ppp)
-			ppp_xmit_process(ppp);
-		read_unlock_bh(&pch->upl);
+			__ppp_xmit_process(ppp);
 	}
 }
 
 static void ppp_channel_push(struct channel *pch)
 {
-	local_bh_disable();
-
-	__ppp_channel_push(pch);
-
-	local_bh_enable();
+	read_lock_bh(&pch->upl);
+	if (pch->ppp) {
+		(*this_cpu_ptr(pch->ppp->xmit_recursion))++;
+		__ppp_channel_push(pch);
+		(*this_cpu_ptr(pch->ppp->xmit_recursion))--;
+	} else {
+		__ppp_channel_push(pch);
+	}
+	read_unlock_bh(&pch->upl);
 }
 
 /*

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.9 00/16] 4.9.43-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:10 +0200
  [PATCH 4.9 07/16] net: sched: set xt_tgchk_param par.nft_compat as 0 in ipt_init_target Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:10 +0200
  [PATCH 4.9 13/16] revert "ipv4: Should use consistent conditional judgement for ip fragment in __ip_append_data and ip_finish_output" Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:10 +0200
  [PATCH 4.9 08/16] tcp: fastopen: tcp_connect() must refresh the route Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 16/16] KVM: arm/arm64: Handle hva aging while destroying the vm Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 11/16] packet: fix tp_reserve race in packet_set_ring Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 15/16] sparc64: Prevent perf from running during super critical sections Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 04/16] net: fix keepalive code vs TCP_FASTOPEN_CONNECT Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 12/16] revert "net: account for current skb length when deciding about UFO" Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 03/16] tcp: avoid setting cwnd to invalid ssthresh after cwnd reduction states Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 06/16] net/mlx4_en: dont set CHECKSUM_COMPLETE on SCTP packets Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 14/16] udp: consistently apply ufo or fragmentation Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 05/16] bpf, s390: fix jit branch offset related to ldimm64 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 10/16] igmp: Fix regression caused by igmp sysctl namespace code. Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 02/16] ppp: fix xmit recursion detection on ppp channels Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  [PATCH 4.9 01/16] ppp: Fix false xmit recursion detect with two ppp devices Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 00:20 +0200
  Re: [PATCH 4.9 00/16] 4.9.43-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-08-12 04:00 +0200
  Re: [PATCH 4.9 00/16] 4.9.43-stable review Guenter Roeck <linux@roeck-us.net> - 2017-08-12 14:40 +0200
    Re: [PATCH 4.9 00/16] 4.9.43-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-12 18:10 +0200
      Re: [PATCH 4.9 00/16] 4.9.43-stable review Guenter Roeck <linux@roeck-us.net> - 2017-08-12 18:30 +0200

csiph-web