From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.98 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795982298; b=hwJ92MCDISjToRoFdGNTg/LQIyaQeACD3rqt2yb9MKxyL5duJuct65/3ho9BwZ6pielX Oz64W3KUCV0p0NWJj6uip9EUSBokhTmTv8V2R94vGntVgHCzq8HJgNhii78zFioH99lWg dz0Fnogaer8UQOsQv1NNYLmUyAXkIE7uCsF9fTafyzJCSJgyJqQGAHXz3Fhi2w4pCRwvI Bj9axekL+sJQTjKa4zlrbI1OGdb9bW0qo/xqhPMME//MrV4KAkYvyJvJbtExOj9nBKAkY cUraniIIQftElmPdUi1UeJ0TIYtVUrxLLXrFt3SFExT00jK8v0SaKbZOzNAS/PYjlcQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795982298; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: X-Relaying-Domain:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=v3wswv2dLvuGmVJ0Zq/HLD40AdcZlI6QQFaKWTPZx34=; b=qEEBLC1LZ5chWiG0kqHpTw/7d4X2+i4lLndyEAjYfhb8Nt4EFCpl3qCu5BbuYrc6Utw0 VRpR501X7ljnzyB36fbFVvu1ZhTglJo02QwXoQSjetRgJzYAARjwY2e/ns926mtNo7aBr AVOpwy4V7kbjc6aAnmtDaf5/KX7fl0ixYM/OvKAD1PYjIMGP1W5HCCIclr19LhxA0Yvjd 1DBj5IcFNyBkBcMjaZf1OfA0A+piPSCwcTGWr1KIKCYTzk/WgBmiXkuW3u4rZd0FdU0tt Ri11HLpDCI9sZsNIVptm9DxsadGkkDjMwXG21Ed5gPDH2fXIfY7nJD+5u+jX6ODOJrA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=andrii.net; spf=pass smtp.mailfrom=andrii.net; dkim=pass header.d=andrii.net header.i=@andrii.net header.a=rsa-sha256 header.s=gmail-2025 header.b=ahOzTcJp; arc=none smtp.remote-ip=209.85.216.98 Received: from mail-pj1-f98.google.com (mail-pj1-f98.google.com [209.85.216.98]) (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 CCD59606A323 for ; Sun, 29 Nov 2026 19:58:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CCD59606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=andrii.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=andrii.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=andrii.net header.i=@andrii.net header.a=rsa-sha256 header.s=gmail-2025 header.b=ahOzTcJp Received: by mail-pj1-f98.google.com with SMTP id 98e67ed59e1d1-3b567ae3d54so320297a91.0 for ; Sun, 29 Nov 2026 11:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrii.net; s=gmail-2025; t=1795982297; x=1796587097; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=v3wswv2dLvuGmVJ0Zq/HLD40AdcZlI6QQFaKWTPZx34=; b=ahOzTcJpuYOaKRlaUqJqJJdQZlUk+uNcGMQaWTulHdx8xk+RReH0RzKxyxA6jvuye+ yyu3F5TBKkFd8RrseBHim2EjxZnZLIFnpTuUUEVByKLl4DpFUA+MiV8y68yQX1pQ6CBb j+2jnvx8dzc5f8Wvoj8qtOm9pvOrjwreOwq3CKXujuo3AWoO/UM0wBeG/s75yuNWOyaV R4fwdkVnBkiYHc8xwNGw4fGIHbyjs4VLUH0OrrVpzvFQljfX3f9YBFXKwX147oJycRZV Xr9Jysd41sRNcZYzefUrrvMuQI6+6a6Kqb/N1g8zTolwFAzIRfu1bbvcEX2JuX6mE9zB kIYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795982297; x=1796587097; h=content-transfer-encoding:mime-version:references:in-reply-to :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=v3wswv2dLvuGmVJ0Zq/HLD40AdcZlI6QQFaKWTPZx34=; b=fp5VdoM67qvBx2SMr572s2dFihzzg3O2+RzYFvhcXd4OfbSgC67CQAVaxFMJVa0V5w uoh1B7L4LYh+PHOSRkqtMAw48blCOa6sAo/T1ExEm8lPdOEOQ2v6ACFY6hOsH+yIvH7F /P5VwLnICBfnz9YwwEKaC4fUEZMDA8wdvWUqtDrtG6/E1yHoGg9f3nRt95TcvUoAZY7o vUSQm0nZFLxFm8X+2rKXdj+QsVmNzEw8/QXc48XC5bh0tSZCpZlKnYXsEZ/errzw6RNt 4AtQy2LkSDKCp9bEdrSt/3Sj2MLzIpdt60Znfxj3KWGgeq1QFJFtFnb4OnBjdHbc1rUL FwwQ== X-Forwarded-Encrypted: i=1; AL+hErGCo3T+vxWH+M6KIXQpJdCWaOdtWTGj0BEjYc5P43AGIh7BZfBgKxTI5AUm1SKccEOfabxxEPEbVOa29ek=@vger.kernel.org X-Gm-Message-State: APuU4Z9PAtA6tnKz/kjVtn6tEzyZRSJSTrCOWRWAOyygDcklGWDcdjeG Y3pXsWG2GCzd8jML28Fd0hyal1ZaYQwpNfZhlG3AD+ZDuQHCS/dBsRSTv8UDubxvp07xSZFoQ22 kRRe/hXkDysf/+pvWN3TByDRD10IV2C4UGYDhUq9oAkcEzyeZnv5/ X-Gm-Gg: AZFdTZflbGNvMl/JN8zJX/DBzcver51ZQnShHp8CKGBys0Gp1mH4SCfz9arJY0VprwK L+rl/O1uHUx8TyBmttj1WGyJEyBp5yI06yBgZtOONUlCa59WwGDymHHqiLtg3+nqlg4r2fV59oT ba3wxyDZzxIifmtsHS/UjmT3J25FJ77KiF0F6kbGm1888ddlze8y+MoUSLbuBCydIKJtnEzs9pi zMTJBXgeKb+V4jpXmA4fugMYk9jzF7R+ds/Z3tj7xwN0xtFVlGYcqVWR0jMyXp/+7tLfZxFLKPN NQqrVsK+pGqUWJ9LRTO5t15KP1f9ofMLiMiOqYWnDCXp6XH3JxBOOOASvsqjwyNhZy6ax5p/34y LW4exwhIll+jBcS6HzFXivhaAji0= X-Received: by 2002:a17:90b:268c:b0:3b5:32db:11c with SMTP id 98e67ed59e1d1-3b532db0430mr10421626a91.12.1795982297108; Sun, 29 Nov 2026 11:58:17 -0800 (PST) Received: from andrii.ai (mac.hestia.andrii.net. [2602:f337:ed:4865:7374:6961:204d:6163]) by smtp-relay.gmail.com with ESMTPS id 98e67ed59e1d1-3b41ab582a3sm20654853a91.0.2026.11.29.11.58.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 29 Nov 2026 11:58:17 -0800 (PST) X-Relaying-Domain: andrii.net From: Andrii Tereshchenko To: Steffen Klassert , Herbert Xu , "David S. Miller" Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Christian Hopps , netdev@vger.kernel.org, ipsec@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH ipsec] xfrm: iptfs: give a runt-started inner packet a MAC header Date: Sun, 29 Nov 2026 12:58:14 -0700 Message-ID: <4de11468-7743-409e-83a6-d7c839df56d7@mid.andrii.net> X-Mailer: git-send-email 2.56.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Both AI reviews [1][2] raise the same issue with this patch, which another of my patches fixes, plus two older issues outside it. Neither review was mailed to the list, so I am answering here. Sashiko (netdev AI review) wrote: > Can this write past the end of the newskb buffer when skb->mac_len is > larger than the headroom of newskb? > > newskb comes from iptfs_alloc_skb(skb, ipremain, false). That call reserves > a fixed amount of headroom and ignores tpl->mac_len: [...] > The note below the --- line says "this copy relies on C1 ... for long MAC > headers". That patch is not in this tree. git am also drops the note, and > the Cc: stable tag lists no prerequisite. > > Would it be safer to check skb->mac_len against skb_headroom(newskb), or to > call skb_cow_head(), before the copy? Another option is to send this with > C1 as one ordered series. > > __input_process_payload() already has the same unchecked pattern: [...] > So a fix would need to cover both places. Sashiko (sashiko.dev) raised the same point. Yes. "xfrm: iptfs: reserve room for the outer MAC header in new inner skbs" [3] fixes it in iptfs_alloc_skb(), which both places allocate from: it reserves at least tpl->mac_len, rounded up to a cache line. Without it, this patch adds a second place with the overflow that __input_process_payload() already has, so it has to be applied after [3], and stable needs both, in that order. Steffen, could you take [3] first? If you would rather have them as one series, I will resend both as a v2, with the order spelled out for stable. Sashiko (sashiko.dev) wrote: > Also, if skb->mac_len is non-zero but smaller than ETH_HLEN, writing > eth_hdr(newskb)->h_proto writes past the end of the skb->mac_len-byte MAC > header into the IP header at newskb->data. That is true of every h_proto store on the xfrm receive path: the reuse branch of __input_process_payload() and xfrm4_remove_tunnel_encap() and xfrm6_remove_tunnel_encap() guard with "if (skb->mac_len)" too. This patch follows them. I don't know of a device that hands ESP up with a MAC header shorter than ETH_HLEN, so I have left it as is. Sashiko (netdev AI review) wrote: > This issue was not introduced by this patch. The new comment names > __input_process_payload() as its model, but the allocate path in that > function does not have this mac_len guard: [...] > Should that store also be guarded with if (first_skb->mac_len)? Sashiko (sashiko.dev) raised the same point. Yes. Over IPIP, point-to-point GRE, ip6ip6 and ip6gre, only one inner packet per outer packet survives it. I have a fix ready that adds that guard, and will post it separately, with other IP-TFS receive fixes. Sashiko (sashiko.dev) wrote: > This problem wasn't introduced by this patch, but earlier in > iptfs_reassem_cont() the blkoff == 0 handling triggers [...] an > out-of-bounds read when skb is completely non-linear: [...] > Direct dereference of *skb->data neither checks that linear data is present > nor reads from the sequential state st at offset data, so it reads past the > empty linear buffer on a fully non-linear skb and otherwise inspects the > outer IP-TFS header subtype byte instead of the inner padding byte. Yes, that check reads the IP-TFS header instead of the data block. The fix, which reads the first octet of the data block with skb_copy_bits(), is in the same receive series. [1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/e7d0ab12-61be-4ba7-9a2d-4a71ca73dc4e%40mid.andrii.net [2] https://sashiko.dev/#/patchset/e7d0ab12-61be-4ba7-9a2d-4a71ca73dc4e%40mid.andrii.net [3] https://lore.kernel.org/all/a502a95c-de83-4f8d-986e-80f804ebe76c@mid.andrii.net/ Andrii Tereshchenko