From mboxrd@z Thu Jan 1 00:00:00 1970 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 58D4947CC81; Tue, 16 Jun 2026 18:45:36 +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=1781635540; cv=none; b=n2UeyQiSSP63RtTgOvcKkI0Oe/onW0jGMkPZA77WuoDpJ/AQlry829cnnsseo5SQYKCSJb7UutM5cZjM7/xpINB1W0iVCgM+PRc42dptPR4OrLsMp0oJF/hyT1jmXIvpqyEflmHJQG7xU1SThGLMUPaiBfW6L0p4A17kbo+glkA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781635540; c=relaxed/simple; bh=TKO7CY+bl8jhbS7++aRn0omISo14A3Fbb+Scmwzn8e0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ONj+Qu1NMAxiHIpUx+b7p7rV49q6JIBCpFDXBO5cD1oVa+ghhCBx+sL+IwdrHXd1+LtjGeXHc1WNuE1XKObwK/xQ1RtAYS90BO0l8BUp1mAZvj3zmdFXKX6X6MC4mTyKKKzMQuPthnVJ7Czhn7xvHHRVJWvPP36QtBOJZxl80nE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MJ8A34Nf; 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="MJ8A34Nf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB1071F00A3A; Tue, 16 Jun 2026 18:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781635535; bh=RFWROCtsoufhpOjK9jp92XLWeApNWlTGhizt9oeFqgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MJ8A34NfsJzWn1/3gipM5qKZXRo8QpbzJgrBERlf32e9dx77AghQr8S1jzL3YCo3x XIcy5gRBiVvXjFTdOM+Os9p8+OFfewEyAc0W3HVr+WAjNxVfnyqm51ju2MvtJ+1xMU 2N7ItZzldAcslFbnpXx4K+kuHbFeHXj6MYtsJsGI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Jason A. Donenfeld" , Jakub Kicinski Subject: [PATCH 5.10 068/342] wireguard: send: append trailer after expanding head Date: Tue, 16 Jun 2026 20:26:04 +0530 Message-ID: <20260616145051.413076720@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason A. Donenfeld commit f75e3eb08fe31d30a9af6ed80cdd22e6772837e2 upstream. With how this is currently written, we add the trailer, zero it out, and then add the header space on. If that header space requires a reallocation + copy, the zeros in the trailer aren't copied, because the skb len hasn't actually been yet expanded to cover that. Instead add the padding at the end of the process rather than at the beginning. Fixes: e7096c131e51 ("net: WireGuard secure network tunnel") Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld Link: https://patch.msgid.link/20260529173134.3080773-2-Jason@zx2c4.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireguard/send.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/drivers/net/wireguard/send.c +++ b/drivers/net/wireguard/send.c @@ -177,16 +177,6 @@ static bool encrypt_packet(struct sk_buf trailer_len = padding_len + noise_encrypted_len(0); plaintext_len = skb->len + padding_len; - /* Expand data section to have room for padding and auth tag. */ - num_frags = skb_cow_data(skb, trailer_len, &trailer); - if (unlikely(num_frags < 0 || num_frags > ARRAY_SIZE(sg))) - return false; - - /* Set the padding to zeros, and make sure it and the auth tag are part - * of the skb. - */ - memset(skb_tail_pointer(trailer), 0, padding_len); - /* Expand head section to have room for our header and the network * stack's headers. */ @@ -198,6 +188,16 @@ static bool encrypt_packet(struct sk_buf skb_checksum_help(skb))) return false; + /* Expand data section to have room for padding and auth tag. */ + num_frags = skb_cow_data(skb, trailer_len, &trailer); + if (unlikely(num_frags < 0 || num_frags > ARRAY_SIZE(sg))) + return false; + + /* Set the padding to zeros, and make sure it and the auth tag are part + * of the skb. + */ + memset(skb_tail_pointer(trailer), 0, padding_len); + /* Only after checksumming can we safely add on the padding at the end * and the header. */