From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1384F425CE6 for ; Thu, 4 Jun 2026 11:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780573572; cv=none; b=FeeLn4vsrztyMe0fuDLimC0q+7Z2kMonNX3SqmZCSgFpWMa0ZNqCJPf1cFyn8MvT4ESRY9wHNUmJbK7c6Bd+Ah7Xg4k8Pmst/nbP7yPoRbPEsXF0DPUw2pge/dmCBWoPFYcqGX32e6R7jIDcZvK4KZdFBBu90zvOij/sO94TK1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780573572; c=relaxed/simple; bh=tyBVDAGqORGCNfVRHw3Ru9dCLxp3WyGsGwS0iSMyDzg=; h=From:To:cc:Subject:MIME-Version:Content-Type:Date:Message-ID; b=p1ohPM5eIM/pfmCBH3hJtXKeNVmWTicKi0XFSXTQi1evYJcIRarjZVjh7sicK4/ICnlDJRvFwJ12LxfodkZq0/KZMgu8oHhNKyGXXj4sqZkZUJ7rz9ut4h7/s8Jxz8lvHjkG95FYvOXMtOrnRSJ/oKrfust/NurvLEI7O7Eg4RU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OhD8y0Cq; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OhD8y0Cq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780573570; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1bjPY9dHNK2+TuuIlF+joIQGrJbqLPAjvn/n6TvWQ44=; b=OhD8y0CqyZ2fzMyEzoUCdYpNa8G95XG0cJ9MjY9Ey3H6W9++v5YzrjR0EbX7f9ME4eorCQ hLwTG8e9vcmrNqDoKghTQ5rATVAZ0bWFSSGzqqVIQ8l6AjdjpPnI65xiGHwEVAWAdK3GpN niqB0f3Nk05jjUPmMGCOrR17rNcB+D0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-RbdsaTjfP-K8hroyv3bcXQ-1; Thu, 04 Jun 2026 07:46:09 -0400 X-MC-Unique: RbdsaTjfP-K8hroyv3bcXQ-1 X-Mimecast-MFC-AGG-ID: RbdsaTjfP-K8hroyv3bcXQ_1780573567 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2CCB1180047F; Thu, 4 Jun 2026 11:46:07 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.44.50.14]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E0FF81955D87; Thu, 4 Jun 2026 11:46:02 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: netdev@vger.kernel.org cc: dhowells@redhat.com, Michael Bommarito , Marc Dionne , Jeffrey Altman , Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, stable@kernel.org, linux-kernel@kernel.org Subject: [PATCH net v2] rxrpc: Fix the ACK parser to extract the SACK table for parsing Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <105361.1780573560.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Thu, 04 Jun 2026 12:46:00 +0100 Message-ID: <105362.1780573560@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 = Fix modification of the received skbuff in rxrpc_input_soft_acks() and a potential incorrect access of the buffer in a fragmented UDP packet (the packet would probably have to be deliberately pre-generated as fragmented) when AF_RXRPC tries to extract the contents of the SACK table by copying out the contents of the SACK table into a buffer before attempting to pars= e AF_RXRPC assumes that it can just call skb_condense() and then validly access the SACK table from skb->data and that it will be a flat buffer - but skb_condense() can silently fail to do anything under some circumstances. Note that whilst rxrpc_input_soft_acks() should be able to parse extended ACKs, the rest of AF_RXRPC doesn't currently support that. Further, there's then no need to call skb_condense() in rxrpc_input_ack(), so don't. Fixes: d57a3a151660 ("rxrpc: Save last ACK's SACK table rather than markin= g txbufs") Reported-by: Michael Bommarito Link: https://lore.kernel.org/r/20260513180907.2061972-1-michael.bommarito= @gmail.com Signed-off-by: David Howells cc: Marc Dionne cc: Jeffrey Altman cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: netdev@vger.kernel.org cc: stable@kernel.org --- Changes =3D=3D=3D=3D=3D=3D=3D ver #2) - Fix potential overflow/infinite loop as detected by AI[1] by resetting acks pointer should the ack number hit a multiple of 256. [1] https://lore.kernel.org/r/20260521021910.687776-2-kuba@kernel.org/ net/rxrpc/input.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c index 24aceb183c2c..ce761466b02d 100644 --- a/net/rxrpc/input.c +++ b/net/rxrpc/input.c @@ -963,23 +963,34 @@ static void rxrpc_input_soft_acks(struct rxrpc_call = *call, struct rxrpc_skb_priv *sp =3D rxrpc_skb(skb); struct rxrpc_txqueue *tq =3D call->tx_queue; unsigned long extracted =3D ~0UL; - unsigned int nr =3D 0; + unsigned int nr =3D 0, nsack; rxrpc_seq_t seq =3D call->acks_hard_ack + 1; rxrpc_seq_t lowest_nak =3D seq + sp->ack.nr_acks; - u8 *acks =3D skb->data + sizeof(struct rxrpc_wire_header) + sizeof(struc= t rxrpc_ackpacket); + u8 sack[256] __aligned(sizeof(unsigned long)); + u8 *acks =3D sack; = _enter("%x,%x,%u", tq->qbase, seq, sp->ack.nr_acks); = while (after(seq, tq->qbase + RXRPC_NR_TXQUEUE - 1)) tq =3D tq->next; = + /* Extract an individual SACK table. A normal SACK table is up to 255 + * bytes with 1 ACK flag per byte, but an extended SACK table can be up + * to 256 bytes with up to 8 ACK/NACK flags per byte. The ACK flags go + * across all bit 0's then all bit 1's, then all bit 2's, ... + */ + memset(sack, 0, sizeof(sack)); + nsack =3D umin(sp->ack.nr_acks, 256); + if (skb_copy_bits(skb, + sizeof(struct rxrpc_wire_header) + sizeof(struct rxrpc_ackpacket), + sack, nsack) < 0) + return; + for (unsigned int i =3D 0; i < sp->ack.nr_acks; i++) { /* Decant ACKs until we hit a txqueue boundary. */ + if ((i & 255) =3D=3D 0) + acks =3D sack; shiftr_adv_rotr(acks, extracted); - if (i =3D=3D 256) { - acks -=3D i; - i =3D 0; - } seq++; nr++; if ((seq & RXRPC_TXQ_MASK) !=3D 0) @@ -1117,9 +1128,6 @@ static void rxrpc_input_ack(struct rxrpc_call *call,= struct sk_buff *skb) skb_copy_bits(skb, ioffset, &trailer, sizeof(trailer)) < 0) return rxrpc_proto_abort(call, 0, rxrpc_badmsg_short_ack_trailer); = - if (nr_acks > 0) - skb_condense(skb); - call->acks_latest_ts =3D ktime_get_real(); call->acks_hard_ack =3D hard_ack; call->acks_prev_seq =3D prev_pkt;