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=1796387384; b=vZBrzJLztNGaBcd3kjDrwcl6Hve/9P7Dzit3o9CeH55zLFwkRDby9/g4mXdAYG99ZAnh suOTe10D7ZC9JavUGH3XK0MAA8htmvCh52HSVKqRIG32FkRUSYqZsN9LnPv3t1vda3aih VOgTJGx23+Fzu1tHHjCIBJpgEb4V30CWLAHcMm0BXrx51cIrNrUZAgmQE033JQiD9Jpxv RyWSyVZKB1wf4W2xhvqSghB8ew9I/0W71c6v2/dpqwoY8yd0XovMF+RckINSHsSKllUVC zBMVsrU/PN70pQrUuZcKTXc2VUQXzdDa41buulnESNOKh5v9te+0tlRqmPI+qJye6rA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387384; 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=0vMkuJziWYMt47qyo0lL7OrUZrE0Tc2IK1Nu7J8Msqg=; b=sbzAh1Aa+vSlBtZ+7kobNwr4k1D9g6c58mQHyBHiAFzFbv0mHttjilcJgEI0WU74sA1S R1eF/o0rvTErfmYSMFacMRaWvcEoEbCTFQ7Z9TwHNbYa7BN7rqfRg3oJTp7l2K+Xqd/JS geS2Lx9RlPUI/zcFROUASXxqNXDazBOe5uAsABu/AH51KxcG0NhNEVh3Mn5q39hxVvcsJ WmIStYst7vjzlWbv1fVsXXqX2aUYhUUbqmr1jUA6rnWNPdsUUUAEnC7MQIaGHwYlC4Oic o35pb+D89lxyizlzQomohpH/aQSd+V+LvhpS7+nI0OsizTFSU4IYUT0VINUKdviAWWg== 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=fHuWvN6s; 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 3B4C3606A32C; Fri, 4 Dec 2026 12:29:44 +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=fHuWvN6s Received: by smtp.kernel.org (Postfix) with ESMTPSA id 719D51F000C2; Fri, 4 Dec 2026 12:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387383; bh=0vMkuJziWYMt47qyo0lL7OrUZrE0Tc2IK1Nu7J8Msqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fHuWvN6sstOOAK78C3ZYo/3uvyedEszpH6037nG2XKc04MYcO75KYuxiDj8zowmuT ImtMVR1AuFWjHleK11GvlOSKgLcImNClCTIRkpgy3nm7N2WpO6xVdbBiQuhI1aVRF9 vB8ky72PeVIhi4nZ/OEFumphfBn2IxM/u9Rtb2Vg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Laight , David Howells , Marc Dionne , Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, Sasha Levin Subject: [PATCH 6.1 0221/1059] rxrpc: Fix lack of short-send handling in rxrpc_kernel_send_data() Date: Fri, 4 Dec 2026 18:55:52 +0900 Message-ID: <20261204100649.998446095@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Howells [ Upstream commit af208f36ae22440cf6011a43cb3064fd525d85b4 ] Fix rxrpc_kernel_send_data() to loop around if it detects a short send. David Laight suggested doing it here rather than wrapping all the calls in loops. Further, remove the len argument and use the iterator count instead and return 0 on success, not the amount copied. Note this is also a prerequisite for changing the way rxrpc_send_data() works to return a short send rather than an error if some data was buffered. Fixes: 651350d10f93 ("[AF_RXRPC]: Add an interface to the AF_RXRPC module for the AFS filesystem to use") Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260824091645.415423-1-dhowells%40redhat.com Suggested-by: David Laight Signed-off-by: David Howells cc: Marc Dionne cc: Eric Dumazet cc: "David S. Miller" cc: Jakub Kicinski cc: Paolo Abeni cc: Simon Horman cc: linux-afs@lists.infradead.org cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261006133011.531806-5-dhowells@redhat.com Signed-off-by: Paolo Abeni [ sashal: Dropped the len argument from the rxrpc_kernel_send_data() callers, omitted the rxperf.c hunk since that file doesn't exist here, and added an -EIO return when a completed call has unsent data. ] Signed-off-by: Sasha Levin --- Documentation/networking/rxrpc.rst | 8 ++-- fs/afs/rxrpc.c | 8 ++-- include/net/af_rxrpc.h | 3 +- net/rxrpc/sendmsg.c | 62 ++++++++++++++++++------------ 4 files changed, 47 insertions(+), 34 deletions(-) diff --git a/Documentation/networking/rxrpc.rst b/Documentation/networking/rxrpc.rst index 39494a6ea739c..3b4fef0ce7428 100644 --- a/Documentation/networking/rxrpc.rst +++ b/Documentation/networking/rxrpc.rst @@ -866,7 +866,6 @@ The kernel interface functions are as follows: int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, struct msghdr *msg, - size_t len, rxrpc_notify_end_tx_t notify_end_rx); This is used to supply either the request part of a client call or the @@ -875,14 +874,17 @@ The kernel interface functions are as follows: exclusively to in-kernel virtual addresses. msg.msg_flags may be given MSG_MORE if there will be subsequent data sends for this call. - The msg must not specify a destination address, control data or any flags - other than MSG_MORE. len is the total amount of data to transmit. + msg must not specify a destination address, control data or any flags + other than MSG_MORE or MSG_WAITALL. notify_end_rx can be NULL or it can be used to specify a function to be called when the call changes state to end the Tx phase. This function is called with the call-state spinlock held to prevent any reply or final ACK from being delivered first. + It returns 0 if all the provided data has been buffered and a negative + error code on failure. + (#) Receive data from a call:: int rxrpc_kernel_recv_data(struct socket *sock, diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c index 501a98583e810..d60f0b573dd23 100644 --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -404,8 +404,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) msg.msg_controllen = 0; msg.msg_flags = MSG_WAITALL | (call->write_iter ? MSG_MORE : 0); - ret = rxrpc_kernel_send_data(call->net->socket, rxcall, - &msg, call->request_size, + ret = rxrpc_kernel_send_data(call->net->socket, rxcall, &msg, afs_notify_end_request_tx); if (ret < 0) goto error_do_abort; @@ -417,7 +416,6 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp) ret = rxrpc_kernel_send_data(call->net->socket, call->rxcall, &msg, - iov_iter_count(&msg.msg_iter), afs_notify_end_request_tx); *call->write_iter = msg.msg_iter; @@ -869,7 +867,7 @@ void afs_send_empty_reply(struct afs_call *call) msg.msg_controllen = 0; msg.msg_flags = 0; - ret = rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, 0, + ret = rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, afs_notify_end_reply_tx); if (ret < 0) { rxrpc_kernel_abort_call(net->socket, call->rxcall, @@ -901,7 +899,7 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len) msg.msg_controllen = 0; msg.msg_flags = 0; - n = rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, len, + n = rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, afs_notify_end_reply_tx); if (n >= 0) { /* Success */ diff --git a/include/net/af_rxrpc.h b/include/net/af_rxrpc.h index b69ca695935ce..70ea6f844d0ef 100644 --- a/include/net/af_rxrpc.h +++ b/include/net/af_rxrpc.h @@ -50,8 +50,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *, enum rxrpc_interruptibility, unsigned int); int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *, - struct msghdr *, size_t, - rxrpc_notify_end_tx_t); + struct msghdr *, rxrpc_notify_end_tx_t); int rxrpc_kernel_recv_data(struct socket *, struct rxrpc_call *, struct iov_iter *, size_t *, bool, u32 *, u16 *); bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *, diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 28cd9fe93844e..4b5ee70433039 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -781,7 +781,6 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) * @sock: The socket the call is on * @call: The call to send data through * @msg: The data to send - * @len: The amount of data to send * @notify_end_tx: Notification that the last packet is queued. * * Allow a kernel service to send data on a call. The call must be in an state @@ -790,8 +789,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) * more data to come, otherwise this data will end the transmission phase. */ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, - struct msghdr *msg, size_t len, - rxrpc_notify_end_tx_t notify_end_tx) + struct msghdr *msg, rxrpc_notify_end_tx_t notify_end_tx) { int ret; @@ -800,31 +798,47 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, ASSERTCMP(msg->msg_name, ==, NULL); ASSERTCMP(msg->msg_control, ==, NULL); - mutex_lock(&call->user_mutex); + for (;;) { + mutex_lock(&call->user_mutex); - _debug("CALL %d USR %lx ST %d on CONN %p", - call->debug_id, call->user_call_ID, call->state, call->conn); - - switch (READ_ONCE(call->state)) { - case RXRPC_CALL_CLIENT_SEND_REQUEST: - case RXRPC_CALL_SERVER_ACK_REQUEST: - case RXRPC_CALL_SERVER_SEND_REPLY: - ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len, - notify_end_tx); - goto out; - case RXRPC_CALL_COMPLETE: - read_lock_bh(&call->state_lock); - ret = call->error; - read_unlock_bh(&call->state_lock); - break; - default: - /* Request phase complete for this client call */ - trace_rxrpc_rx_eproto(call, 0, tracepoint_string("late_send")); - ret = -EPROTO; + _debug("CALL %d USR %lx ST %d on CONN %p", + call->debug_id, call->user_call_ID, call->state, call->conn); + + switch (READ_ONCE(call->state)) { + case RXRPC_CALL_CLIENT_SEND_REQUEST: + case RXRPC_CALL_SERVER_ACK_REQUEST: + case RXRPC_CALL_SERVER_SEND_REPLY: + ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, + msg_data_left(msg), notify_end_tx); + if (ret < 0) + goto out; + if (msg_data_left(msg) == 0) { + ret = 0; + goto out; + } + if (ret == 0) { + ret = -EIO; + goto out; + } + continue; + case RXRPC_CALL_COMPLETE: + read_lock_bh(&call->state_lock); + ret = call->error; + read_unlock_bh(&call->state_lock); + if (!ret && msg_data_left(msg)) + ret = -EIO; + break; + default: + /* Request phase complete for this client call */ + trace_rxrpc_rx_eproto(call, 0, tracepoint_string("late_send")); + ret = -EPROTO; + break; + } + + mutex_unlock(&call->user_mutex); break; } - mutex_unlock(&call->user_mutex); out: _leave(" = %d", ret); return ret; -- 2.53.0