Skip to content

Commit 0a0e1a8

Browse files
Guillaume Naultdavem330
authored andcommitted
ppp: fix xmit recursion detection on ppp channels
Commit e5dadc6 ("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: e5dadc6 ("ppp: Fix false xmit recursion detect with two ppp devices") Signed-off-by: Guillaume Nault <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 05bfd7d commit 0a0e1a8

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

drivers/net/ppp/ppp_generic.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,21 +1915,23 @@ static void __ppp_channel_push(struct channel *pch)
19151915
spin_unlock(&pch->downl);
19161916
/* see if there is anything from the attached unit to be sent */
19171917
if (skb_queue_empty(&pch->file.xq)) {
1918-
read_lock(&pch->upl);
19191918
ppp = pch->ppp;
19201919
if (ppp)
1921-
ppp_xmit_process(ppp);
1922-
read_unlock(&pch->upl);
1920+
__ppp_xmit_process(ppp);
19231921
}
19241922
}
19251923

19261924
static void ppp_channel_push(struct channel *pch)
19271925
{
1928-
local_bh_disable();
1929-
1930-
__ppp_channel_push(pch);
1931-
1932-
local_bh_enable();
1926+
read_lock_bh(&pch->upl);
1927+
if (pch->ppp) {
1928+
(*this_cpu_ptr(pch->ppp->xmit_recursion))++;
1929+
__ppp_channel_push(pch);
1930+
(*this_cpu_ptr(pch->ppp->xmit_recursion))--;
1931+
} else {
1932+
__ppp_channel_push(pch);
1933+
}
1934+
read_unlock_bh(&pch->upl);
19331935
}
19341936

19351937
/*

0 commit comments

Comments
 (0)