From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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_ops") Reported-by: Maoyi Xie Cc: stable@vger.kernel.org # v5.15+ Signed-off-by: Maoyi Xie --- 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 *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip6gre_net *ign = net_generic(dev_net(dev), ip6gre_net_id); + struct ip6_tnl *nt = netdev_priv(dev); + struct ip6gre_net *ign = net_generic(nt->net, ip6gre_net_id); struct __ip6_tnl_parm p; struct ip6_tnl *t; -- 2.34.1