* [PATCH v2 net 0/2] net: hamradio: fix missing input validation in bpqether and scc
@ 2026-04-09 2:49 Mashiro Chen
2026-04-09 2:49 ` [PATCH v2 net 1/2] net: hamradio: bpqether: validate frame length in bpq_rcv() Mashiro Chen
2026-04-09 2:49 ` [PATCH v2 net 2/2] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl Mashiro Chen
0 siblings, 2 replies; 4+ messages in thread
From: Mashiro Chen @ 2026-04-09 2:49 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, jreuter, linux-hams,
linux-kernel, Mashiro Chen
This series fixes two missing input validation bugs in the hamradio
drivers. Both patches were reviewed by Joerg Reuter (hamradio
maintainer).
v2 changes:
- bpqether: no code change; add Acked-by: Joerg Reuter
- scc: drop the upper bound of 4096 per reviewer feedback;
only enforce the minimum of 16
Mashiro Chen (2):
net: hamradio: bpqether: validate frame length in bpq_rcv()
net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl
drivers/net/hamradio/bpqether.c | 3 +++
drivers/net/hamradio/scc.c | 2 ++
2 files changed, 5 insertions(+)
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 net 1/2] net: hamradio: bpqether: validate frame length in bpq_rcv()
2026-04-09 2:49 [PATCH v2 net 0/2] net: hamradio: fix missing input validation in bpqether and scc Mashiro Chen
@ 2026-04-09 2:49 ` Mashiro Chen
2026-04-09 2:49 ` [PATCH v2 net 2/2] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl Mashiro Chen
1 sibling, 0 replies; 4+ messages in thread
From: Mashiro Chen @ 2026-04-09 2:49 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, jreuter, linux-hams,
linux-kernel, Mashiro Chen, stable
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.
Additionally, a negative len corrupts the 64-bit rx_bytes counter
through implicit sign-extension.
Add a bounds check before pulling the length bytes: reject frames
where len is negative or exceeds the remaining skb data.
Cc: stable@vger.kernel.org
Cc: linux-hams@vger.kernel.org
Acked-by: Joerg Reuter <jreuter@yaina.de>
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 net 2/2] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl
2026-04-09 2:49 [PATCH v2 net 0/2] net: hamradio: fix missing input validation in bpqether and scc Mashiro Chen
2026-04-09 2:49 ` [PATCH v2 net 1/2] net: hamradio: bpqether: validate frame length in bpq_rcv() Mashiro Chen
@ 2026-04-09 2:49 ` Mashiro Chen
2026-04-09 19:27 ` Joerg Reuter
1 sibling, 1 reply; 4+ messages in thread
From: Mashiro Chen @ 2026-04-09 2:49 UTC (permalink / raw)
To: netdev
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, jreuter, linux-hams,
linux-kernel, Mashiro Chen, stable
The SIOCSCCSMEM ioctl copies a scc_mem_config from user space and
assigns its bufsize field directly to scc->stat.bufsize without any
range validation:
scc->stat.bufsize = memcfg.bufsize;
If a privileged user (CAP_SYS_RAWIO) sets bufsize to 0, the receive
interrupt handler later calls dev_alloc_skb(0) and immediately writes
a KISS type byte via skb_put_u8() into a zero-capacity socket buffer,
corrupting the adjacent skb_shared_info region.
Reject bufsize values smaller than 16; this is large enough to hold
at least one KISS header byte plus useful data.
Cc: stable@vger.kernel.org
Cc: linux-hams@vger.kernel.org
Signed-off-by: Mashiro Chen <mashiro.chen@mailbox.org>
---
drivers/net/hamradio/scc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index ae5048efde686a..8569db4a71401c 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1909,6 +1909,8 @@ static int scc_net_siocdevprivate(struct net_device *dev,
if (!capable(CAP_SYS_RAWIO)) return -EPERM;
if (!arg || copy_from_user(&memcfg, arg, sizeof(memcfg)))
return -EINVAL;
+ if (memcfg.bufsize < 16)
+ return -EINVAL;
scc->stat.bufsize = memcfg.bufsize;
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 net 2/2] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl
2026-04-09 2:49 ` [PATCH v2 net 2/2] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl Mashiro Chen
@ 2026-04-09 19:27 ` Joerg Reuter
0 siblings, 0 replies; 4+ messages in thread
From: Joerg Reuter @ 2026-04-09 19:27 UTC (permalink / raw)
To: Mashiro Chen
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, linux-hams,
linux-kernel, stable
Looks great, thanks!
73, Joerg
> The SIOCSCCSMEM ioctl copies a scc_mem_config from user space and
> assigns its bufsize field directly to scc->stat.bufsize without any
> range validation:
>
> scc->stat.bufsize = memcfg.bufsize;
>
> If a privileged user (CAP_SYS_RAWIO) sets bufsize to 0, the receive
> interrupt handler later calls dev_alloc_skb(0) and immediately writes
> a KISS type byte via skb_put_u8() into a zero-capacity socket buffer,
> corrupting the adjacent skb_shared_info region.
>
> Reject bufsize values smaller than 16; this is large enough to hold
> at least one KISS header byte plus useful data.
>
> Cc: stable@vger.kernel.org
> Cc: linux-hams@vger.kernel.org
Acked-by: Joerg Reuter <jreuter@yaina.de>
> Signed-off-by: Mashiro Chen <mashiro.chen@mailbox.org>
> ---
> drivers/net/hamradio/scc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
> index ae5048efde686a..8569db4a71401c 100644
> --- a/drivers/net/hamradio/scc.c
> +++ b/drivers/net/hamradio/scc.c
> @@ -1909,6 +1909,8 @@ static int scc_net_siocdevprivate(struct net_device *dev,
> if (!capable(CAP_SYS_RAWIO)) return -EPERM;
> if (!arg || copy_from_user(&memcfg, arg, sizeof(memcfg)))
> return -EINVAL;
> + if (memcfg.bufsize < 16)
> + return -EINVAL;
> scc->stat.bufsize = memcfg.bufsize;
> return 0;
>
> --
> 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)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-09 19:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-09 2:49 [PATCH v2 net 0/2] net: hamradio: fix missing input validation in bpqether and scc Mashiro Chen
2026-04-09 2:49 ` [PATCH v2 net 1/2] net: hamradio: bpqether: validate frame length in bpq_rcv() Mashiro Chen
2026-04-09 2:49 ` [PATCH v2 net 2/2] net: hamradio: scc: validate bufsize in SIOCSCCSMEM ioctl Mashiro Chen
2026-04-09 19:27 ` Joerg Reuter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox