From adaeff554005d8cf2de2e2fb086dd858059c1a25 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sun, 26 Apr 2015 20:59:09 +0200 Subject: [PATCH] PPP, MPPE, discard late packet in stateless mode When PPP is used over a link which does not guarantee packet ordering, we might get late MPPE packets. This is a problem because MPPE must be kept synchronized and the current implementation does not drop them and rekey 4095 times instead of 0, which is wrong. In order to prevent rekeying about a whole count space times (~ 4095 times), drop packets which are not within the forward 4096/2 window and increase sanity error counter. --- src/netif/ppp/mppe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/netif/ppp/mppe.c b/src/netif/ppp/mppe.c index 85e6d451..31a38d86 100644 --- a/src/netif/ppp/mppe.c +++ b/src/netif/ppp/mppe.c @@ -308,6 +308,12 @@ mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb) */ if (!state->stateful) { + /* Discard late packet */ + if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE > MPPE_CCOUNT_SPACE / 2) { + state->sanity_errors++; + goto sanity_error; + } + /* RFC 3078, sec 8.1. Rekey for every packet. */ while (state->ccount != ccount) { mppe_rekey(state, 0);