Netdev List
 help / color / mirror / Atom feed
* [PATCH net v1] sctp: Unwind address notifier registration on failure
@ 2026-06-08 16:22 Yuho Choi
  2026-06-10 15:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-06-08 16:22 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner, Xin Long, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, linux-sctp, netdev, linux-kernel, Yuho Choi

sctp_v4_add_protocol() and sctp_v6_add_protocol() register their
address notifiers before registering the SCTP protocol handlers. If
protocol registration fails, the functions return without unregistering
the notifiers.

Unregister the notifiers on the protocol registration failure paths.
Also propagate notifier registration failures instead of ignoring them.

Fixes: 827bf12236fb ("[SCTP]: Re-order SCTP initializations to avoid race with sctp_rcv()")
Fixes: 270637abff0c ("[SCTP]: Fix a race between module load and protosw access")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 net/sctp/ipv6.c     | 10 ++++++++--
 net/sctp/protocol.c | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index cd15b695607e..ef26878f1282 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -1176,11 +1176,17 @@ void sctp_v6_protosw_exit(void)
 /* Register with inet6 layer. */
 int sctp_v6_add_protocol(void)
 {
+	int ret;
+
 	/* Register notifier for inet6 address additions/deletions. */
-	register_inet6addr_notifier(&sctp_inet6addr_notifier);
+	ret = register_inet6addr_notifier(&sctp_inet6addr_notifier);
+	if (ret)
+		return ret;
 
-	if (inet6_add_protocol(&sctpv6_protocol, IPPROTO_SCTP) < 0)
+	if (inet6_add_protocol(&sctpv6_protocol, IPPROTO_SCTP) < 0) {
+		unregister_inet6addr_notifier(&sctp_inet6addr_notifier);
 		return -EAGAIN;
+	}
 
 	return 0;
 }
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 5800e7ee7ea0..6153340f1b45 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1263,12 +1263,18 @@ static void sctp_v4_protosw_exit(void)
 
 static int sctp_v4_add_protocol(void)
 {
+	int ret;
+
 	/* Register notifier for inet address additions/deletions. */
-	register_inetaddr_notifier(&sctp_inetaddr_notifier);
+	ret = register_inetaddr_notifier(&sctp_inetaddr_notifier);
+	if (ret)
+		return ret;
 
 	/* Register SCTP with inet layer.  */
-	if (inet_add_protocol(&sctp_protocol, IPPROTO_SCTP) < 0)
+	if (inet_add_protocol(&sctp_protocol, IPPROTO_SCTP) < 0) {
+		unregister_inetaddr_notifier(&sctp_inetaddr_notifier);
 		return -EAGAIN;
+	}
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net v1] sctp: Unwind address notifier registration on failure
  2026-06-08 16:22 [PATCH net v1] sctp: Unwind address notifier registration on failure Yuho Choi
@ 2026-06-10 15:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-10 15:40 UTC (permalink / raw)
  To: Yuho Choi
  Cc: marcelo.leitner, lucien.xin, davem, edumazet, kuba, pabeni, horms,
	linux-sctp, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon,  8 Jun 2026 12:22:30 -0400 you wrote:
> sctp_v4_add_protocol() and sctp_v6_add_protocol() register their
> address notifiers before registering the SCTP protocol handlers. If
> protocol registration fails, the functions return without unregistering
> the notifiers.
> 
> Unregister the notifiers on the protocol registration failure paths.
> Also propagate notifier registration failures instead of ignoring them.
> 
> [...]

Here is the summary with links:
  - [net,v1] sctp: Unwind address notifier registration on failure
    https://git.kernel.org/netdev/net-next/c/c8459ee2fef5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-10 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08 16:22 [PATCH net v1] sctp: Unwind address notifier registration on failure Yuho Choi
2026-06-10 15:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox