From nobody Wed Jun 17 02:51:01 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 2B7413AE18C for ; Tue, 28 Apr 2026 11:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777374450; cv=none; b=FF6kY66VePcqXwQFy0AvWqygc70Xh9zIFMDK96XPic1866UHmfe+ylVFH76tzOTVuL3dOasS+tUYyNL4TGHyvRcn9OMEcim2YXyQO4A3RyHI6NfbuUhZz0IOIwk7Eg0zQ0Ae0/+daQLZ4yXpuDU0+fSzGowR49QOH5NlEbk8VbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777374450; c=relaxed/simple; bh=t1J1G0DPTGU3Nq5IK8gdpkJgcqUbwU/dQwACfaQ8rfQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xze4TqbduWKdiCM5jwONuVTpMBJswFn7FLwVfjR27xUHCm6v0BWOdMFFJk+fglSz4nWPaegJvPyRYxqjLoQ/62Tytc2ydsEp9IfrMuIXz4iPNfFqAZ3hFBiknfNAbvAPD4z2f21HvWyOC+BUAgynE6EigdCcIC0rj9YOxrmF30Y= 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=rYENpmII; arc=none smtp.client-ip=209.85.216.48 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="rYENpmII" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-35f9ab079bdso7568918a91.2 for ; Tue, 28 Apr 2026 04:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777374443; x=1777979243; 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; bh=jbbMQ0UaEkffRakuaSv0SsaIDp6XiWs2fQ+ORE2pX24=; b=rYENpmIImf6ID+SbAViIxp/ggJ2TcTkqLd72/oZO2O9PeO8JbTLlv10ujnRP5lJ3JL GToWdPOoJxsBm+wkrnFswdeDtWGEbpFejQv12DWD+4Xfv85qsLhKsOKuPaf7vsjKlBKn e8Tro0FEKbz2EXLa0p77Z2hxiyY96mxIfq7eIMrOFE8KKMV2Qk1fw3abqtYmiFwMfAj8 VtlOoNAJJNefcKnaNjD0eIgpM/iqZldcs7n5tcRlZ/c/rwCX0ZU0kPA8+Ilk2xWwAby4 1GGCP7L+kjE5CYVP8T7PXFMdGVFfjREbp+6Buo1DYHiNL28rPm4fTxNxftyMvl+JnvSJ 5lMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777374443; x=1777979243; 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; bh=jbbMQ0UaEkffRakuaSv0SsaIDp6XiWs2fQ+ORE2pX24=; b=TAD7nUDilFdiBIVyfDy68QjegRmbCaQA32xZG+iqzWwv51gXokSZoxVM5lyN0V1Wth AHzIj1ouBTd1KF2o3v6b0EPtRbBsTsey9hRcBdTgpv5KKM2234/dRlCUPvKfaCefWOum izePZsA7/svrjsfgscj9vhT52oNwSlgcSibNY3IUHfJ+1aqDqV2baMaMGq1qJ/2aZwun GsFVCVOyQ21+bb6pJvK3pZ8PlXYwyCt5IpvsEGA+QdFYNkdY4SRjYrmFRXbR7y/596Xb j4wMM7jVsKdwaBg79VNOEWtTgZ5YiN4HFC4GrujFBH6Ey5VQRYFfeaFCi2GKA/+ZJZjH 9PEg== X-Forwarded-Encrypted: i=1; AFNElJ+YuRwfFLgCoxdi4TNTcPfJHUKqECRj1fcya3DHAf415IMJ6+SI8Bl3bdaQKdoNOMoXHZRYxLSBjnhFdNM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxw01SfYVQ8JhYVMsw4eSoiQfleN+VDwQBSmSW2k4kYj/7kDeIu 1ZQ+5pDalTyOdCCq1Gc5yh3q1HCodBrwq2HKov4BFJxVO1N3mCnjokuB X-Gm-Gg: AeBDiesHBh608fZA1oZ+YM3HSSUprhPUwVn0H7VrbwY6qUcYK0oTapE8WkTYs5D6QI4 4s/jE/KMIrX65hedFULd25LMb8L3hGkdMbQ48IvYVfZEhFaiduiYmxPKATvjDuGpywlTXwJqP2X ygF+K4AcYdFSEl+KGcwm52dqFt+g6O536hKoM+h/N6uWRELDj428qAkobFp+3fH+22O636AcEy/ SfEk/sjG1m/4FhkoIvJ4dl9wk5aTjSerRwxFjGoHMBIhX83VdSs4J3xFYWUHNOnM/0umW3m/OxB 1iG44r0i+jBfTwoDBJvm6Yc0eX58daZne9VZIk8BWxLr8zk0zTJ6tDC3/QRM+qHbsdy1fSziKRi 6bFVuvCfg2WHMoC6tsOJQKiWA2reysKSU4+X8TtibNaLSpU7BMlRVsAm6Px6VK0t32FixpUWLeC cGRL1mBZZzZ7qbmvq7MC77cvepzdJLI4dLgCGU6a6+FV6gS6ggOuVCOOLEh7Q= X-Received: by 2002:a17:90b:4c86:b0:35f:d56d:1c45 with SMTP id 98e67ed59e1d1-36491fbc102mr2653279a91.12.1777374442873; Tue, 28 Apr 2026 04:07:22 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7fc33d4e11sm2023328a12.24.2026.04.28.04.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 04:07:22 -0700 (PDT) From: Maoyi Xie To: netdev@vger.kernel.org Cc: kuniyu@google.com, shaw.leon@gmail.com, davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, kuznet@ms2.inr.ac.ru, linux-kernel@vger.kernel.org, stable@vger.kernel.org, security@kernel.org Subject: [PATCH net 1/2] ip6: vti: Use ip6_tnl.net in vti6_changelink(). Date: Tue, 28 Apr 2026 19:07:12 +0800 Message-Id: <20260428110713.2550315-2-maoyixie.tju@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260428110713.2550315-1-maoyixie.tju@gmail.com> References: <20260428110713.2550315-1-maoyixie.tju@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kuniyuki Iwashima ip netns add ns1 ip netns add ns2 ip -n ns1 link add vti6_test type vti6 remote ::1 local ::2 key 7 ip -n ns1 link set vti6_test netns ns2 ip -n ns2 link set vti6_test type vti6 remote ::3 local ::4 key 9 ip netns del ns2 ip netns del ns1 [ 132.495484] ------------[ cut here ]------------ [ 132.497609] kernel BUG at net/core/dev.c:12376! After commit 5e72ce3e3980 ("net: ipv6: Use link netns in newlink() of rtnl_link_ops"), vti6_newlink() correctly resolves the per-netns vti6 hash via link_net. vti6_changelink() and vti6_update() were not converted in that series and still read dev_net(dev) / dev_net(t->dev), which diverge from the device's creation netns after IFLA_NET_NS_FD migration. The result is a stale per-netns hash entry; cleanup_net() of the original netns then walks freed memory. Reachable from an unprivileged user namespace ("unshare --user --map-root-user --net"); cross-tenant scope on container hosts. Fixes: 5e72ce3e3980 ("net: ipv6: Use link netns in newlink() of rtnl_link_o= ps") Reported-by: Maoyi Xie Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Kuniyuki Iwashima Reviewed-by: Eric Dumazet --- net/ipv6/ip6_vti.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c index ad5290be4..dcb257411 100644 --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c @@ -722,10 +722,11 @@ vti6_tnl_change(struct ip6_tnl *t, const struct __ip6= _tnl_parm *p, static int vti6_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p, bool keep_mtu) { - struct net *net =3D dev_net(t->dev); - struct vti6_net *ip6n =3D net_generic(net, vti6_net_id); + struct net *net =3D t->net; + struct vti6_net *ip6n; int err; =20 + ip6n =3D net_generic(net, vti6_net_id); vti6_tnl_unlink(ip6n, t); synchronize_net(); err =3D vti6_tnl_change(t, p, keep_mtu); @@ -1031,11 +1032,12 @@ static int vti6_changelink(struct net_device *dev, = struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip6_tnl *t; + struct ip6_tnl *t =3D netdev_priv(dev); + struct net *net =3D t->net; struct __ip6_tnl_parm p; - struct net *net =3D dev_net(dev); - struct vti6_net *ip6n =3D net_generic(net, vti6_net_id); + struct vti6_net *ip6n; =20 + ip6n =3D net_generic(net, vti6_net_id); if (dev =3D=3D ip6n->fb_tnl_dev) return -EINVAL; =20 --=20 2.34.1 From nobody Wed Jun 17 02:51:01 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 61C0C3E121A for ; Tue, 28 Apr 2026 11:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777374452; cv=none; b=BKDldGGnQcXMwMy8s15b9vOVl3iOhtS8SqmTGoMrrk04CjMNxh2hy5kL1Z6n/3PGHE1Ptygyhv6AuaiDQ+uuzuKRWdnGk4t3GxFHPGA+qkDIMfvrrN4pq8Qbi5K8e4gkX7YZHgn3el6Q84TfCBPHPwVh0ucS2UPhWyJmv4/+btU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777374452; c=relaxed/simple; bh=o8i2uC1zO/a2xkebuFDYmXGH5i+hiWFwIKkf2xAeZHU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Jenodjuys2zFzZPwJqQgVctNlAer/p05CmNS6PgCsAVld/Xnyt9wrk4j3yDqY/xUE643NlCZdKV3mEPnVXazzx048Yx51TS+ZND7n+13VFCLRDJ82hZS5PBfYlHfaQwVApIo0bhZImNsD6dOHhuXpVSai/CuRDDDopuZoKbo8wU= 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=Ys0dmzq2; arc=none smtp.client-ip=209.85.210.175 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="Ys0dmzq2" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82fb2d0c5d1so5642834b3a.0 for ; Tue, 28 Apr 2026 04:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777374446; x=1777979246; 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; bh=winsu62q5y/m4N8BbYwmfb2kAuzIpiVgfaZfSzGuNDg=; b=Ys0dmzq2kEmt/rfD7kGSv1AUCdL+lFmRBLqyN3HK/hVC1Whs7WbYmjwoZ8dDRSCzAA Ig8U9fNXfwsmQpD/iOL7w1k7QW3XUZj03wiyUfEK1kQ4uq0tHm5dX6XAzpMxG5XlLECP TJ07eSekulVIVT763v4LmonkPj8XVhtylK+PteOjJVF2Kzg+Fl19JN3a49irfVTd821q a+/VUYIYcv8lmMTL8AE2OyZ+9t8pVxTFrwuS8Wts+zsVQrVL6YD8rZmcrl9CF1xWByWa Rd8+meZMJjYzi/XZhTLbvVGI/UFY6jQm9xp3daIwRF1CETbZeafQqjALz7P05Zx/fDpo aklw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777374446; x=1777979246; 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; bh=winsu62q5y/m4N8BbYwmfb2kAuzIpiVgfaZfSzGuNDg=; b=mfmKx8TzCdyNOI6dSm5sPqsLOvqIU9NQfvoLiUyZosyvdjHeEpU+BbTBQN/4P9o/SM mjxv6Ynv1l4odBwtyq7xJR5ruY2HjDosHPjkzaEmo+mX8Yyib+a7IApKyPorg5ddsc4f wherZz/vqsGHuvjwlJOGpavYpIUrYMGErSiOoXMdh165FsFB/c1sB65n67L+HGZJGF5t leAb1plbuvIGtoChEbWWWxWUEbjZfEyIqwP898kWRBRbEj6Xv8dgC3b88+SEqyszSy1s k9M5+PWx7fNp4QoL5qVZCT1VC7xl7WT+zMmv5dFai8zgIA26Y84qq7JqLm5Q66VHramd J16A== X-Forwarded-Encrypted: i=1; AFNElJ9iITO4bVkh8eb7oVza9u5GHwlk/gJhvEFeEz8Ju9/pxeXrm6CPeKwdLd+Jc5EXpm0ToPUpmVdS5tq+Uaw=@vger.kernel.org X-Gm-Message-State: AOJu0YyRfu+ACCyvoWPbgkfNJK7hZLSMRGe0EbLP3pXUZj3IcieQOeom kH+9jm3zW2jO12t6UDLAx5zWHvbltcnDXXr3+7n4jYuwFE0QsDM8AEZQ X-Gm-Gg: AeBDietTXhiT7dr7hU/Zp/OPlCqhmUqWjYfS7lhdvSG9uamnmnB1aoojeXH6bXc+f0k bamuGMVr9dQsIBtfCg0SyJyAXkjXwXsnhBgG3EBMneqo9a1Ic8x83az37H7P+WYrXWUPc9nQ/iP XPKmmf2+KHNO/20gTFcTEWQ53uyJxJDBtLJLdrourO3qoUE2A51JiK1/SIstAVhMtHCGF9xg83b rSh+5llGI8wg9+Ohro5NL5AK+hm2gmlnkHqZy4BXH5JkkpQsaVZ7Lg7bWBOkCdn6f8U8uyhFFzX jmfAagYl259E4dv2swzfvKv2utm1qv9DrxkbLfusR1F9dpXQtXX0cAsE/kRLMAHNXEhkp044I+P rQbaCekeoC90gPqycCoHDYJZJARnS5GDy12JYY5peA4IeV4YCcnlmNrQ6du4qo7XDzCYezJSVkW 4qWwUdz7KnjX51kyciYMrgTqDvbpdusccDt0npYOD0ISDuDduK48jAMSEv+kyAauoPPVwWAw== X-Received: by 2002:a05:6a20:9146:b0:3a2:d53f:691c with SMTP id adf61e73a8af0-3a39c14961fmr2707035637.26.1777374446370; Tue, 28 Apr 2026 04:07:26 -0700 (PDT) Received: from csl-conti-dell7858.ntu.edu.sg ([155.69.195.57]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7fc33d4e11sm2023328a12.24.2026.04.28.04.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2026 04:07:26 -0700 (PDT) From: Maoyi Xie To: netdev@vger.kernel.org Cc: kuniyu@google.com, shaw.leon@gmail.com, davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, kuznet@ms2.inr.ac.ru, linux-kernel@vger.kernel.org, stable@vger.kernel.org, security@kernel.org Subject: [PATCH net 2/2] ip6_gre: Use cached t->net in ip6erspan_changelink(). Date: Tue, 28 Apr 2026 19:07:13 +0800 Message-Id: <20260428110713.2550315-3-maoyixie.tju@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260428110713.2550315-1-maoyixie.tju@gmail.com> References: <20260428110713.2550315-1-maoyixie.tju@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maoyi Xie After commit 5e72ce3e3980 ("net: ipv6: Use link netns in newlink() of rtnl_link_ops"), ip6erspan_newlink() correctly resolves the per-netns ip6gre hash via link_net. ip6erspan_changelink() was not converted in that series and still uses dev_net(dev), which diverges from the device's creation netns after IFLA_NET_NS_FD migration. This re-inserts the tunnel into the wrong per-netns hash, leaving a stale entry in the original creation netns. When that netns is later destroyed, ip6gre_exit_rtnl_net() walks the stale entry, producing a slab-use-after-free reported by KASAN, followed by a kernel BUG at net/core/dev.c (LIST_POISON1) in unregister_netdevice_many_notify(). Reachable from an unprivileged user namespace ("unshare --user --map-root-user --net"); cross-tenant scope on container hosts. Note: ip6gre_changelink() (the non-erspan sibling earlier in the same file) already uses the cached t->net correctly. The bug is specific to ip6erspan_changelink() copying the wrong shape. Fixes: 5e72ce3e3980 ("net: ipv6: Use link netns in newlink() of rtnl_link_o= ps") Reported-by: Maoyi Xie Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Maoyi Xie Reviewed-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima --- net/ipv6/ip6_gre.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index dafcc0dcd..38ac14cc0 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -2261,7 +2261,8 @@ static int ip6erspan_changelink(struct net_device *de= v, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip6gre_net *ign =3D net_generic(dev_net(dev), ip6gre_net_id); + struct ip6_tnl *nt =3D netdev_priv(dev); + struct ip6gre_net *ign =3D net_generic(nt->net, ip6gre_net_id); struct __ip6_tnl_parm p; struct ip6_tnl *t; =20 --=20 2.34.1