Skip to contentSkip to conversation

flow_dissector: do not dissect PPPoE PFC frames

PATCH Applied Qingfang Deng 3 participants 7 messages Apr 15 – Apr 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/2 flow_dissector: do not dissect PPPoE 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 flow dissector driver has assumed an uncompressed frame until the blamed commit.

During the review process of that commit [1], support for PFC is suggested. However, having a compressed (1-byte) protocol field means the subsequent PPP payload is shifted by one byte, causing 4-byte misalignment for the network header and an unaligned access exception on some architectures.

The exception can be reproduced by sending a PPPoE PFC frame to an ethernet interface of a MIPS board, with RPS enabled, even if no PPPoE session is active on that interface:

$ 0   : 00000000 80c40000 00000000 85144817
$ 4   : 00000008 00000100 80a75758 81dc9bb8
$ 8   : 00000010 8087ae2c 0000003d 00000000
$12   : 000000e0 00000039 00000000 00000000
$16   : 85043240 80a75758 81dc9bb8 00006488
$20   : 0000002f 00000007 85144810 80a70000
$24   : 81d1bda0 00000000
$28   : 81dc8000 81dc9aa8 00000000 805ead08
Hi    : 00009d51
Lo    : 2163358a
epc   : 805e91f0 __skb_flow_dissect+0x1b0/0x1b50
ra    : 805ead08 __skb_get_hash_net+0x74/0x12c
Status: 11000403        KERNEL EXL IE
Cause : 40800010 (ExcCode 04)
BadVA : 85144817
PrId  : 0001992f (MIPS 1004Kc)
Call Trace:
[<805e91f0>] __skb_flow_dissect+0x1b0/0x1b50
[<805ead08>] __skb_get_hash_net+0x74/0x12c
[<805ef330>] get_rps_cpu+0x1b8/0x3fc
[<805fca70>] netif_receive_skb_list_internal+0x324/0x364
[<805fd120>] napi_complete_done+0x68/0x2a4
[<8058de5c>] mtk_napi_rx+0x228/0xfec
[<805fd398>] __napi_poll+0x3c/0x1c4
[<805fd754>] napi_threaded_poll_loop+0x234/0x29c
[<805fd848>] napi_threaded_poll+0x8c/0xb0
[<80053544>] kthread+0x104/0x12c
[<80002bd8>] ret_from_kernel_thread+0x14/0x1c
Code: 02d51821  1060045b  00000000 <8c640000> 3084000f  2c820005  144001a2  00042080  8e220000

To reduce the attack surface and maintain performance, do not process PPPoE PFC frames.

[1] https://lore.kernel.org/r/[email protected]

Fixes 46126db9c861 ("flow_dissector: Add PPPoE dissectors")

---
Changes in v6: document that PFC is rejected by ppp_proto_is_valid().
Link to v5: https://lore.kernel.org/r/[email protected]

 net/core/flow_dissector.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
net/core/flow_dissector.c +5 -8
index 1b61bb25ba0e..c471559db4d9 100644
@@ -1374,16 +1374,13 @@ bool __skb_flow_dissect(const struct net *net,
 			break;
 		}
 
-		/* least significant bit of the most significant octet
-		 * indicates if protocol field was compressed
+		/* PFC (compressed 1-byte protocol) frames are not processed.
+		 * A compressed protocol field has the least significant bit of
+		 * the most significant octet set, which will fail the following
+		 * ppp_proto_is_valid(), returning FLOW_DISSECT_RET_OUT_BAD.
 		 */
 		ppp_proto = ntohs(hdr->proto);
-		if (ppp_proto & 0x0100) {
-			ppp_proto = ppp_proto >> 8;
-			nhoff += PPPOE_SES_HLEN - 1;
-		} else {
-			nhoff += PPPOE_SES_HLEN;
-		}
+		nhoff += PPPOE_SES_HLEN;
 
 		if (ppp_proto == PPP_IP) {
 			proto = htons(ETH_P_IP);
Signature · 1 line
2.43.0
#1 lore raw

PATCH v6 2/2 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.

Fixes 7fb1b8ca8fa1 ("ppp: Move PFC decompression to PPP generic layer")

---
Changes in v6: none
Link to v5: https://lore.kernel.org/r/[email protected]

 drivers/net/ppp/ppp_generic.c |  2 +-
 drivers/net/ppp/pppoe.c       |  8 +++++++-
 include/linux/ppp_defs.h      | 16 ++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)
drivers/net/ppp/ppp_generic.c +1 -1
index b0d3bc49c685..57c68efa5ff8 100644
@@ -2245,7 +2245,7 @@ ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
  */
 static void __ppp_decompress_proto(struct sk_buff *skb)
 {
-	if (skb->data[0] & 0x01)
+	if (ppp_skb_is_compressed_proto(skb))
 		*(u8 *)skb_push(skb, 1) = 0x00;
 }
 
drivers/net/ppp/pppoe.c +7 -1
index d546a7af0d54..bdd61c504a1c 100644
@@ -393,7 +393,7 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (skb_mac_header_len(skb) < ETH_HLEN)
 		goto drop;
 
-	if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
+	if (!pskb_may_pull(skb, PPPOE_SES_HLEN))
 		goto drop;
 
 	ph = pppoe_hdr(skb);
@@ -403,6 +403,12 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (skb->len < len)
 		goto drop;
 
+	/* skb->data points to the PPP protocol header after skb_pull_rcsum.
+	 * Drop PFC frames.
+	 */
+	if (ppp_skb_is_compressed_proto(skb))
+		goto drop;
+
 	if (pskb_trim_rcsum(skb, len))
 		goto drop;
 
include/linux/ppp_defs.h +16 -0
index b7e57fdbd413..b1d1f46d7d3b 100644
@@ -8,6 +8,7 @@
 #define _PPP_DEFS_H_
 
 #include <linux/crc-ccitt.h>
+#include <linux/skbuff.h>
 #include <uapi/linux/ppp_defs.h>
 
 #define PPP_FCS(fcs, c) crc_ccitt_byte(fcs, c)
@@ -25,4 +26,19 @@ static inline bool ppp_proto_is_valid(u16 proto)
 	return !!((proto & 0x0101) == 0x0001);
 }
 
+/**
+ * ppp_skb_is_compressed_proto - checks if PPP protocol in a skb is compressed
+ * @skb: skb to check
+ *
+ * Check if the PPP protocol field is compressed (the least significant
+ * bit of the most significant octet is 1). skb->data must point to the PPP
+ * protocol header.
+ *
+ * Return: Whether the PPP protocol field is compressed.
+ */
+static inline bool ppp_skb_is_compressed_proto(const struct sk_buff *skb)
+{
+	return unlikely(skb->data[0] & 0x01);
+}
+
 #endif /* _PPP_DEFS_H_ */
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH net v6 2/2] pppoe: drop PFC frames

This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
pppoe: drop PFC frames

This commit drops Protocol Field Compression (PFC) frames for PPPoE to avoid unaligned access exceptions caused by the network header being shifted. A helper function is introduced to identify compressed protocol fields.

Quoted 3 lines
drivers/net/ppp/pppoe.c +0 -0

[ ... ]

drivers/net/ppp/pppoe.c static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev, · line 440

Quoted 8 lines
drivers/net/ppp/pppoe.c +4 -0
@@ -434,6 +434,12 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (skb->len < len)
 		goto drop;
 
+	/* skb->data points to the PPP protocol header after skb_pull_rcsum.
+	 * Drop PFC frames.
+	 */
+	if (ppp_skb_is_compressed_proto(skb))

Does this code safely access the PPP protocol byte?

After pulling the PPPoE header, skb->data points to the inner payload. However, the new ppp_skb_is_compressed_proto() helper unconditionally dereferences skb->data[0].

If a crafted PPPoE packet is received with an inner length of 0 and no Ethernet padding, the linear buffer might end exactly after the PPPoE header. In that scenario, this would read past the allocated linear buffer.

Even if the inner length is greater than 0, could the payload reside entirely in non-linear paged fragments, causing an out-of-bounds read?

Would it be safer to verify the packet has at least 1 byte and use pskb_may_pull() to ensure the protocol byte is in the linear region before inspecting it, perhaps after the pskb_trim_rcsum() call?

Quoted 4 lines
drivers/net/ppp/pppoe.c +2 -0
+		goto drop;
+
 	if (pskb_trim_rcsum(skb, len))
 		goto drop;

[ ... ]

Quoted 3 lines
include/linux/ppp_defs.h +0 -0

[ ... ]

Quoted 4 lines
include/linux/ppp_defs.h +4 -0
+static inline bool ppp_skb_is_compressed_proto(const struct sk_buff *skb)
+{
+	return unlikely(skb->data[0] & 0x01);
+}
Signature · 1 line
pw-bot: cr
#3 lore raw

Re: [PATCH net v6 2/2] pppoe: drop PFC frames

Hi,

Quoted 20 lines · Jakub Kicinski

[ ... ]

drivers/net/ppp/pppoe.c static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev, · line 440

Quoted 8 lines
drivers/net/ppp/pppoe.c +4 -0
@@ -434,6 +434,12 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
  	if (skb->len < len)
  		goto drop;
 
+	/* skb->data points to the PPP protocol header after skb_pull_rcsum.
+	 * Drop PFC frames.
+	 */
+	if (ppp_skb_is_compressed_proto(skb))

Does this code safely access the PPP protocol byte?

After pulling the PPPoE header, skb->data points to the inner payload. However, the new ppp_skb_is_compressed_proto() helper unconditionally dereferences skb->data[0].

If a crafted PPPoE packet is received with an inner length of 0 and no Ethernet padding, the linear buffer might end exactly after the PPPoE header. In that scenario, this would read past the allocated linear buffer.

Quoted 6 lines

Even if the inner length is greater than 0, could the payload reside entirely in non-linear paged fragments, causing an out-of-bounds read?

Would it be safer to verify the packet has at least 1 byte and use pskb_may_pull() to ensure the protocol byte is in the linear region before inspecting it, perhaps after the pskb_trim_rcsum() call?

I already updated the pskb_may_pull() above, from struct pppoe_hdr (6) to PPPOE_SES_HLEN (8), to ensure that.

Regards,
Qingfang

maintainer
#5 lore raw
Quoted 2 lines · On Wed, 15 Apr 2026 21:42:09 +0800 Qingfang Deng wrote:

The patch state is "Changes Requested" in patchwork but I haven't received any feedback. Was it set by mistake?

Fixed, thanks for the report.

#6 lore raw
In reply to Qingfang Deng
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 5 lines · On Wed, 15 Apr 2026 10:24:50 +0800 you wrote:

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 flow dissector driver has assumed an uncompressed frame until the blamed commit.

Quoted 7 lines

During the review process of that commit [1], support for PFC is suggested. However, having a compressed (1-byte) protocol field means the subsequent PPP payload is shifted by one byte, causing 4-byte misalignment for the network header and an unaligned access exception on some architectures.

[...]

Here is the summary with links:
- [net,v6,1/2] flow_dissector: do not dissect PPPoE PFC frames

    https://git.kernel.org/netdev/net/c/d6c19b31a3c1
  - [net,v6,2/2] pppoe: drop PFC frames
    https://git.kernel.org/netdev/net/c/cc1ff87bce1c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html