From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A018D78B61; Tue, 27 Feb 2024 14:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709043442; cv=none; b=eXOR8FTThgFW93o2dcxrUlOeo3z99YLLYxM1nMTCCisLwzyeHZnn5qGz7dTWf5IssU0S+2a4sZlKmWJ3/4KLYg2HvHJ+ZXkmEDJg/y45KW6raioStOGmqA1odjU8BApBQTX1tkPABjmM0YjlaWfxhOp2CBptsXqojNDqUfISndA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709043442; c=relaxed/simple; bh=Mfom+2Jx6JXpwQk71qrE95CVDBkTSinzAVRXLt7qCFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WN3w4om5HGs91Yk63p4TzptU5kLFzhowGxHmIIB9fp+UAKpKu/zu7QrP6O+MVvSjz/5r3C4eMxNbSsV8Y+15diVqJQQ7SWCGNYCEzevtHUUXDxeXJ0+HUfMSqBn79kHJRVhe9os1RwsaqDfALAeCafPIdqgop4P9sBpsQ0t6aRI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AMAaYvLJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AMAaYvLJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B8EEC433F1; Tue, 27 Feb 2024 14:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709043442; bh=Mfom+2Jx6JXpwQk71qrE95CVDBkTSinzAVRXLt7qCFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AMAaYvLJTWVRfiYjYGM4R+zWnDmGTNiWjZcopHh9Ubdvn02AE68a4bLwOf/R07Nc/ 1y+Jkv/4djYrjidTSoV9ru3CgH/a3jif/O7o8FlyxJMkUy9LAgIHeNAXf6bsJA3VL2 PWvdQIri0i3FXawbipeW9BssDJWRXP2ex8JzIXpo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Howells , Tom Parkin , Simon Horman , Paolo Abeni Subject: [PATCH 6.1 110/195] l2tp: pass correct message length to ip6_append_data Date: Tue, 27 Feb 2024 14:26:11 +0100 Message-ID: <20240227131614.095491115@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131610.391465389@linuxfoundation.org> References: <20240227131610.391465389@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tom Parkin commit 359e54a93ab43d32ee1bff3c2f9f10cb9f6b6e79 upstream. l2tp_ip6_sendmsg needs to avoid accounting for the transport header twice when splicing more data into an already partially-occupied skbuff. To manage this, we check whether the skbuff contains data using skb_queue_empty when deciding how much data to append using ip6_append_data. However, the code which performed the calculation was incorrect: ulen = len + skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0; ...due to C operator precedence, this ends up setting ulen to transhdrlen for messages with a non-zero length, which results in corrupted packets on the wire. Add parentheses to correct the calculation in line with the original intent. Fixes: 9d4c75800f61 ("ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data()") Cc: David Howells Cc: stable@vger.kernel.org Signed-off-by: Tom Parkin Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20240220122156.43131-1-tparkin@katalix.com Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- net/l2tp/l2tp_ip6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -630,7 +630,7 @@ static int l2tp_ip6_sendmsg(struct sock back_from_confirm: lock_sock(sk); - ulen = len + skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0; + ulen = len + (skb_queue_empty(&sk->sk_write_queue) ? transhdrlen : 0); err = ip6_append_data(sk, ip_generic_getfrag, msg, ulen, transhdrlen, &ipc6, &fl6, (struct rt6_info *)dst,