Skip to contentSkip to conversation

pppoe: drop PFC frames

PATCH Superseded Qingfang Deng 3 participants 4 messages Apr 3 – Apr 7

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

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 the compressed protocol field frames.

---
 drivers/net/ppp/pppoe.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ppp/pppoe.c +5 -1
index 1ac61c273b28..457a83c73293 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,10 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (skb->len < len)
 		goto drop;
 
+	/* drop PFC frames */
+	if (unlikely(skb->data[0] & 0x01))
+		goto drop;
+
 	if (pskb_trim_rcsum(skb, len))
 		goto drop;
 
Signature · 1 line
2.43.0
reviewer
#1 lore raw
Quoted 32 lines · Qingfang Deng

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.

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 the compressed protocol field frames.

---
 drivers/net/ppp/pppoe.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ppp/pppoe.c +1 -1
index 1ac61c273b28..457a83c73293 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);

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

Quoted 6 lines
drivers/net/ppp/pppoe.c +3 -0
@@ -403,6 +403,10 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
 	if (skb->len < len)
 		goto drop;
 
+	/* drop PFC frames */
+	if (unlikely(skb->data[0] & 0x01))
+		goto drop;

Hi,

I think it would be best to add/use a #define rather than open coding the magic value 0x01. And perhaps expanding the comment to note that skb->data[0] is the first byte of the PPP protocol would be nice too.

Quoted 7 lines
drivers/net/ppp/pppoe.c +1 -0
+
 	if (pskb_trim_rcsum(skb, len))
 		goto drop;
 
Signature · 1 line
2.43.0
#2 lore raw

Hi,

Quoted 7 lines · Simon Horman

Hi,

I think it would be best to add/use a #define rather than open coding the magic value 0x01. And perhaps expanding the comment to note that skb->data[0] is the first byte of the PPP protocol would be nice too.

The field does not have a canonical name. As per RFC1661, the LSB of the first octet is used to test if the protocol field is compressed, and the same code snippet is used in ppp_generic.c.

I could instead add a helper function:

static inline bool ppp_skb_is_compressed_proto(const struct sk_buff *skb)

{
	return skb->data[0] & 0x01;
}

What do you think?

Regards,
Qingfang

maintainer
#3 lore raw
Quoted 10 lines · On 4/7/26 5:19 AM, [email protected] wrote:
Quoted 4 lines · Simon Horman

I think it would be best to add/use a #define rather than open coding the magic value 0x01. And perhaps expanding the comment to note that skb->data[0] is the first byte of the PPP protocol would be nice too.

The field does not have a canonical name. As per RFC1661, the LSB of the first octet is used to test if the protocol field is compressed, and the same code snippet is used in ppp_generic.c.

Quoted 8 lines

I could instead add a helper function:

static inline bool ppp_skb_is_compressed_proto(const struct sk_buff *skb)

{
	return skb->data[0] & 0x01;
}

What do you think?

The helper LGTM, and could be re-used in ppp_generic.c, too.

/P