From: Jakub Kicinski <kuba@kernel.org>
To: dhowells@redhat.com
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, michael.bommarito@gmail.com,
marc.dionne@auristor.com, jaltman@auristor.com,
edumazet@google.com, davem@davemloft.net, pabeni@redhat.com,
horms@kernel.org, linux-afs@lists.infradead.org,
stable@kernel.org
Subject: Re: [PATCH net] rxrpc: Fix the ACK parser to extract the SACK table for parsing
Date: Wed, 20 May 2026 19:19:11 -0700 [thread overview]
Message-ID: <20260521021910.687776-2-kuba@kernel.org> (raw)
In-Reply-To: <488970.1779144259@warthog.procyon.org.uk>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
rxrpc: Fix the ACK parser to extract the SACK table for parsing
This commit fixes modification of the received skbuff and incorrect access
of the buffer in fragmented UDP packets during SACK table parsing. It copies
out the contents of the SACK table into a flat stack buffer instead of
relying on skb_condense().
Link: https://lore.kernel.org/r/20260513180907.2061972-1-michael.bommarito@gmail.com
> diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
> index 24aceb183c2c3..0c15ebf19eae9 100644
> --- a/net/rxrpc/input.c
> +++ b/net/rxrpc/input.c
> @@ -963,21 +963,34 @@ static void rxrpc_input_soft_acks(struct rxrpc_call *call,
> struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
> struct rxrpc_txqueue *tq = call->tx_queue;
> unsigned long extracted = ~0UL;
> - unsigned int nr = 0;
> + unsigned int nr = 0, nsack;
> rxrpc_seq_t seq = call->acks_hard_ack + 1;
> rxrpc_seq_t lowest_nak = seq + sp->ack.nr_acks;
> - u8 *acks = skb->data + sizeof(struct rxrpc_wire_header) + sizeof(struct rxrpc_ackpacket);
> + u8 sack[256] __aligned(sizeof(unsigned long));
> + u8 *acks = sack;
[ ... ]
> for (unsigned int i = 0; i < sp->ack.nr_acks; i++) {
> /* Decant ACKs until we hit a txqueue boundary. */
> shiftr_adv_rotr(acks, extracted);
> if (i == 256) {
> - acks -= i;
> + acks = sack;
> i = 0;
> }
Can this lead to an out-of-bounds access and an infinite loop if
sp->ack.nr_acks is greater than 256?
If a received packet has sp->ack.nr_acks > 256, on the 257th iteration
(where i == 256), the shiftr_adv_rotr(acks, extracted) macro will execute
before the wrap-around check resets the acks pointer.
Since the acks pointer has been incremented 256 times by previous iterations,
wouldn't it point to sack + 256 at this point, causing an out-of-bounds read
and write on the sack[] array?
Furthermore, resetting i to 0 inside the loop means the loop's i++
operation will set it to 1 for the next iteration. Because the counter is
reset without breaking out of the loop, will this ever terminate if
sp->ack.nr_acks > 256, or will it cycle infinitely and eventually cause a NULL
pointer dereference when tq->next runs out of transmit queues?
--
pw-bot: cr
next prev parent reply other threads:[~2026-05-21 2:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 22:44 [PATCH net] rxrpc: Fix the ACK parser to extract the SACK table for parsing David Howells
2026-05-20 13:36 ` Jeffrey E Altman
2026-05-21 2:19 ` Jakub Kicinski [this message]
2026-05-21 2:42 ` Jeffrey E Altman
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=20260521021910.687776-2-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jaltman@auristor.com \
--cc=linux-afs@lists.infradead.org \
--cc=marc.dionne@auristor.com \
--cc=michael.bommarito@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@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