History

pppoe: drop PFC frames

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.

Qingfang Deng committed 7 months ago

Commit cc1ff871 parent d6c19b33 files · +24 −2Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/ppp_defs.h+16−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
8#define _PPP_DEFS_H_8#define _PPP_DEFS_H_
9 9
10#include <linux/crc-ccitt.h>10#include <linux/crc-ccitt.h>
11#include <linux/skbuff.h>
11#include <uapi/linux/ppp_defs.h>12#include <uapi/linux/ppp_defs.h>
12 13
13#define PPP_FCS(fcs, c) crc_ccitt_byte(fcs, c)14#define PPP_FCS(fcs, c) crc_ccitt_byte(fcs, c)
@@ -25,4 +26,19 @@ static inline bool ppp_proto_is_valid(u16 proto) · 11 unmodified lines
25 return !!((proto & 0x0101) == 0x0001);26 return !!((proto & 0x0101) == 0x0001);
26}27}
27 28
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 */
39static inline bool ppp_skb_is_compressed_proto(const struct sk_buff *skb)
40{
41 return unlikely(skb->data[0] & 0x01);
42}
43
28#endif /* _PPP_DEFS_H_ */44#endif /* _PPP_DEFS_H_ */