mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Hui Peng <benquike@gmail.com>
Cc: alex.aring@gmail.com,  stefan@datenfreihafen.org,
	 davem@davemloft.net, edumazet@google.com,  kuba@kernel.org,
	 pabeni@redhat.com, horms@kernel.org,
	 linux-wpan@vger.kernel.org,  netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ieee802154: socket: fix shared skb BUG_ON and double header subtraction in dgram_ioctl()
Date: Sun, 20 Sep 2026 15:12:19 +0200	[thread overview]
Message-ID: <87jyog9ido.fsf@bootlin.com> (raw)
In-Reply-To: <20260919212855.3241205-1-benquike@gmail.com> (Hui Peng's message of "Sat, 19 Sep 2026 21:28:55 +0000")

On 19/09/2026 at 21:28:55 GMT, Hui Peng <benquike@gmail.com> wrote:

> In `dgram_ioctl()` (`SIOCINQ`), the queued skb at the head of
> `sk->sk_receive_queue` has already had its MAC header stripped by
> `ieee802154_subif_frame()` prior to `dgram_deliver()`, so `skb->len` is
> already the exact payload length that `dgram_recvmsg()` will return to
> userspace.
>
> However, `dgram_ioctl()` computes `*karg = skb->len -
> ieee802154_hdr_length(skb)`. Calling `ieee802154_hdr_length(skb)`
> re-parses the payload bytes as an 802.15.4 MAC header and calls
> `pskb_may_pull(skb, ...)` while holding `sk->sk_receive_queue.lock`.
> When multiple `SOCK_DGRAM` sockets receive a cloned copy of the frame
> (`skb_shared(skb)` is true) and the payload is non-linear,
> `pskb_may_pull()` calls `pskb_expand_head()`, which triggers
> `BUG_ON(skb_shared(skb))`. Even on unshared linear skbs, subtracting
> `ieee802154_hdr_length(skb)` a second time underflows `*karg` to a
> negative value when the payload is shorter than the bogus parsed header
> length.
>
> Set `*karg = skb->len` directly in `dgram_ioctl()`.
>
> Fixes: e1d001fa5b47 ("net: ioctl: Use kernel memory on protocol ioctl callbacks")
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@gmail.com>

Looks legitimate.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

      reply	other threads:[~2026-09-20 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 21:28 Hui Peng
2026-09-20 13:12 ` Miquel Raynal [this message]

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=87jyog9ido.fsf@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=alex.aring@gmail.com \
    --cc=benquike@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stefan@datenfreihafen.org \
    /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

all inboxes | Powered by JetHome®