From: Joerg Reuter <jreuter@yaina.de>
To: Mashiro Chen <mashiro.chen@mailbox.org>
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, linux-hams@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net 1/2] net: hamradio: bpqether: validate frame length in bpq_rcv()
Date: Wed, 8 Apr 2026 23:05:25 +0200 [thread overview]
Message-ID: <adbDFVlrqnldyBXz@yaina.de> (raw)
In-Reply-To: <20260408172358.281186-2-mashiro.chen@mailbox.org>
Am Thu, Apr 09, 2026 at 01:23:57AM +0800 schrieb Mashiro Chen:
> The BPQ length field is decoded as:
>
> len = skb->data[0] + skb->data[1] * 256 - 5;
>
> If the sender sets bytes [0..1] to values whose combined value is
> less than 5, len becomes negative. Passing a negative int to
> skb_trim() silently converts to a huge unsigned value, causing the
> function to be a no-op. The frame is then passed up to AX.25 with
> its original (untrimmed) payload, delivering garbage beyond the
> declared frame boundary.
I don't even know why there is a length field in the first place, and John
G8BPQ doesn't seem to remember either.
There is nothing supposed to come after the payload, and there should be no
need to skb_trim() at all.
However, since an obviously wrong length field indicates that something is
indeed wrong with that frame, I'm in favor of dropping those frames.
Acked-by: Joerg Reuter <jreuter@yaina.de>
> Cc: stable@vger.kernel.org
> Cc: linux-hams@vger.kernel.org
> Signed-off-by: Mashiro Chen <mashiro.chen@mailbox.org>
> ---
> drivers/net/hamradio/bpqether.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
> index 045c5177262eaf..214fd1f819a1bb 100644
> --- a/drivers/net/hamradio/bpqether.c
> +++ b/drivers/net/hamradio/bpqether.c
> @@ -187,6 +187,9 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
>
> len = skb->data[0] + skb->data[1] * 256 - 5;
>
> + if (len < 0 || len > skb->len - 2)
> + goto drop_unlock;
> +
> skb_pull(skb, 2); /* Remove the length bytes */
> skb_trim(skb, len); /* Set the length of the data */
>
> --
> 2.53.0
>
--
Joerg Reuter http://yaina.de/jreuter
And I make my way to where the warm scent of soil fills the evening air.
Everything is waiting quietly out there.... (Anne Clark)
next prev parent reply other threads:[~2026-04-08 21:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260408172358.281186-1-mashiro.chen@mailbox.org>
2026-04-08 17:23 ` [PATCH net 1/2] net: hamradio: bpqether: validate frame length in bpq_rcv() Mashiro Chen
2026-04-08 21:05 ` Joerg Reuter [this message]
2026-04-08 17:23 ` [PATCH net 2/2] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl Mashiro Chen
2026-04-08 20:51 ` Joerg Reuter
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=adbDFVlrqnldyBXz@yaina.de \
--to=jreuter@yaina.de \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-hams@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mashiro.chen@mailbox.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.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