Re: [PATCH net v3 1/2] sctp: avoid auth_enable sysctl UAF during netns teardown
Xin Long <[email protected]> Thu, 16 Jul 2026 09:31:35 -0400
| Newsgroups | org.kernel.vger.linux-sctp,org.kernel.vger.netdev |
|---|---|
| Message-ID | <CADvbK_f7du2s28mJ=DsFm6dE8u5xaSbd=EG_5sL+-HKYfUuCcQ@mail.gmail.com> |
On Tue, Jul 14, 2026 at 9:50=E2=80=AFPM Ren Wei <[email protected]> wrote: > > From: Zhiling Zou <[email protected]> > > proc_sctp_do_auth() updates the SCTP control socket after changing > net.sctp.auth_enable. The handler gets the per-net SCTP state from > ctl->data, so an already opened sysctl file can still target a network > namespace while that namespace is being torn down. > > SCTP previously registered its per-net sysctls from sctp_defaults_init(), > while the control socket is created later from sctp_ctrlsock_init(). This > exposed a window during initialization where auth_enable was writable > before net->sctp.ctl_sock existed, and a teardown window where auth_enabl= e > stayed writable after inet_ctl_sock_destroy() had released the control > socket. > > Move the per-net SCTP sysctl registration into sctp_ctrlsock_init() after > sctp_ctl_sock_init() succeeds, and unregister the sysctl table before > destroying the control socket in sctp_ctrlsock_exit(). If sysctl > registration fails after the control socket was created, destroy the > control socket in the same init path. > > Make sctp_sysctl_net_unregister() tolerate a missing header and clear the > saved pointer so init-error and exit paths can safely share the unregiste= r > helper. > > Fixes: 15649fd5415e ("sctp: sysctl: auth_enable: avoid using current->nsp= roxy") > Cc: [email protected] > Reported-by: Yuan Tan <[email protected]> > Reported-by: Yifan Wu <[email protected]> > Reported-by: Juefei Pu <[email protected]> > Reported-by: Xin Liu <[email protected]> > Co-developed-by: Qi Tang <[email protected]> > Signed-off-by: Qi Tang <[email protected]> > Signed-off-by: Zhiling Zou <[email protected]> > Signed-off-by: Ren Wei <[email protected]> Acked-by: Xin Long <[email protected]>