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=1796384132; b=xSCFQb/nBG7ykAJ5qvcki6odo//Xqieay6VEuIkpKxcyhfGL/yLBV7XZrJvX4RqBeGKT OUit3r3lE5BN0uFXIriffORVjYiGdFQbDJ8w6LI8OGx72O+CYH7KiBOcOVrxVB3NmYUra 5d6xjEB0ih2NsBr/Q3sFAA7hNP+mew5Syb0js1ULu/deEv75KMNP9ZlDvLUW20NRgbQLQ 9Q2x1Li8HT6Apy/TxQJpCyhHm35FK7XNnXpTGvkIhB9VIO4rbw8jnuNwSBwLD3cWf4J4l RZzRQoRxeYHueNI+rgEhMUR0J0hjWjB9YTevupqgC0LjnZVRlMFN0l870lkO9NoIAaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384132; 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=yTUcNaqJqPLbmAMKpa0br1oukxu7L6ZRQejhERdd04c=; b=K1QatseM/5AT0scY2616KCCqBdIgJL5YaWGB5CCdSeLRA4xA7hEQhCxT7dPAW/QZjU8H zuRFFW1KwAZCIIpn9+GyLHoR4kIeCZg1k89XA2xLZiWmwEeNTFT95EuCWjWdh+Bg41lA7 QG4trwwZWnatWn9mAW/HHoBYbwh/sn1hy4kAG1opJ/S7qNQf12BLOKrXV9GKimuLbtp1J tlHasGmNEnrwIODrP9JNb+nWJr7O6SeBIjf0RZP4lRUTZycYxBAaBCV5ubRoheTe6mMUR Xjy3G8Zp3hs2dmBsBFUt/NIhv5BhCdsNN1EFyXJvanEo6a3kvAz6Ozlsyjk3xjJt2QQ== 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=TFKa3zHA; 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 87987606A322; Fri, 4 Dec 2026 11:35:32 +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=TFKa3zHA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 010251F00897; Fri, 4 Dec 2026 11:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384132; bh=yTUcNaqJqPLbmAMKpa0br1oukxu7L6ZRQejhERdd04c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TFKa3zHAxG9Tnv0jfx/1HCKNwH4jSauTeL92tF02AWzJOiOu92IcQUcft+rXj6p9K QUU+8lXlKOZDcy8ZBRFLkEbuLKsLvN1uPUJdKbQAMFGlOLmAGupf3S7xMEvcMjf+ZV pQqr7XWwqIe6bkgo/DMN4JT6owiXPXKl81RY1WNc= 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 511/555] rose: say when we are busy, and leave the busy state on read Date: Fri, 4 Dec 2026 19:09:14 +0900 Message-ID: <20261204100628.301093943@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: patches@lists.linux.dev 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 ROSE_COND_OWN_RX_BUSY is set when the receive buffer is more than half full, but the peer only learns it with the next acknowledgment, which is held back for up to the hold-back time (5 s by default). Meanwhile it keeps sending, the buffer overflows and the call is reset. The busy state is then only left by the heartbeat, up to five seconds after the application has read its data. Acknowledge at once when we have just become busy, so that the peer gets RNR before the buffer overflows. Add rose_check_rx_busy(), which leaves the busy state once the buffer is half empty and sends RR, as the heartbeat does, and call it from the heartbeat and from rose_recvmsg() after a message is consumed, with the socket locked so that it does not race with the receive path. Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A calls B and writes twelve messages of 200 bytes; B has a minimal receive buffer and starts reading after 20 s. before: messages 1-3 read at 20.0 s, the others at 23.5 s after: the twelve messages read between 20.0 s and 20.1 s 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 09b0e6261615f80f35e4df588cf18134990d21d8) Signed-off-by: Sasha Levin --- include/net/rose.h | 1 + net/rose/af_rose.c | 5 +++++ net/rose/rose_in.c | 7 +++++-- net/rose/rose_out.c | 21 +++++++++++++++++++++ net/rose/rose_timer.c | 10 +--------- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/include/net/rose.h b/include/net/rose.h index 30b0809dd0a65..b60d2dd5d2995 100644 --- a/include/net/rose.h +++ b/include/net/rose.h @@ -253,6 +253,7 @@ int rose_loopback_queue(struct sk_buff *, struct rose_neigh *); /* rose_out.c */ void rose_kick(struct sock *); void rose_enquiry_response(struct sock *); +void rose_check_rx_busy(struct sock *sk); /* rose_route.c */ extern struct rose_neigh *rose_loopback_neigh; diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 2a610cf8425af..48ac6fd660316 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -1490,6 +1490,11 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, skb_free_datagram(sk, skb); + /* Room was made: leave the busy state now if we can */ + lock_sock(sk); + rose_check_rx_busy(sk); + release_sock(sk); + return copied; } diff --git a/net/rose/rose_in.c b/net/rose/rose_in.c index 0bb801c3142c8..c6c4e92016ae7 100644 --- a/net/rose/rose_in.c +++ b/net/rose/rose_in.c @@ -224,9 +224,12 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety } /* * If the window is full, ack the frame, else start the - * acknowledge hold back timer. + * acknowledge hold back timer. When we have just become busy, + * send RNR at once, so that the peer stops before our + * receive buffer overflows. */ - if (((rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == rose->vr) { + if (((rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == rose->vr || + (rose->condition & ROSE_COND_OWN_RX_BUSY)) { rose->condition &= ~ROSE_COND_ACK_PENDING; rose_stop_timer(sk); rose_enquiry_response(sk); diff --git a/net/rose/rose_out.c b/net/rose/rose_out.c index 6672fc65a7651..6a8881116bf31 100644 --- a/net/rose/rose_out.c +++ b/net/rose/rose_out.c @@ -121,3 +121,24 @@ void rose_enquiry_response(struct sock *sk) rose_stop_timer(sk); } + +/* + * Leave the busy state as soon as the application has made room in the + * receive buffer, instead of waiting for the next heartbeat. Called with + * the socket locked. + */ +void rose_check_rx_busy(struct sock *sk) +{ + struct rose_sock *rose = rose_sk(sk); + + if (rose->state != ROSE_STATE_3 || + !(rose->condition & ROSE_COND_OWN_RX_BUSY) || + atomic_read(&sk->sk_rmem_alloc) >= (sk->sk_rcvbuf / 2)) + return; + + rose->condition &= ~ROSE_COND_OWN_RX_BUSY; + rose->condition &= ~ROSE_COND_ACK_PENDING; + rose->vl = rose->vr; + rose_write_internal(sk, ROSE_RR); + rose_stop_timer(sk); /* HB */ +} diff --git a/net/rose/rose_timer.c b/net/rose/rose_timer.c index 5ba0c89e4ee1b..9f28cbf8c9a8a 100644 --- a/net/rose/rose_timer.c +++ b/net/rose/rose_timer.c @@ -218,15 +218,7 @@ static void rose_heartbeat_expiry(struct timer_list *t) /* * Check for the state of the receive buffer. */ - if (atomic_read(&sk->sk_rmem_alloc) < (sk->sk_rcvbuf / 2) && - (rose->condition & ROSE_COND_OWN_RX_BUSY)) { - rose->condition &= ~ROSE_COND_OWN_RX_BUSY; - rose->condition &= ~ROSE_COND_ACK_PENDING; - rose->vl = rose->vr; - rose_write_internal(sk, ROSE_RR); - rose_stop_timer(sk); /* HB */ - break; - } + rose_check_rx_busy(sk); break; } -- 2.53.0