Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4727846DFF9; Tue, 21 Jul 2026 17:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655179; cv=none; b=b47Bbm8KFPG7fjXF0LwL6ddpak3/Wru0WBANSkkQWQwsEqQPXTzLElLmI9iemNA3sNobJBL1oeGuQy84c/1nxn/UJQo3xvBWxRav022gbrSXkcKVPXX6NLjiTNBDqI/vK8Eiuf+zfht7zGJBs2cvLgrbWI0PTgdVVWR3butl7n4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784655179; c=relaxed/simple; bh=ptlm7Dcqq99EBk/J2ZwOryteaykcU7yxdW0wxX9ii1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qiPwBqMOtCKXOFpxHaAvNaX4i4H6k0Y14HIyq6ViLTDDX4MAVLKBUikx0gwgZWPoS0x9iTsqH5snMhIsPacBLL/EXKG0Z4oHCxBzE6JF36yGCfGa4ndrTw35IHUagPXN6cwl3Sjepp6kQ8beLsfyodrOCgAA3XBswJNj2kszSx8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=d+wmZ28B; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="d+wmZ28B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F0C11F00A3D; Tue, 21 Jul 2026 17:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784655177; bh=3iJ136ryJoezgIzTSvEwWy1V6M6sGs27m9gVLvcqrGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=d+wmZ28BTIVMrz8cdWDSOv50puOXGB3iNCI3RGvVkOn+qa+S8WPq4r+k4nqmAD6sB t40YvL0gGWCzwf+LyOXQpAUuuPcQ9hZL24sVplbuIV9e/bO9lkEJMs9g5IyAvlXz56 p3G1dvyxdUYhJTIGxCsGZj6WjTrrFv1J2Cm0Qld4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Aaron Esau , Yiming Qian , Sabrina Dubroca , Steffen Klassert Subject: [PATCH 7.1 1941/2077] espintcp: use sk_msg_free_partial to fix partial send Date: Tue, 21 Jul 2026 17:26:54 +0200 Message-ID: <20260721152638.489356371@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sabrina Dubroca commit 007800408002d871f5699bdb944f985896730b8f upstream. sk_msg_free_partial() ensures consistency of the skmsg at every iteration, without having to manually handle uncharges and offsets. This simplifies the code, and fixes some bugs in skmsg accounting when we don't send the full contents. Cc: stable@vger.kernel.org Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)") Reported-by: Aaron Esau Reported-by: Yiming Qian Signed-off-by: Sabrina Dubroca Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/xfrm/espintcp.c | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) --- a/net/xfrm/espintcp.c +++ b/net/xfrm/espintcp.c @@ -212,43 +212,23 @@ static int espintcp_sendskmsg_locked(str struct sk_msg *skmsg = &emsg->skmsg; bool more = flags & MSG_MORE; struct scatterlist *sg; - int done = 0; int ret; - sg = &skmsg->sg.data[skmsg->sg.start]; do { struct bio_vec bvec; - size_t size = sg->length - emsg->offset; - int offset = sg->offset + emsg->offset; - struct page *p; - - emsg->offset = 0; + sg = &skmsg->sg.data[skmsg->sg.start]; if (sg_is_last(sg) && !more) msghdr.msg_flags &= ~MSG_MORE; - p = sg_page(sg); -retry: - bvec_set_page(&bvec, p, size, offset); - iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, size); - ret = tcp_sendmsg_locked(sk, &msghdr, size); - if (ret < 0) { - emsg->offset = offset - sg->offset; - skmsg->sg.start += done; + bvec_set_page(&bvec, sg_page(sg), sg->length, sg->offset); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, sg->length); + ret = tcp_sendmsg_locked(sk, &msghdr, sg->length); + if (ret < 0) return ret; - } - if (ret != size) { - offset += ret; - size -= ret; - goto retry; - } - - done++; - put_page(p); - sk_mem_uncharge(sk, sg->length); - sg = sg_next(sg); - } while (sg); + sk_msg_free_partial(sk, skmsg, ret); + } while (skmsg->sg.size); memset(emsg, 0, sizeof(*emsg));