From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49C0B49480F for ; Mon, 7 Sep 2026 11:38:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788781105; cv=none; b=GrjVFv/B+lM3fBcse7SoeRM9cDR99kddxbO9hnoSLvO6esmve/jE0MDUpbAN0jdMpfGIvaKDn/5IuyqpAT533cRMbW6JmKjhP/Rhiadwu22p/rr2/9IUAR+HCROPOIwgNeZmL2oTHc3M93yS++oidpjqWZRhIbbETXlIRAJgi0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788781105; c=relaxed/simple; bh=Hs3L2JWkKOYuDzhkdd6k2DfZ0N5LOqcZOqLU7BkyZwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sbHRtmbVBePdBTrQvYBqH6kwAT4UyYDuaFR6EPDJpQ6SdmezN3NEyWboZ9xlbIdaj6ZUcyWsxL0Tl0g5Y+BUUb+y4z3pUubRsDZnxh8lduu4QZVjHG7RP4dhHB/CSDFfpNsszirL/p7qmjSzbP04lijdy11VgtKMdxw1csibjwQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dZRzGg/9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dZRzGg/9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788781103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CXhFZ1mABywDeC+BzGLKbgEtDrREzsxnWbEq/vxDP4Q=; b=dZRzGg/9SxHabNPxhVV6fA/cgCbCkLEsFqp8kJ0KO4lv+5J0VAKXqG/qTgWKkQIS2qlrXL nTW68PTtAjEtbOK0tUPiHszsVEd388/EibnmmywcrBhpj52wyBqmYjpqL3N3GOpLBuL2iw Jo46mlYRUlwgmqvWEh/XbhSHmGG5qd8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-347-M1QlhbPePeKDOJfpQBwD7g-1; Mon, 07 Sep 2026 07:38:20 -0400 X-MC-Unique: M1QlhbPePeKDOJfpQBwD7g-1 X-Mimecast-MFC-AGG-ID: M1QlhbPePeKDOJfpQBwD7g_1788781098 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6728B1955DE1; Mon, 7 Sep 2026 11:38:18 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.158]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1FF781956042; Mon, 7 Sep 2026 11:38:14 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Marc Dionne , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, Jeffrey Altman , stable@vger.kernel.org Subject: [PATCH net v9 05/14] rxrpc: Fix sendmsg length Date: Mon, 7 Sep 2026 12:37:32 +0100 Message-ID: <20260907113743.1453210-6-dhowells@redhat.com> In-Reply-To: <20260907113743.1453210-1-dhowells@redhat.com> References: <20260907113743.1453210-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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. 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 cc: stable@vger.kernel.org --- 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 1d66e9808162..565799548102 100644 --- a/net/rxrpc/sendmsg.c +++ b/net/rxrpc/sendmsg.c @@ -379,9 +379,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; } @@ -405,7 +405,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; txb = call->conn->security->alloc_txbuf(call, remain, sk->sk_allocation); if (!txb) { ret = -ENOMEM; @@ -416,8 +416,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 = umin(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, @@ -428,6 +428,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; } @@ -439,8 +440,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->flags |= RXRPC_LAST_PACKET; ret = call->security->secure_packet(call, txb); @@ -449,7 +450,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, rxrpc_queue_packet(rx, call, txb, notify_end_tx); txb = NULL; } - } while (msg_data_left(msg) > 0); + } while (len > 0 && msg_data_left(msg) > 0); success: ret = copied;