From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384219; b=jmj6eHba6rY+u9wOlRfBNIe68NLoLvumAYifbSffKqoo0zo0Mni3AH556sXZxScF44cD Wiq5jRhcTd4tOOQLxVoOxTwPG+ll93DM6iTKNlLnrfoLkMImadZZGY3VdzDOl/iRiaIs0 mhygCYNg0P1DiF3AyUCWXy8tmfnOMAVczv5bYJeZx+8QPWSpgN5e19cFe93fee44OgjYN RCHKEUnN1lTR8bli6oqFzS8pUgAkgm1ySedJ57wMkwCkx/QD7IldJJvXyQtRd1dZz4F+u mYQUALkWXE2O+so3SulW9DeSBq28lOvHWSzU0gke1KyT7n2cJU14SiVbjAFGi1Kwm2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384219; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=xCPIqkVEHIrvgliePh2pCJPWOvXkGyNDBrnysFI0cKg=; b=l5eoqwCTyQJouVdEyNgDFWCidxA9tJZkbzBxPi8qnmVRS9AupozfNBEAF/TWmjIQNu0X mPPv9BlEumMrUmAt+BwfqTdORvxGtpAiFr56eN0SYehHbAfiaPMiGLzFXvsagz2Oy9Mp8 CAnFptw0M2iOBosoFT886BVtVuivCX2t5ISMuesHiTdU8N1VkPOg16fnldmq8/WMckM6d nesE4PEv4vnBOIq40XgYePJR1u0dm8ahwRPwL63dVH/RsDeYY6WwSfhbK1bqIWlSRn9IU iCoXnaC7DVBqUcmOU+p1erpJ5c9/zTkcNuRKbJvyQEVsVAzREttai0iCh7gnnGCjYPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tkA7g2to; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88F0F606A322; Fri, 4 Dec 2026 11:36:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=tkA7g2to Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0AB01F00897; Fri, 4 Dec 2026 11:36:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384219; bh=xCPIqkVEHIrvgliePh2pCJPWOvXkGyNDBrnysFI0cKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tkA7g2to+EgONkwTevXUV2+4EBAUe6zqYIsiZPQRTmH3yQmpslARxeOqCYaz8jC/D RMJ3onCjbvrT1AEGn4pTFqISIxgr9un3z7Doz3qLUlQfEoBFCdhQKxw0TCOTfoML+p WGP4m1Y5FZsvI1VmWfDMEqi0v2FbTsYJMYmmgMyM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bernard Pidoux , Sasha Levin Subject: [PATCH 6.12 506/555] netrom: bound the resequencing queue while we are busy Date: Fri, 4 Dec 2026 19:09:09 +0900 Message-ID: <20261204100628.165485110@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bernard Pidoux In state 3, an INFO frame that arrives while we are busy (NR_COND_OWN_RX_BUSY) is put on the resequencing queue and nothing else is done: no check of N(S) against the receive window and no check for a copy already there. The queue is only sorted out once we are no longer busy. A peer that keeps sending while we have set the choke flag, or that sends the same frames again on its own timer, therefore makes the queue grow without limit. These buffers are not charged to the socket, so the receive buffer limit does not stop it either, and they stay until the circuit is closed or the frames can be delivered. Keep a frame that arrives while we are busy only if it is inside the receive window and not already on the queue. Frames outside the window were dropped later anyway, and a copy of a frame we already hold brings nothing, so nothing that can be delivered is lost. The queue is now bounded by the window size. Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A speaks NET/ROM itself, makes a socket on B busy, then ignores the choke flag and sends twice 3000 INFO frames of 20 bytes (N(S) outside the window, and one in ten a copy of a frame inside it). Active skbuff_head_cache objects on B: before: 732, 3780 after the first 3000 frames, 6785 after the second after: 720, 791 after the first 3000 frames, 1100 after the second In both cases the application on B reads the same data afterwards, and there is no KASAN, lockdep or WARN report. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Bernard Pidoux Assisted-by: Claude:claude-opus-5-5 (cherry picked from commit 953622a061da21812307406fc171fbd8ac8c5809) Signed-off-by: Sasha Levin --- net/netrom/nr_in.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c index 805881e5d6c01..f4f5b5fba15b3 100644 --- a/net/netrom/nr_in.c +++ b/net/netrom/nr_in.c @@ -182,6 +182,16 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb, return 0; } +static bool nr_reseq_has_ns(struct nr_sock *nrom, unsigned short ns) +{ + struct sk_buff *skb; + + skb_queue_walk(&nrom->reseq_queue, skb) + if (skb->data[17] == ns) + return true; + return false; +} + /* * State machine for state 3, Connected State. * The handling of the timer(s) is in file nr_timer.c @@ -266,6 +276,16 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype } } } + /* + * While we are busy the frames are only kept for later. + * Keep the ones inside the window that we do not hold + * already, so that a peer that does not stop sending + * cannot make the queue grow without limit. + */ + ns = skb->data[17]; + if ((nrom->condition & NR_COND_OWN_RX_BUSY) && + (!nr_in_rx_window(sk, ns) || nr_reseq_has_ns(nrom, ns))) + break; queued = 1; skb_queue_head(&nrom->reseq_queue, skb); if (nrom->condition & NR_COND_OWN_RX_BUSY) -- 2.53.0