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=1796387878; b=4qKck12c08wwZIbODUjK1KylXp+03MXpooNY607vMChGxmpmT0wEDM+WRrtNuqQH+OzN F9KagTbXOWh4mazcAQYg2iqAu65wxZcSpKMGeRd+eh+Ngzdqv8DSD445NecBvEIRz3z+b G0vEBf7Y3D0O6niHz538QClWbQDJETVLflFY2Fagb9JV0SlGFlpQyMxVt4ACQnyU1Ar61 lKFB8SBM0tKEIJ8q2nZJuYSFo3CV16sJe6L/1egEuGdEwYhLV2Vo0jqivgKas3wLIG8EV 1GN6JGNofBz+zi3kc4OUbqDAN08nnXrNT7loap5X7E1b3/MpuN3qke8Nhc13dNtsjaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387878; 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=vRGHKM2yZHSlvW4hSGHTNpuehUQSqMoNpqSRWmPfCq4=; b=22Tlz4sG8m1IRdaqDGpNluGwDJEBLh6qwSi0cLX7+LHBoNtskTMVDOmPFDTDl/yAK9oB ouOxfttbsxi7CzC4Ztzh9Xa9bi2ft61aPmXZkWg/ml02b1joQMzYYlxn6iWF03AkPkema uX692V6lvnmPymIYw8bP82O9oj6JUoltjF5+vzVL65QkwI7qh6O/mPHrmqpfkw0eCdEga 7F5gzDZZfVY2aXdwRw3yDTxbJPdUTTeStoualsImOnmoP9DZSRexb4vnGLcsqmQD4S9r5 xXwws9IZdegVsh2l2hATvm+8qwG4Zo4y6f4BlQldPmTva8MhV1uADz/+n1j3bEoOM3A== 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=bUosszrh; 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 342DB606A322; Fri, 4 Dec 2026 12:37:57 +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=bUosszrh Received: by smtp.kernel.org (Postfix) with ESMTPSA id 322821F000CE; Fri, 4 Dec 2026 12:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387877; bh=vRGHKM2yZHSlvW4hSGHTNpuehUQSqMoNpqSRWmPfCq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bUosszrhzfxh0EGpW5i0g+8Dc5ATE9StcopbIjBGoviHhwX79lb8lTsGKUjsRwL5p atkLbQFx3Q+yiugOVX2p/l0swCFY3Ojix2yW4TycgcyHGw9EzypxS8J/Gj/z078q2G riRfC2qjNr7NJodPl/MbPYdYYt0yss2f/jRqEbEQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Howells , Marc Dionne , Jeffrey Altman , Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, Sasha Levin Subject: [PATCH 6.1 0394/1059] rxrpc: Fix sendmsg length Date: Fri, 4 Dec 2026 18:58:45 +0900 Message-ID: <20261204100654.518450382@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 ef369cacbd524931199078427ae152c63a826189 ] rxrpc_send_data() is given two data lengths (len and msg->msg_iter.count) and is inconsistent about how it uses them. Fix this by using len in preference to msg->msg_iter.count. Also limit the amount copied to either len or msg->msg_iter.count, whichever is smaller. Note that, currently, all the callers have len and msg->msg_iter.count the same and so the problem won't occur. This is a prerequisite for another patch that fixes the handling of encryption errors. Fixes: 382d7974de31 ("RxRPC: Use iov_iter_count() in rxrpc_send_data() instead of the len argument") 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 Link: https://patch.msgid.link/20261006133011.531806-8-dhowells@redhat.com Signed-off-by: Paolo Abeni [ sashal: Adapted the fix to the older skb-based send code, using len in the buffer sizing, copy clamp, full-packet test, last-packet flag and rxrpc_queue_packet() argument instead of txb-based helpers. ] Signed-off-by: Sasha Levin --- net/rxrpc/sendmsg.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 4b5ee70433039..a4ad0dc9f4367 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -318,9 +318,9 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ret = -EMSGSIZE; if (call->tx_total_len != -1) { - if (len - copied > call->tx_total_len) + if (len > call->tx_total_len) goto maybe_error; - if (!more && len - copied != call->tx_total_len) + if (!more && len != call->tx_total_len) goto maybe_error; } @@ -343,7 +343,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, * the security header is going to be in the padded * region (enc blocksize), but the trailer is not. */ - remain = more ? INT_MAX : msg_data_left(msg); + remain = more ? INT_MAX : len; ret = call->conn->security->how_much_data(call, remain, &bufsize, &chunk, &offset); if (ret < 0) @@ -387,9 +387,11 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, sp = rxrpc_skb(skb); /* append next segment of data to the current buffer */ - if (msg_data_left(msg) > 0) { + if (len > 0) { int copy = skb_tailroom(skb); ASSERTCMP(copy, >, 0); + if (copy > len) + copy = len; if (copy > msg_data_left(msg)) copy = msg_data_left(msg); if (copy > sp->remain) @@ -403,6 +405,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, sp->remain -= copy; skb->mark += copy; copied += copy; + len -= copy; if (call->tx_total_len != -1) call->tx_total_len -= copy; } @@ -414,7 +417,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, /* add the packet to the send queue if it's now full */ if (sp->remain <= 0 || - (msg_data_left(msg) == 0 && !more)) { + (len == 0 && !more)) { struct rxrpc_connection *conn = call->conn; uint32_t seq; @@ -424,7 +427,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, sp->hdr._rsvd = 0; sp->hdr.flags = conn->out_clientflag; - if (msg_data_left(msg) == 0 && !more) + if (len == 0 && !more) sp->hdr.flags |= RXRPC_LAST_PACKET; else if (call->tx_top - call->tx_hard_ack < call->tx_winsize) @@ -435,12 +438,12 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, goto out_unlock; ret = rxrpc_queue_packet(rx, call, skb, - !msg_data_left(msg) && !more, + len == 0 && !more, notify_end_tx); /* Should check for failure here */ call->tx_pending = NULL; } - } while (msg_data_left(msg) > 0); + } while (len > 0 && msg_data_left(msg) > 0); success: ret = copied; -- 2.53.0