From nobody Mon May 25 01:15:09 2026 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 5AF2331E828 for ; Wed, 20 May 2026 03:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779246245; cv=none; b=UBlrq3kt8KgXZp+hFcmie43yz1FsfVgxlPlwIINGEhGK7Q9NyTHC7uaar4doCAaha1tggI8dWIFZ3r9Pp6JFJ3kA3baBw1/pFyYb1VGU7UHpT3j0PYBTfvbWbLvKbmkJt0lF8RqeIN+79KIVn2ci/6D1EYjirlnuCLZd/UaBw5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779246245; c=relaxed/simple; bh=Wiih0f6OIaCvmndCXRWrRH6xlc+Q9XwF+Kgo0p/Z/uI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=IRZv/7PiYJ7GcToDHOT0IRXsoSxaCjzq3KskfwrOLgel/hJNBJeX82lPro+ot/fPOpF0V3BXprdXVBI00wpeOVWUQp3Ibav7HXXoLOj12JssIRysRdhUEfYiynArxTKPLxUerIt7pF/wDlyA8d0INXzYPjH2iSiJSdbeJJ+HA6k= 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=YhglDZjc; arc=none smtp.client-ip=209.85.222.173 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="YhglDZjc" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-90fa736d46fso278774785a.0 for ; Tue, 19 May 2026 20:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779246243; x=1779851043; 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; bh=kovsExyDN+b4Tnm+cUXV8cO+9boS4Oqn0adESQ9JWn0=; b=YhglDZjcT1OOMYwihBsXNLmfkbFA8NIhqugUHpULC8akaoJ8XHLPWNo3UzvrKo7pjp MlzLm6MCb0oVg18PQ1DySD9370lv/1wgVoqr4QO71BzNhPbG5U6NELTLHKrFEMfXExs1 4ttvix4yPHxVsPXwi457vFMAT5Bgsq6fK+HYFXqwdIXmn/8ENENWIGhIqmj/mPTe+7AV XNRMIT2MHS4iRQL6o5JJhx023Y+vNZYi6PwZtwHB+OdXvF5W4fQE6Tgpv0CH88aGmfWT k53Ak/OU7mQM8nKcly+Z2tz2qiElJ6wBV35druXkh5jq+5f/lWGnv6rnVxl8XgM13QQv rlrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779246243; x=1779851043; 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; bh=kovsExyDN+b4Tnm+cUXV8cO+9boS4Oqn0adESQ9JWn0=; b=fo0uvzP5Pj+iu3p0m12d6rinq2j/eJ+Rv7snvvQ2x0hiuWGXUTycNR09NQS4CH+tpx HTpbvsFO/tEVogBbsxcsPuB3iEI1W4uNyoZlT0QSN/mKpEC7zAFU9G3M/PLpssLbWeKO UDXOvi6Lo7TCAS3Du8UZwjzgbSG/Jel0iCY0/weRkrSqefz2URm8ZnMOlsHP+R6JOgwj zvh0EI8GVcJJ5IDDCJRoAA9KgdArTCxTPo/9oleES0fSwM63O92dbui7aW181ujd7ECf 8BR348UAjHRel6TDADI2QZifLhg9cLGbAZtUVxdEQb+U41Q/3QSa4z5bMadG9/FEj2No kVog== X-Forwarded-Encrypted: i=1; AFNElJ93RUtLDQhp47E2ADz+mqIVSmRyMiuhiRPq1g8GmQLI/eH6pamJf2HzWDTmGiQFMOfZ28RhdAzAQrmgDNI=@vger.kernel.org X-Gm-Message-State: AOJu0YyDwmFylPts2ObKOUCc4oEfef0zLCe9pBxk4p77Ud9PjJsard72 60e3WZ0BRRUL7FnkzrSTNdDe43vVUh2xSEin5HDVboXS3mCYlqseSkTobJcQN5L69Ek= X-Gm-Gg: Acq92OG7RmbgUBiorS93UDESqtxIbSwF8B9UYiG4aR6OBkbiqGHUOJyF+jp2UbRABRJ LH3UvsKIelM5grs2J/B4hSfw7lrSJRK5XjTI/7+EihpQpIDMijS3cYEcJPSAunQ83GmAIu3yyn/ +XkGkWABlXUEZWhfUNGLP9oA1zCcNVItEskbFQH9ZjC2hyKOviXZXIjc9SyPXEMl9RrGgha2XS4 TyEIMZlPVIEIYRpkxY216ZguVzGcMfVjVRM/4D06HcoVGlieOtRgiKgSbDA5CP2uNI0gMsPmtry 44dHdKzd1c6QN6gXBLRrfXncrVA3dsY7oNRO7Z7r1625Bq7b3tEPE4j/eLrGyQqxlHuLAl6/nld ajV1lZkzDL1IiTl/x4Ot2cz6cA6uRhgF159Sh3Loh/OVcjIozRULdyIcXraaIVm8KkxMo9VzN4e 4UIDfxmN0A60GtqQuN/7x6N9smKBFD1X5IDdxcYkPb X-Received: by 2002:a05:620a:12da:b0:912:67ca:bab7 with SMTP id af79cd13be357-91267cac05amr2355066385a.2.1779246243171; Tue, 19 May 2026 20:04:03 -0700 (PDT) Received: from i4-gl-tmk5904.ad.psu.edu ([130.203.156.186]) by smtp.gmail.com with ESMTPSA id af79cd13be357-910ba36e638sm2036138285a.9.2026.05.19.20.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 20:04:02 -0700 (PDT) From: Yuho Choi To: David Ahern , Ido Schimmel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yuho Choi Subject: [PATCH v3] ipv6: route: Unregister netdevice notifier on BPF init failure Date: Tue, 19 May 2026 23:03:28 -0400 Message-ID: <20260520030329.1061183-1-dbgh9129@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: quoted-printable Content-Type: text/plain; charset="utf-8" ip6_route_init() registers ip6_route_dev_notifier before registering the IPv6 route BPF iterator target. If bpf_iter_register() fails after the notifier has been registered, the error path currently jumps to out_register_late_subsys and unwinds the RTNL handlers and pernet route state without removing the notifier from the netdevice notifier chain. This leaves ip6_route_dev_notify() callable after the IPv6 route state it uses has been torn down. Add a separate unwind label for the BPF iterator failure path and unregister the netdevice notifier before continuing with the existing cleanup. Fixes: 138d0be35b14 ("net: bpf: Add netlink and ipv6_route bpf_iter targets= ") Signed-off-by: Yuho Choi Reviewed-by: Ido Schimmel --- Chagnes since v2: - Rebase on current net/ipv6/route.c. - Keep the goto-based unwind path. - Guard the notifier unwind label with the same BPF/procfs condition. Chages since v1: - Unregister ip6_route_dev_notifier directlry in the bpf_iter_register() fa= ilure path. net/ipv6/route.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index e3d355d1fbd6..b106e5fef9cb 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -6933,7 +6933,7 @@ int __init ip6_route_init(void) #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_PROC_FS) ret =3D bpf_iter_register(); if (ret) - goto out_register_late_subsys; + goto out_register_notifier; #endif =20 for_each_possible_cpu(cpu) { @@ -6946,6 +6946,10 @@ int __init ip6_route_init(void) out: return ret; =20 +#if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_PROC_FS) +out_register_notifier: + unregister_netdevice_notifier(&ip6_route_dev_notifier); +#endif out_register_late_subsys: rtnl_unregister_all(PF_INET6); unregister_pernet_subsys(&ip6_route_net_late_ops); --=20 2.43.0