Skip to contentSkip to conversation

pppoe: reload header pointer after dev_hard_header()

PATCH Applied Asim Viladi Oglu Manizada 4 participants 4 messages Jul 22 – Jul 23

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

PATCH 1/1 pppoe: reload header pointer after dev_hard_header()

pppoe_sendmsg() saves a pointer to the PPPoE header before calling dev_hard_header(). Device header callbacks are allowed to reallocate the skb head, invalidating pointers into it.

This can happen when a send is blocked in copy_from_user() while the first non-Ethernet port is added to an empty team device. The team's delegated GRE header callback then expands the skb head. PPPoE subsequently writes six bytes through the stale pointer into the freed head.

Reload the PPPoE header through the skb's network-header offset after device header creation. pskb_expand_head() updates that offset when it relocates the head.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by avom-custom-harness:gpt-5.5-qwen3.6-mod-mix
---
 drivers/net/ppp/pppoe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ppp/pppoe.c +1 -0
index 4a018acb5..6874a1a8e 100644
@@ -825,6 +825,7 @@ static int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
 	dev_hard_header(skb, dev, ETH_P_PPP_SES,
 			po->pppoe_pa.remote, NULL, total_len);
 
+	ph = pppoe_hdr(skb);
 	memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
 
 	ph->length = htons(total_len);
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Asim Viladi Oglu Manizada

pppoe_sendmsg() saves a pointer to the PPPoE header before calling dev_hard_header(). Device header callbacks are allowed to reallocate the skb head, invalidating pointers into it.

This can happen when a send is blocked in copy_from_user() while the first non-Ethernet port is added to an empty team device. The team's delegated GRE header callback then expands the skb head. PPPoE subsequently writes six bytes through the stale pointer into the freed head.

Reload the PPPoE header through the skb's network-header offset after device header creation. pskb_expand_head() updates that offset when it relocates the head.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by avom-custom-harness:gpt-5.5-qwen3.6-mod-mix
---
  drivers/net/ppp/pppoe.c | 1 +
  1 file changed, 1 insertion(+)
drivers/net/ppp/pppoe.c +0 -0
index 4a018acb5..6874a1a8e 100644

drivers/net/ppp/pppoe.c static int pppoe_sendmsg(struct socket *sock, struct msghdr *m, · line 831

Quoted 7 lines
drivers/net/ppp/pppoe.c +1 -0
@@ -825,6 +825,7 @@ static int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
  	dev_hard_header(skb, dev, ETH_P_PPP_SES,
  			po->pppoe_pa.remote, NULL, total_len);
 
+	ph = pppoe_hdr(skb);
  	memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
 
  	ph->length = htons(total_len);
Reviewed-by
#2 lore raw
Quoted 31 lines · Vadim Fedorenko
Quoted 29 lines · Asim Viladi Oglu Manizada

pppoe_sendmsg() saves a pointer to the PPPoE header before calling dev_hard_header(). Device header callbacks are allowed to reallocate the skb head, invalidating pointers into it.

This can happen when a send is blocked in copy_from_user() while the first non-Ethernet port is added to an empty team device. The team's delegated GRE header callback then expands the skb head. PPPoE subsequently writes six bytes through the stale pointer into the freed head.

Reload the PPPoE header through the skb's network-header offset after device header creation. pskb_expand_head() updates that offset when it relocates the head.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by avom-custom-harness:gpt-5.5-qwen3.6-mod-mix
---
  drivers/net/ppp/pppoe.c | 1 +
  1 file changed, 1 insertion(+)
drivers/net/ppp/pppoe.c +0 -0
index 4a018acb5..6874a1a8e 100644
@@ -825,6 +825,7 @@ static int pppoe_sendmsg(struct socket *sock, struct msghdr *m,
      dev_hard_header(skb, dev, ETH_P_PPP_SES,
                      po->pppoe_pa.remote, NULL, total_len);
 
Quoted 5 lines

drivers/net/ppp/pppoe.c static int pppoe_sendmsg(struct socket *sock, struct msghdr *m, · line 831

Quoted 4 lines
drivers/net/ppp/pppoe.c +1 -0
+     ph = pppoe_hdr(skb);
      memcpy(ph, &hdr, sizeof(struct pppoe_hdr));
 
      ph->length = htons(total_len);
#3 lore raw
In reply to Asim Viladi Oglu Manizada
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 10 lines · On Wed, 22 Jul 2026 09:38:43 +0000 you wrote:

pppoe_sendmsg() saves a pointer to the PPPoE header before calling dev_hard_header(). Device header callbacks are allowed to reallocate the skb head, invalidating pointers into it.

This can happen when a send is blocked in copy_from_user() while the first non-Ethernet port is added to an empty team device. The team's delegated GRE header callback then expands the skb head. PPPoE subsequently writes six bytes through the stale pointer into the freed head.

[...]

Here is the summary with links:
- [net] pppoe: reload header pointer after dev_hard_header()

    https://git.kernel.org/netdev/net/c/e9c238f6fe42

You are awesome, thank you!

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