Skip to content

Commit 49e41b6

Browse files
LGA1150gregkh
authored andcommitted
pppoe: drop PFC frames
[ Upstream commit cc1ff87 ] RFC 2516 Section 7 states that Protocol Field Compression (PFC) is NOT RECOMMENDED for PPPoE. In practice, pppd does not support negotiating PFC for PPPoE sessions, and the current PPPoE driver assumes an uncompressed (2-byte) protocol field. However, the generic PPP layer function ppp_input() is not aware of the negotiation result, and still accepts PFC frames. If a peer with a broken implementation or an attacker sends a frame with a compressed (1-byte) protocol field, the subsequent PPP payload is shifted by one byte. This causes the network header to be 4-byte misaligned, which may trigger unaligned access exceptions on some architectures. To reduce the attack surface, drop PPPoE PFC frames. Introduce ppp_skb_is_compressed_proto() helper function to be used in both ppp_generic.c and pppoe.c to avoid open-coding. Fixes: 7fb1b8c ("ppp: Move PFC decompression to PPP generic layer") Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260415022456.141758-2-qingfang.deng@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6849b99 commit 49e41b6

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

drivers/net/ppp/ppp_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,7 @@ ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
22452245
*/
22462246
static void __ppp_decompress_proto(struct sk_buff *skb)
22472247
{
2248-
if (skb->data[0] & 0x01)
2248+
if (ppp_skb_is_compressed_proto(skb))
22492249
*(u8 *)skb_push(skb, 1) = 0x00;
22502250
}
22512251

drivers/net/ppp/pppoe.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
425425
if (skb_mac_header_len(skb) < ETH_HLEN)
426426
goto drop;
427427

428-
if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
428+
if (!pskb_may_pull(skb, PPPOE_SES_HLEN))
429429
goto drop;
430430

431431
ph = pppoe_hdr(skb);
@@ -435,6 +435,12 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
435435
if (skb->len < len)
436436
goto drop;
437437

438+
/* skb->data points to the PPP protocol header after skb_pull_rcsum.
439+
* Drop PFC frames.
440+
*/
441+
if (ppp_skb_is_compressed_proto(skb))
442+
goto drop;
443+
438444
if (pskb_trim_rcsum(skb, len))
439445
goto drop;
440446

include/linux/ppp_defs.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define _PPP_DEFS_H_
99

1010
#include <linux/crc-ccitt.h>
11+
#include <linux/skbuff.h>
1112
#include <uapi/linux/ppp_defs.h>
1213

1314
#define PPP_FCS(fcs, c) crc_ccitt_byte(fcs, c)
@@ -25,4 +26,19 @@ static inline bool ppp_proto_is_valid(u16 proto)
2526
return !!((proto & 0x0101) == 0x0001);
2627
}
2728

29+
/**
30+
* ppp_skb_is_compressed_proto - checks if PPP protocol in a skb is compressed
31+
* @skb: skb to check
32+
*
33+
* Check if the PPP protocol field is compressed (the least significant
34+
* bit of the most significant octet is 1). skb->data must point to the PPP
35+
* protocol header.
36+
*
37+
* Return: Whether the PPP protocol field is compressed.
38+
*/
39+
static inline bool ppp_skb_is_compressed_proto(const struct sk_buff *skb)
40+
{
41+
return unlikely(skb->data[0] & 0x01);
42+
}
43+
2844
#endif /* _PPP_DEFS_H_ */

0 commit comments

Comments
 (0)