Re: [PATCH net v3 1/2] sctp: avoid auth_enable sysctl UAF during netns teardown
From: Xin Long <lucien.xin@gmail.com>
Date: 2026-07-16 13:31:47
Also in:
linux-sctp
On Tue, Jul 14, 2026 at 9:50 PM Ren Wei [off-list ref] wrote:
From: Zhiling Zou <redacted>
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_enable
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 unregister
helper.
Fixes: 15649fd5415e ("sctp: sysctl: auth_enable: avoid using current->nsproxy")
Cc: stable@vger.kernel.org
Reported-by: Yuan Tan <redacted>
Reported-by: Yifan Wu <redacted>
Reported-by: Juefei Pu <redacted>
Reported-by: Xin Liu <redacted>
Co-developed-by: Qi Tang <redacted>
Signed-off-by: Qi Tang <redacted>
Signed-off-by: Zhiling Zou <redacted>
Signed-off-by: Ren Wei <redacted>Acked-by: Xin Long <lucien.xin@gmail.com>