From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DA2926B971 for ; Sat, 1 Aug 2026 06:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785564156; cv=none; b=ntJ/RgXxlLrIBERn1RdOrgHZ+oeVld9rB+YNm+bxls148DqByt46i4MfilJs3VHE1UOtS069zh9cJqVIBgpiDasr2x7Do9JZ/tp5hg7ZrMbc4BhJxr+xFF/oPt7l8PYd6SWgZw/g5mnnmrsTBtpznL/8Wog2jr3ilpXpZx4NEdo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785564156; c=relaxed/simple; bh=cCRUw9Tymj8WgwK1j3rS3w2OZiOMdK3gIoxQR8pYLGM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EpyT+u6WH0FqyeaUMHMM0MPW3rKraEaAUoseBDkAxhQsG/KH28RUIufMJFJ46Fh8zSsbomicyxnjHKuInsuPJVGrkz3j3Rv/dlWiOzrmnyreAsqszX0nQNcuLVwLri/3ubrg8gTQKl7HJyb5WLjTOl5vD/kwBoGOMgw6sCbgYqg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=POIogbOn; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="POIogbOn" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-37f9e2642deso273130a91.1 for ; Fri, 31 Jul 2026 23:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785564155; x=1786168955; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=wG08jLgdCXnGeCo9TntB3GpQ3NVQXE5hVvOabkH8znA=; b=POIogbOnw9X+TMqiJ4lECbJyXuvQ27W8u561fswtnkQTMk1u1NnTLbw30X6DV7KrSE MGA8iQs6zhzRlnyRlA+FdpvQd/upyxOt8pAMtGM9RserjFf6tzA+eQPoxziIRWmVgbsr NLwZJasZGriMmw4wvNwKOHAuezP7cRmsuB3UgdP/rn56GcP7OUs7McyHTzRsGZ2raQtr vD8nE2xVpq4Qd6t9MSOJSGOCSDVRXM0EAa3H+CVqVEfSJSe6MQvtC+os3l88VycmCfig YiftZKHIJq20X+NrGMXPR8ZJIa4EydU6XtCdiygK6c3QG2rjparOnysWZvxquCLuf5ex JY/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785564155; x=1786168955; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wG08jLgdCXnGeCo9TntB3GpQ3NVQXE5hVvOabkH8znA=; b=iAvuG3++J3o3NMVdji7AQPs7Z2/XWMBX5vEGPrh/a8xrDtpXR1cid4w20eELlG5mBz 93uNC1xtkJx+YCD4K5kLz8BszX1Mrb9UB8TNFRmKq83WtKzkp8yqJFmYn0bQ0bbNTCdM FKfrFy+fs4nzDQsz5cqDdr3Twa7NYj0la2bVtxzjE8HDLv3E0miZ6yYY1gef0j2bqoWW P3VCl2TRxGDFRUIIGHfr+ckglsVLd1oXKm1+gQcsYEOXucyHwJUTrAXMv0zkNQ707B2I Hc1ZGoZ2x4jjdpdp0e2cF5KfyNvGD9yAgv62JtPo/RjKXhKHSMBrnEyiDME4EPeM4j6N eBYw== X-Forwarded-Encrypted: i=1; AHgh+Rry+0juxp2sLRWT6VeI/O37MqqVSEc5U4xM9wxo+UPrUEaz0Npn/rgjGuXbWwhG8y9ePMT9J8VdS4MeOrM=@vger.kernel.org X-Gm-Message-State: AOJu0YwYpT3ddCzWTXxg2pPxL4e8RhOCE1FPwoPXPpwWrJnGWjuQ4ZFv VqY57YzuZ011kjpEKKe30+Rnt+PU+6d9ZKugmmT/6R6sqOFJ5LohrHz//Bz5B/yLrg8= X-Gm-Gg: AR+sD11yRU3xHy2wcBaCcXitqItg1XO9XuAwLPsnZuUGymHqziuTK+LR/YfSrBXa52y /+mas4COeLUlW424yuHxR10OHOCgPLsKOXAH3y3S86Q7bP8HDMKD+i44jn95h63jKYP6Cb6mZux /uZKmli050W/d7bDzfdZnk9Ll1c3MG8sQQmHo4GyIn6wn6L54V3qDCACWxTWPQwomZ4EmoEuzNS irtyOM1woQx51ZXgaiHTGibuulOoLN423js99hbBrrGT+n278gaj6wOq/9pQsWC0CDtir+nsuYF pE8fUo9PN3T7mW9t/WDGVEvTW/Y6eVPCsy6p0kWsJ1kpD3v/fCqYqjhV+2Qx/eEpuxYRg8XwwuU TJsLTh53cupURvBgA5Ed19Kv4en2+cr9FrUj0Y71v5sZP8xEqA2nJkciDGdS4mzfO1vsRRS1LO7 YHLEoxvEHfvyxcq1CZ/edottHZzIQVACBS4mzUtH1354WgeCi5Y1f7RmqcromrJt9HUCgPopg5P amIKZIynlFulvxG9uYJ8Qg+OZqzFjHCR1Gu/3pQpfz5nC97d22HE2k= X-Received: by 2002:a17:903:46cf:b0:2ca:ecf6:9115 with SMTP id d9443c01a7336-2d0523bcf3amr36902565ad.2.1785564154559; Fri, 31 Jul 2026 23:02:34 -0700 (PDT) Received: from localhost.localdomain (45.78.65.84.16clouds.com. [45.78.65.84]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3153e18e114sm22462138eec.28.2026.07.31.23.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2026 23:02:34 -0700 (PDT) From: Chengfeng Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Kuniyuki Iwashima , Richard Gobert , Xuanqiang Luo , Chengfeng Ye , Xin Long , William Tu Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net] fou: ensure GUE headers have enough headroom Date: Sat, 1 Aug 2026 14:01:15 +0800 Message-ID: <20260801060115.3538849-1-nicoyip.dev@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ipgre_changelink() installs GUE encapsulation before it publishes the new GRE header length and updates dev->needed_headroom. The transmit path does not serialize with RTNL, so it can interleave as follows: CPU 0 (ipgre_changelink) CPU 1 (ipgre_xmit) install GUE encapsulation reserve the old needed_headroom publish larger GRE flags update tunnel->tun_hlen push the larger GRE header push the GUE and UDP headers update dev->needed_headroom With REMCSUM, the new layout can push 16 bytes of GRE and 20 bytes of GUE/UDP headers into an skb with only 32 bytes of actual headroom. The final UDP push writes four bytes before skb->head. With the update window widened, the kernel reported: skbuff: skb_under_panic: ... len:128 put:8 ... dev:gre0poc kernel BUG at net/core/skbuff.c:214! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI Call Trace: skb_push fou_build_udp gue_build_header ip_tunnel_xmit __gre_xmit ipgre_xmit Make __gue_build_header() ensure space for both the GUE header it is about to push and the UDP header that follows. On normally sized skbs the check is a no-op. If configuration changes race with transmission, skb_cow_head() expands the head before either GUE write, or returns an error without modifying the packet. Fixes: dd9d598c6657 ("ip_gre: add the support for i/o_flags update via netlink") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5 Signed-off-by: Chengfeng Ye --- net/ipv4/fou_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index ab09dfcdecbd..8cf0d43acb41 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -980,6 +980,8 @@ int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, skb, 0, 0, false); hdrlen = sizeof(struct guehdr) + optlen; + if (skb_cow_head(skb, hdrlen + sizeof(struct udphdr))) + return -ENOMEM; skb_push(skb, hdrlen); -- 2.43.0