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=1795053432; b=PN1ckKflB5eUBzZsrTPiOhm4LB0d1ymJ3gAE57u9tXWYKUyTmDp2+u1YdhS3VErzCLAq V+XW7lW5jINV7OsIEkt16TDoPsWPI+sMzkL59gKAGBUZyMmxtCKeE7BfEAU6BCW0Ko0bB DN+51VaOa4bU3lb1N1E0w1KTwpG5MxwEk1MGNwR9j29YBDncnw1Qn/wht3rYbYFLmbyhe OShw46V/r5KmyCLNtfpniyzgEJ1t+qBz/GBrRrPg0YiaNf2tYFq58hKgf3+KBIjPui/p7 raedFXGApIwBZbB0AevzQGUmeKlG7oPu4uhAXzUpKhq4igeWvoF2pvRSKsSW+Hn2WRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795053432; 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=dvLGERbRvlTuMrykVEX5O3vXVdTMpSnY5pW3vUXnJtY=; b=pvLBHA1tKOuBX7fYrYwLBRw/OurxQLXZaWk1pTn9d61iyro1zviiL9cESczxxAfVTkIy jyla8WFWvPYDiCL8k0JlFHiIwP1JAEXRpilLQ25L0vEP7raogVbDV9kc0THtFfkR1F5IC Ctl+vis/9dcjsG1KAEhdhGVlnSJfpHGtT/OqGfCRiH/IXH5PEH7uiCb4Q/+lrnJf9kv2F pNDJbDuK12KyYf76oEc6Sin9Sfiw9wFP04Ne+KngXNOl8Lq+FuPxt3diMz4ZJUWDsW7m+ R6hHfFQTCqpra9vNGvFG+r0rNBfLf3onYlv6URxru6/858MzzbBtzYIE50GNlY7PNOQ== 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=2gZaKOap; 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 9B95F606A31C; Thu, 19 Nov 2026 01:57:12 +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=2gZaKOap Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2A7D1F000C4; Thu, 19 Nov 2026 01:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795053432; bh=dvLGERbRvlTuMrykVEX5O3vXVdTMpSnY5pW3vUXnJtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2gZaKOaph6JCJyebbrS4x17rrDgEqsbiuzLv7o9SQUt39NeeMziTcqzxxcJr2Ybda oypc/bMscY7lwBYSyigJxu2n3lm7jUyMykBM/FfGTSA6tAJEle4NzaaWJTQJfWbWvj PisPg7XhdkP0BmxlbRKbognHLPqyh+BnD1NETaLo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryam Vargas , Dust Li , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 0918/2214] net/smc: dont spin in smc_rx_recvmsg() while a pipe holds spliced data Date: Wed, 18 Nov 2026 15:43:14 +0100 Message-ID: <20261118150049.068036150@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas [ Upstream commit 8288ba942cfd20621c05e16978b7c3da91513ae1 ] While bytes spliced off the RMB are still in a pipe, recvmsg() waits for the pipe to release them before it copies the data behind them. The path to that wait skips the timeout and signal checks, and smc_rx_wait() returns at once on RCV_SHUTDOWN. With a signal pending, after SHUT_RD, or once the peer closes or shuts down writing, recvmsg() spins on a CPU until the pipe is drained, and SIGKILL cannot stop it. MSG_DONTWAIT and an expired SO_RCVTIMEO wait there too instead of returning -EAGAIN. Check the timeout and signals before that wait, and end it when the pipe releases the data or the connection is killed, not on RCV_SHUTDOWN. A zero-length read returns 0 without waiting for the pipe; a non-blocking one returns -EAGAIN while poll() still reports the socket readable (splice() can still take those bytes). The wait sets SOCKWQ_ASYNC_WAITDATA like smc_rx_wait(), so a byte arriving behind the pipe raises no SIGIO on a reader already asleep for it, and a full barrier orders its wait queue entry before its read of splice_pending, so no wake is lost. Fixes: 9014db202cb7 ("smc: add support for splice()") Cc: stable@vger.kernel.org Signed-off-by: Bryam Vargas Reviewed-by: Dust Li Link: https://patch.msgid.link/20261029-b4-disp-da7f8e6a-v2-1-9052904adf72@proton.me Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/smc/smc_rx.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c index 33b5bcafdec7d..b74b992aff4b1 100644 --- a/net/smc/smc_rx.c +++ b/net/smc/smc_rx.c @@ -227,6 +227,27 @@ int smc_rx_wait(struct smc_sock *smc, long *timeo, size_t peeked, return rc; } +/* Wait for the pipe to release the spliced data. Unlike smc_rx_wait() + * it does not end on shutdown or sk_err, the data is already in the + * RMB; smc_conn_kill() wakes it and the caller checks conn->killed. + */ +static void smc_rx_wait_splice(struct smc_sock *smc, long *timeo) +{ + DEFINE_WAIT_FUNC(wait, woken_wake_function); + struct smc_connection *conn = &smc->conn; + struct sock *sk = &smc->sk; + + sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk); + add_wait_queue(sk_sleep(sk), &wait); + /* pairs with the smp_mb() in wq_has_sleeper(): the release drops + * splice_pending, then looks for a sleeper + */ + smp_mb(); + sk_wait_event(sk, timeo, !atomic_read(&conn->splice_pending), &wait); + remove_wait_queue(sk_sleep(sk), &wait); + sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk); +} + static int smc_rx_recv_urg(struct smc_sock *smc, struct msghdr *msg, int len, int flags) { @@ -384,7 +405,23 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg, /* could be just 1 byte, even after waiting on data above */ readable = smc_rx_data_available(conn, peeked_bytes); splbytes = atomic_read(&conn->splice_pending); - if (!readable || (msg && splbytes)) { + if (msg && splbytes) { + /* a pipe holds bytes ahead of these; the copy path + * skips the timeout and signal checks + */ + if (!read_remaining) + break; + if (!timeo || signal_pending(current)) { + if (!read_done) + read_done = timeo ? + sock_intr_errno(timeo) : + -EAGAIN; + break; + } + smc_rx_wait_splice(smc, &timeo); + continue; + } + if (!readable) { if (splbytes) func = smc_rx_data_available_and_no_splice_pend; else -- 2.53.0