Netdev List
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: netdev@vger.kernel.org, Simon Wunderlich <sw@simonwunderlich.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	b.a.t.m.a.n@lists.open-mesh.org,
	Simon Wunderlich <sw@simonwunderlich.de>
Subject: Re: [PATCH net-next 05/10] batman-adv: annotate functions which may reallocate the skbuff
Date: Thu, 06 Aug 2026 18:13:14 +0200	[thread overview]
Message-ID: <5280888.31r3eYUQgx@sven-desktop> (raw)
In-Reply-To: <20260805143200.722098-6-sw@simonwunderlich.de>

[-- Attachment #1: Type: text/plain, Size: 4420 bytes --]

https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260805143200.722098-1-sw%40simonwunderlich.de?part=5

> --- Patch [5]: [PATCH net-next 05/10] batman-adv: annotate functions which may reallocate the skbuff ---
[...]
> 
> Discovered by: opus-5 · Missed by: sashiko-gemini
> This isn't a bug, but the ellipsis in the batadv_dat_snoop_outgoing_arp_request()
> annotation has an extra dot ("batadv_dat_get_vid()/....") compared to the
> "/..." spelling used in the other hunks of this patch.

Feel free to use the extra dot for whatever you want. Will not resend the PR 
or create a patch because of this.

> 
> > + * from skb->data or eth_hdr()) before this call must be considered
> > + * invalid afterwards and has to be reacquired.
> > + *
> >   * Return: true if the message has been sent to the dht candidates, false
> >   * otherwise. In case of a positive return value the message has to be enqueued
> >   * to permit the fallback.
> > @@ -1271,6 +1286,11 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
> >   * @skb: packet to check
> >   * @hdr_size: size of the encapsulation header
> >   *
> > + * Warning: This function may reallocate the skb data buffer via
> > + * batadv_dat_get_vid()/... Any pointer into the skb data (e.g. obtained
> > + * from skb->data or eth_hdr()) before this call must be considered
> > + * invalid afterwards and has to be reacquired.
> > + *
> >   * Return: true if the request has been answered, false otherwise.
> >   */
> >  bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
> 
> Discovered by: opus-5 · Missed by: sashiko-gemini
> Is the advice to reacquire the pointers correct for the true return path of
> batadv_dat_snoop_incoming_arp_request()?  On that path the skb is not just
> reallocated, it is released:
> 
> net/batman-adv/distributed-arp-table.c:batadv_dat_snoop_incoming_arp_request() {
> 	...
> out:
> 	batadv_dat_entry_put(dat_entry);
> 	if (ret)
> 		kfree_skb(skb);
> 	return ret;
> }

This is outside the scope of this patch. The WARNING is of course only valid 
when there is still an skb to use.

> [ ... ]
> 
> > @@ -1788,6 +1818,11 @@ void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
> >   * This function first checks whether the given skb is a valid DHCPACK. If
> >   * so then its source MAC and IP as well as its DHCP Client Hardware Address
> >   * field and DHCP Your IP Address field are added to the local DAT cache.
> > + *
> > + * Warning: This function may reallocate the skb data buffer via
> > + * pskb_may_pull()/batadv_dat_get_vid()/... Any pointer into the skb data
> > + * (e.g.obtained from skb->data or eth_hdr()) before this call must be
>        ^^^^^^^^^^
> 
> Discovered by: opus-5 · Missed by: sashiko-gemini
> Missing space after "e.g." in the batadv_dat_snoop_incoming_dhcp_ack()
> annotation.

Will not resend the PR because of this.

> [ ... ]
> 
> > diff --git a/net/batman-adv/multicast_forw.c b/net/batman-adv/multicast_forw.c
> > index 1404a3b7adfb1..60ec12805742c 100644
> > --- a/net/batman-adv/multicast_forw.c
> > +++ b/net/batman-adv/multicast_forw.c
> > @@ -1080,6 +1080,11 @@ unsigned int batadv_mcast_forw_packet_hdrlen(unsigned int num_dests)
> >   * Tries to expand an skb's headroom so that its head to tail is 1298
> >   * bytes (minimum IPv6 MTU + vlan ethernet header size) large.
> >   *
> > + * Warning: This function may reallocate the skb data buffer via
> > + * skb_cow()/skb_linearize()/... Any pointer into the skb data (e.g.
> > + * obtained from skb->data or eth_hdr()) before this call must be
> > + * considered invalid afterwards and has to be reacquired.
> > + *
> 
> Discovered by: opus-5 · Missed by: sashiko-gemini
> Are skb_cow() and skb_linearize() the right helpers to name here?
> batadv_mcast_forw_expand_head() calls neither of them; the only
> reallocating primitive in its body is pskb_expand_head():
> 
> net/batman-adv/multicast_forw.c:batadv_mcast_forw_expand_head() {
> 	...
> 	if (skb_headroom(skb) < hdr_size &&
> 	    pskb_expand_head(skb, hdr_size, 0, GFP_ATOMIC) < 0)
> 		return -ENOMEM;
> 
> 	return 0;
> }

The relevant changes were lost when the fixes were removed from the PR. Will 
not resend the PR without this line. The statement will be true when the fixes 
are added.

Regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-08-06 16:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 14:27 [PATCH net-next 00/10] pull request for net-next: batman-adv 2026-08-05 Simon Wunderlich
2026-08-05 14:27 ` [PATCH net-next 01/10] batman-adv: dat: drop non-4addr backwards compatibility Simon Wunderlich
2026-08-06 15:03   ` Sven Eckelmann
2026-08-05 14:27 ` [PATCH net-next 02/10] batman-adv: tvlv: handle negative tvlv processing return codes Simon Wunderlich
2026-08-06 15:36   ` Sven Eckelmann
2026-08-05 14:27 ` [PATCH net-next 03/10] batman-adv: add missing kernel-doc comments Simon Wunderlich
2026-08-06 16:02   ` Sven Eckelmann
2026-08-06 18:25   ` Sven Eckelmann
2026-08-05 14:27 ` [PATCH net-next 04/10] batman-adv: fix kernel-doc for functions holding skb ownership Simon Wunderlich
2026-08-05 14:27 ` [PATCH net-next 05/10] batman-adv: annotate functions which may reallocate the skbuff Simon Wunderlich
2026-08-06 16:13   ` Sven Eckelmann [this message]
2026-08-05 14:27 ` [PATCH net-next 06/10] batman-adv: split multiple declarations per line Simon Wunderlich
2026-08-05 14:27 ` [PATCH net-next 07/10] batman-adv: switch var declarations to reverse x-mas tree order Simon Wunderlich
2026-08-05 14:27 ` [PATCH net-next 08/10] batman-adv: handle errors in batadv_init() Simon Wunderlich
2026-08-05 14:27 ` [PATCH net-next 09/10] batman-adv: correct NET_RX_* NET_XMIT_* confusion Simon Wunderlich
2026-08-05 14:27 ` [PATCH net-next 10/10] batman-adv: remove negative returns for batadv_send_skb_unicast Simon Wunderlich
2026-08-06 16:26   ` Sven Eckelmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5280888.31r3eYUQgx@sven-desktop \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sw@simonwunderlich.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox