🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Simon Horman Sun, 18 Oct 2026 13:31
Re: [PATCH net 1/1] net: phonet: ensure headroom for aligned GPRS TX
#4563
Author: Simon Horman
Date: Sun, 18 Oct 2026 13:31
91 lines
8867 bytes
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/eeacc6bb1a121b6161c38898441997ea4641e5c0.1791616268.git.rakukuip@gmail.com?part=1
---
net: phonet: ensure headroom for aligned GPRS TX

This commit adds a skb_cow_head() call in pep_write() on the aligned pipe
path. It makes sure the skb forwarded from gprs_xmit() has enough headroom
before pipe_skb_send() and pn_send() push the pipe and Phonet headers. If
reallocation fails, the skb is dropped and -ENOMEM is returned.

Closes: https://bugtracker.nebusec.ai/f/1935

> diff --git a/net/phonet/pep.c b/net/phonet/pep.c
> index bd1cdd00edfa5..9d24b370fb7c0 100644
> --- a/net/phonet/pep.c
> +++ b/net/phonet/pep.c
> @@ -1259,8 +1259,13 @@ int pep_write(struct sock *sk, struct sk_buff *skb)
>  	struct sk_buff *rskb, *fs;
>  	int flen = 0;
>  
> -	if (pep_sk(sk)->aligned)
> +	if (pep_sk(sk)->aligned) {
> +		if (skb_cow_head(skb, MAX_PNPIPE_HEADER)) {

[Severity: Medium]
Will this reallocate the head of almost every packet on the aligned GPRS
path?

MAX_PNPIPE_HEADER expands to a large value:

include/net/phonet/pep.h:
#define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)

include/net/phonet/phonet.h:
#define MAX_PHONET_HEADER	(8 + MAX_HEADER)

That is at least 44 bytes, and up to about 188 bytes depending on config.

The GPRS netdev does not advertise any headroom, though. gprs_setup() in
net/phonet/pep-gprs.c sets:

	dev->hard_header_len	= 0;

and never sets needed_headroom, so LL_RESERVED_SPACE() for the gprs device
is 16.

For locally generated IPv4 datagrams, __ip_append_data() uses
hh_len = LL_RESERVED_SPACE(rt->dst.dev) and calls skb_reserve(skb, hh_len).
ip_finish_output2() does not expand the head either, because the gprs
device has no header_ops.

So UDP, ICMP and raw packets arrive here with 16 bytes of headroom:

udp_sendmsg()
  __ip_append_data()        /* skb_reserve(skb, 16) */
  ...
  ip_finish_output2()
    gprs_xmit()
      pep_write()
        skb_cow_head(skb, MAX_PNPIPE_HEADER)
          __skb_cow()
            pskb_expand_head(..., GFP_ATOMIC)

Before this patch, those packets had enough room for what is actually
pushed and did not crash: the 4 byte pipe header, the 7 byte phonethdr,
and the lower device's link header. Many skbs forwarded from ordinary NICs
also fall below the new threshold on common configs. Only paths with large
reservations, such as TCP's MAX_TCP_HEADER, avoid the copy.

With this change, the zero-copy path from fea93ecef619 ("Phonet: zero-copy
GPRS TX") copies the head in the common case. That makes it more expensive
than the non-aligned path, which only allocates a small wrapper skb and
chains the payload through frag_list.

The commit message describes the check only as a guard for unusual skbs,
such as ones redirected from veth, and does not mention this effect.

Would it be better to set dev->needed_headroom in gprs_setup() (for
example to MAX_PNPIPE_HEADER)? The stack would then reserve the space up
front, and skb_cow_head() would only be a rarely taken safety net.

> +			kfree_skb(skb);
> +			return -ENOMEM;
> +		}
>  		return pipe_skb_send(sk, skb);
> +	}
>  
>  	rskb = alloc_skb(MAX_PNPIPE_HEADER, GFP_ATOMIC);
>  	if (!rskb) {
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads