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=1796385192; b=Xe069qEg5auFnjLtFQwDvY+tWgDQ49b8cJ0SLEWcskFdl2N/HsLMcPYJO2XSsk5UVZvy abaR7w1dRQXzs6yJgqynOdADhYCqx9TfO6pcX7swi8RYIeIaWzGSvqQjjEw5m5v5lzsNv pWxTJLBKNSvJIP58xMubHHl+/aPZMoTyUr+HjKU4zitXTfE8qcMFl9JS76oVCtsgG7shN kLlhO5vM3GqgilNx43y01Tp3h0lGTSZmFKuwIsrTMI2LyBwl5FYBndSOF/r9qG+gzzALL s+uHpCgGC+5lpV/gbXXMJ9hvDLDbW0EAorqx5cXApF1dt9rPSMr7WB8vury2S2Iq6xA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385192; 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=a8iYAYftl6sS9AYSX8b+3i5W5ZyXLn3UfkeDVJh04hA=; b=t+6Te7RyAdWrKYJWwLTHywp1HlYCDhTNWX5WHMqb+aC6XYRmNr1xnv8YNrak4tczzDJc GEYgeE2MuiIoqAEqYF73WV8vBf4D4r/78tXCr6iKCrrMRE0Fl3sZpj6tMyQY/S0zorhXp MBxnOIwck7VWJAVm8rQllSALDzNt0Db5bHyWAHm9YcuFpdEwXoW/3JNyLSO22gjNTeIjf MlYoFsYegPm/lQJ9S9nJmUrY2p2P26vjuhmuLVbut437UHS/pNbf4gUU1Jl2zzz5oo3cu AF/3nNmOQ8LcfBp8WEkY9TtfO8GOmcWiEK/Jov3XKz6CQV/CyYctzpLcH57xt0KNy0w== 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=B+70vkQg; 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 AFB19606A32C; Fri, 4 Dec 2026 11:53: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=B+70vkQg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 025ED1F000C2; Fri, 4 Dec 2026 11:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385192; bh=a8iYAYftl6sS9AYSX8b+3i5W5ZyXLn3UfkeDVJh04hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=B+70vkQglEn8MTl2HoQNCuasHwsiCUuNwuSSIVdJP5R90KE2kF1WECoPav9mpDW02 iv1zSbVPUJT5bXnyhnTg2d1fCqybRs4k6W1YZzuSNf/91S0jmho931cvn481dZ+irz FFkStmBx7oIrXpKHo7Fbbq0swQA80pMGVaOMePVI= 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.6 0416/1167] rxrpc: Fix sendmsg length Date: Fri, 4 Dec 2026 18:57:23 +0900 Message-ID: <20261204100712.858819655@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 hunks to this tree's older allocation path and flag handling (how_much_data(), wire.flags, min_t), keeping the same length-counter logic. ] Signed-off-by: Sasha Levin --- net/rxrpc/sendmsg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c index 7ba5a6de3e4e1..dccbbbcc77361 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -324,9 +324,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; } @@ -345,7 +345,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) @@ -371,8 +371,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, _debug("append"); /* append next segment of data to the current buffer */ - if (msg_data_left(msg) > 0) { - size_t copy = min_t(size_t, txb->space, msg_data_left(msg)); + if (len > 0) { + size_t copy = min3(txb->space, len, msg_data_left(msg)); _debug("add %zu", copy); if (!copy_from_iter_full(txb->data + txb->offset, copy, @@ -383,6 +383,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, txb->len += copy; txb->offset += copy; copied += copy; + len -= copy; if (call->tx_total_len != -1) call->tx_total_len -= copy; } @@ -394,8 +395,8 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, /* add the packet to the send queue if it's now full */ if (!txb->space || - (msg_data_left(msg) == 0 && !more)) { - if (msg_data_left(msg) == 0 && !more) { + (len == 0 && !more)) { + if (len == 0 && !more) { txb->wire.flags |= RXRPC_LAST_PACKET; __set_bit(RXRPC_TXBUF_LAST, &txb->flags); } @@ -410,7 +411,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, rxrpc_queue_packet(rx, call, txb, notify_end_tx); call->tx_pending = NULL; } - } while (msg_data_left(msg) > 0); + } while (len > 0 && msg_data_left(msg) > 0); success: ret = copied; -- 2.53.0