socket: Release cred reference later in sodealloc()

We dereference so->so_cred to update the per-uid socket buffer
accounting, so the crfree() call must be deferred until after that
point.

PR:		255869

(cherry picked from commit b295c5ddce)
This commit is contained in:
Lv Yunlong 2021-05-18 15:23:15 -04:00 committed by Mark Johnston
parent b1304759ec
commit e53b671b4f

View file

@ -475,7 +475,6 @@ sodealloc(struct socket *so)
#endif
hhook_run_socket(so, NULL, HHOOK_SOCKET_CLOSE);
crfree(so->so_cred);
khelp_destroy_osd(&so->osd);
if (SOLISTENING(so)) {
if (so->sol_accept_filter != NULL)
@ -492,6 +491,7 @@ sodealloc(struct socket *so)
SOCKBUF_LOCK_DESTROY(&so->so_snd);
SOCKBUF_LOCK_DESTROY(&so->so_rcv);
}
crfree(so->so_cred);
mtx_destroy(&so->so_lock);
uma_zfree(socket_zone, so);
}