From: Mashiro Chen <mashiro.chen@mailbox.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, gregkh@linuxfoundation.org,
ben@decadent.org.uk, linux-hams@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Mashiro Chen <mashiro.chen@mailbox.org>
Subject: [PATCH 1/3] net: netrom: fix integer overflow in nr_queue_rx_frame()
Date: Wed, 8 Apr 2026 01:15:58 +0800 [thread overview]
Message-ID: <20260407171600.102988-2-mashiro.chen@mailbox.org> (raw)
In-Reply-To: <20260407171600.102988-1-mashiro.chen@mailbox.org>
nr_sock.fraglen is declared as unsigned short, so accumulating
received fragment lengths via
nr->fraglen += skb->len;
can silently wrap around to a small value once the total exceeds
65535 bytes. When the final fragment arrives (NR_MORE_FLAG clear),
the wrapped fraglen is passed to alloc_skb(), which allocates an
undersized buffer. The subsequent skb_put() and skb_copy_from_linear_data()
loop then writes the actual full data into it, resulting in a heap
buffer overflow.
An attacker with NR_STATE_3 access (i.e. after completing a NET/ROM
connection handshake, which open BBS/node services allow to any
callsign) can trigger this by sending a stream of NR_INFO frames
with the MORE flag set until fraglen wraps, followed by a final
NR_INFO frame.
Fix by checking whether adding the incoming skb's length to the
accumulated fraglen would exceed USHRT_MAX before each accumulation.
If so, purge the fragment queue, reset fraglen, and return an error
to signal receive-busy to the caller.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Mashiro Chen <mashiro.chen@mailbox.org>
---
net/netrom/nr_in.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c
index 97944db6b5ac6..0b7cdb99ae501 100644
--- a/net/netrom/nr_in.c
+++ b/net/netrom/nr_in.c
@@ -36,12 +36,22 @@ static int nr_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
nr_start_idletimer(sk);
if (more) {
+ if ((unsigned int)nr->fraglen + skb->len > USHRT_MAX) {
+ skb_queue_purge(&nr->frag_queue);
+ nr->fraglen = 0;
+ return 1;
+ }
nr->fraglen += skb->len;
skb_queue_tail(&nr->frag_queue, skb);
return 0;
}
if (!more && nr->fraglen > 0) { /* End of fragment */
+ if ((unsigned int)nr->fraglen + skb->len > USHRT_MAX) {
+ skb_queue_purge(&nr->frag_queue);
+ nr->fraglen = 0;
+ return 1;
+ }
nr->fraglen += skb->len;
skb_queue_tail(&nr->frag_queue, skb);
--
2.53.0
next prev parent reply other threads:[~2026-04-07 17:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 17:15 [PATCH 0/3] net: fix three security bugs in NET/ROM and ROSE stacks Mashiro Chen
2026-04-07 17:15 ` Mashiro Chen [this message]
2026-04-07 17:15 ` [PATCH 2/3] net: netrom: validate source address in nr_find_socket() Mashiro Chen
2026-04-07 17:16 ` [PATCH 3/3] net: rose: fix out-of-bounds read in rose_parse_ccitt() Mashiro Chen
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=20260407171600.102988-2-mashiro.chen@mailbox.org \
--to=mashiro.chen@mailbox.org \
--cc=ben@decadent.org.uk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-hams@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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