From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796018183; b=cW6qJA2IkrIFdahXB8TDuPTXgvbFog97BFSizf9lUQBbXt1AHVAVAYQvbPHFF7TGFn6y Hu2oAF9aExeD5JK0sSET+cNgfHPLCVV81/flkMYhguO9t8YXgKeNvvopvO1eIC/nkYhUn 6/TDjNTzLqAmfI0HknHISFgVogIHHCq/uEs5kgyFYc42SeZpddp3LoZx3uLhUQDMH1B6h RnD8av4jmOV4TTlJpwkbys3pGZPFYLytsKpEYTmvDEpOVULCgvc7gu8beeebPWmq4cJJ9 Bi0gYKKlJqGFBFGxRUPq16eHwMOtoflh7mkKJwJgWykWDUMNGEuDR/njeQeY5FSjZoQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796018183; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding; bh=N0iaqp86ropo9bnWQm9g91wN1p68NBMDOYfg+KKFssU=; b=ZFd6QrDaEq18P23I+O507kODU84zCAA/Dy82VPcKcy0paW5HH6MytCdibu33zYAlUqOV si6plwyBmqLuNmD2+WukSJNusw0vmjN+/GdesMnP77tvO9Cu0JzoFTOE8ddNikx4/AewT QGavB0wZ6WXfxiAFlWv5dKWIz0bOm6Ti+KtoNt2kZmlOgBzwn/UILGAs0ZzvovBuMIAjX E6za2EYT39dgsDHEb8huFPydgQWPqW4AqQVyj4tFy+bMMANr56sHbmx5mvxLIMUCVDhJZ Bm6R+N/4vDoXT9kwcoznc6XaLZ4RLQ4nphjWgtPQHrvCOqA6HSOi39jBDFNl0/gF/Ww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rFDhXLsW; arc=none smtp.remote-ip=209.85.210.174 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59E90606A325 for ; Mon, 30 Nov 2026 05:56:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 59E90606A325 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.a=rsa-sha256 header.s=20260707 header.b=rFDhXLsW Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-8c20d68c83fso5722663b3a.0 for ; Sun, 29 Nov 2026 21:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796018183; x=1796622983; 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=N0iaqp86ropo9bnWQm9g91wN1p68NBMDOYfg+KKFssU=; b=rFDhXLsWyuJ4UQHf24WT7OMvmphFaxKOJXGvg3JiRPvXkTZPS7WOCOnVhVY+JSDIJr FQUtU2bSTbJ9y/M90vsv3n8bSghRYe4aYc28fmh+l8x+5WzctwuLzRg4/mDKZ6Wz4TW5 5cB949xusddwfNT78t8bbfLW8XLkn1B+AdH36dZfLa+WPCTDHtcG0BpNRLzCPa7mpXfw wk06UUR+k5VGEFm0r61IR9G2MgeiO4gGp1SZNMws8xTLJrGKivCuIITC2FhQH5mbyJLC yvfHbUek0nnExvX2wxCiiNTbIYPANSOVozeEqP4pPvEyzZvzDQDQ3P24NzVUnHQUy9HX +KDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796018183; x=1796622983; 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=N0iaqp86ropo9bnWQm9g91wN1p68NBMDOYfg+KKFssU=; b=UtAuNAZeKpZNmkcbhdkJ+xD3dYuL8/iulk0gtV+PZzYMJHLRYFPL62N7i2bK6QXRJh zZcYra8OIkP4uCbxUVbu8HxriXA44LjIKLPxKOvxQNJwonRfDrxiDDHikAhAAM4GtzcT JEOxAidWbGEChrJzbo3LjnOUmTRUM3hTc1ihy4X46nmj1Rr6TAZ74vbp4/2j2xlYTDAw 8PpVpMHG8yVzVmz1o4lc0l3sYPjYGEe8/nqdCSVDmD6nXqR0FyXbQqBSZysUvE4y2jAN 7QCGKiyEK+Aa6gM7ez+Q0USfb/bIKLv4zbb/TgV5BAfUDcPLZIPM29K285XIYtEYbheS 4pvw== X-Forwarded-Encrypted: i=1; AL+hErGRTruzisA1KDPaqQZkPeKu8FRp/UovEF0g3RHeV/F598lEkbmcAVomFu8sW1bSnIAgLOGEwvA=@vger.kernel.org X-Gm-Message-State: APuU4Z9nobkrXO494Hmo3wD/LpTg55GmAC0ZV6slA2w7NFc3oLYBAoQ+ 19Kwmp5VNqDchnyWPUf8dOszXvuQfBqYvxqIMyRU2bUusdEUMDQYy5JYQIjkiw== X-Gm-Gg: AZFdTZfRBn+cb5JFAT4qUsZz6ovmUSJHy2XyGK77C9pVvFfyCuukOwgY/ObLN95AKND CPTFDzHP3vRW0yRQr0Chak8LRU9NvEyy5/7ehXmgcwRQcbmylE2Dffl4H8Gx3HmRhmpDFXqgfwQ NboBoVSxbzTcao+h/DOUupLYIGUMelnWZ5X+SrELoRf8uJfgWwZNd5cxUoIcrr+KN/QTa3MzOaB 6jR2QEQjT6s5Nihn5uGXIzNots/bSEy5H3MDbrLoEq62pQ9q3DIllnbK4TLkn5IS5uyjv3YSfda +7ScMwlrMGuNFWoTBTbQHzFniWcMKxK5caTWl6e+JTlUldfYQTN7FpSkNGGObe5/OWzXLvmgpBY nYHWwzikXSItLGlb/DySFSYsLQ+llcSIpNIlDrfMiPTxdjK+FvV9hyPd75nF6RtR2gMFxbYnXKg 7z27vUyJDG5CafEWdVAHnrCyF9/3DbcMpZdaTz4Y7L/nAVYNUDEhtj32f+t40qItFQrM7TFQkPH kc+wkHKxQGzSwSoBbeFnojjmOSftQROt4kJJ3enVEAOV+oYimBdKRXLXtEwBQ3k8qygHRb0tapg DGOz0YRwyvXbAfoOj6qJf2yVo3AhQ1YQUXTncSABCElpVHWMR2gNJBhp9FzABEwuMpU= X-Received: by 2002:a05:6a21:3b8e:b0:3fe:c355:b92a with SMTP id adf61e73a8af0-400ad19dee3mr26179952637.14.1796018182601; Sun, 29 Nov 2026 21:56:22 -0800 (PST) Received: from d20be28ee783.tail196be.ts.net (vldb.skku.ac.kr. [115.145.173.180]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cde6cea770asm17578233a12.3.2026.11.29.21.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 21:56:22 -0800 (PST) From: Kyuwon Cho To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: Ido Schimmel , Xin Long , Willem de Bruijn , Simon Horman , Dmitry Kozlov , netdev@vger.kernel.org Subject: [PATCH net v2 0/3] gre: fix the headers that ipgre_header() and ip6gre_header() build Date: Mon, 30 Nov 2026 14:56:14 +0900 Message-ID: X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ipgre_header() and ip6gre_header() build the outer IP header and the GRE header for AF_PACKET SOCK_DGRAM sends on a GRE device with header_ops (remote any). Neither clears the optional GRE fields, so a packet socket bound to the device reads the key and the sequence number from uninitialized memory (patches 1 and 2, from Ido's review of v1). ip6gre_header() also returns 40 bytes too little, so the payload lands on the outer IPv6 header (patch 3, which is v1). v2: - Add patches 1 and 2; v1 is now patch 3 (Ido). v1: https://lore.kernel.org/netdev/179553307366.1670514.6802805102726706751@gmail.com/ Tested on a KMSAN kernel as any user under "unshare -Urn", with the program below on three devices, each set up first: ip link add g4 type gre local 10.0.0.1 okey 7 oseq # gre-tap g4 4 ip link add g6 type ip6gre local 2001:db8::1 okey 7 oseq # gre-tap g6 6 ip link add g6p type ip6gre local 2001:db8::3 # gre-tap g6p 6 Without the series, KMSAN reports bytes 24-31 of the g4 packet (the key and the sequence number) and bytes 68-107 of the g6p packet as uninitialized. With patch 3 alone, it reports bytes 44-51 of the g6 packet. With the series, it reports nothing, the optional fields are zero and the IPv6 headers are intact. #include #include #include #include #include #include #include #include /* gre-tap DEV 4|6: send 64 bytes of 0xaa through DEV and print what a tap on it sees */ int main(int argc, char **argv) { unsigned char sa[offsetof(struct sockaddr_ll, sll_addr) + 16] = {}; struct sockaddr_ll *dst = (void *)sa, tap = { .sll_family = AF_PACKET }; int v6 = argc > 2 && argv[2][0] == '6'; int proto = htons(v6 ? ETH_P_IPV6 : ETH_P_IP); int c = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); int s = socket(AF_PACKET, SOCK_DGRAM, proto); unsigned char payload[64], buf[256]; int n; tap.sll_protocol = htons(ETH_P_ALL); tap.sll_ifindex = if_nametoindex(argv[1]); bind(c, (void *)&tap, sizeof(tap)); dst->sll_family = AF_PACKET; dst->sll_protocol = proto; dst->sll_ifindex = tap.sll_ifindex; dst->sll_halen = v6 ? 16 : 4; inet_pton(v6 ? AF_INET6 : AF_INET, v6 ? "2001:db8::2" : "10.0.0.2", sa + offsetof(struct sockaddr_ll, sll_addr)); memset(payload, 0xaa, sizeof(payload)); sendto(s, payload, sizeof(payload), 0, (void *)sa, sizeof(sa)); n = recv(c, buf, sizeof(buf), 0); printf("%d bytes:", n); for (int i = 0; i < 64 && i < n; i++) printf(" %02x", buf[i]); printf("\n"); return 0; } The issue in patch 3 was found by an LLM-guided test generator that we are developing as a research prototype. Kyuwon Cho (3): ip_gre: clear the optional GRE fields in ipgre_header() ip6_gre: clear the optional GRE fields in ip6gre_header() ip6_gre: return the full header length from ip6gre_header() net/ipv4/ip_gre.c | 1 + net/ipv6/ip6_gre.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) -- 2.43.0