Print this page
Zone ID only matches once, don't loop after a match
Two NLM fixes: use zone_kcred() and plug cl_auth leaks

*** 841,880 **** /* * Create an RPC handle that'll be used for communication with local * statd using the status monitor protocol. */ error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS, ! 0, NLM_RPC_RETRIES, kcred, &nsm->ns_handle); if (error != 0) goto error; /* * Create an RPC handle that'll be used for communication with the * local statd using the address registration protocol. */ error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM, ! NSM_ADDR_V1, 0, NLM_RPC_RETRIES, kcred, &nsm->ns_addr_handle); if (error != 0) goto error; sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL); return (0); error: kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen); ! if (nsm->ns_handle) CLNT_DESTROY(nsm->ns_handle); return (error); } static void nlm_nsm_fini(struct nlm_nsm *nsm) { kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen); CLNT_DESTROY(nsm->ns_addr_handle); nsm->ns_addr_handle = NULL; CLNT_DESTROY(nsm->ns_handle); nsm->ns_handle = NULL; sema_destroy(&nsm->ns_sem); } --- 841,888 ---- /* * Create an RPC handle that'll be used for communication with local * statd using the status monitor protocol. */ error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS, ! 0, NLM_RPC_RETRIES, zone_kcred(), &nsm->ns_handle); if (error != 0) goto error; /* * Create an RPC handle that'll be used for communication with the * local statd using the address registration protocol. */ error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM, ! NSM_ADDR_V1, 0, NLM_RPC_RETRIES, zone_kcred(), ! &nsm->ns_addr_handle); if (error != 0) goto error; sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL); return (0); error: kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen); ! if (nsm->ns_handle) { ! ASSERT(nsm->ns_handle->cl_auth != NULL); ! auth_destroy(nsm->ns_handle->cl_auth); CLNT_DESTROY(nsm->ns_handle); + } return (error); } static void nlm_nsm_fini(struct nlm_nsm *nsm) { kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen); + if (nsm->ns_addr_handle->cl_auth != NULL) + auth_destroy(nsm->ns_addr_handle->cl_auth); CLNT_DESTROY(nsm->ns_addr_handle); nsm->ns_addr_handle = NULL; + if (nsm->ns_handle->cl_auth != NULL) + auth_destroy(nsm->ns_handle->cl_auth); CLNT_DESTROY(nsm->ns_handle); nsm->ns_handle = NULL; sema_destroy(&nsm->ns_sem); }
*** 2625,2638 **** { struct nlm_globals *g; rw_enter(&lm_lck, RW_READER); TAILQ_FOREACH(g, &nlm_zones_list, nlm_link) { ! if (g->nlm_zoneid != exi->exi_zoneid) ! continue; nlm_zone_unexport(g, exi); } rw_exit(&lm_lck); } /* * Allocate new unique sysid. --- 2633,2654 ---- { struct nlm_globals *g; rw_enter(&lm_lck, RW_READER); TAILQ_FOREACH(g, &nlm_zones_list, nlm_link) { ! if (g->nlm_zoneid == exi->exi_zoneid) { ! /* ! * NOTE: If we want to drop lm_lock before ! * calling nlm_zone_unexport(), we should break, ! * and have a post-rw_exit() snippit like: ! * if (g != NULL) ! * nlm_zone_unexport(g, exi); ! */ nlm_zone_unexport(g, exi); + break; /* Only going to match once! */ } + } rw_exit(&lm_lck); } /* * Allocate new unique sysid.
*** 2800,2810 **** static void nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm) { (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0, ! NLM_RPC_RETRIES, kcred); } static void nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj) { --- 2816,2826 ---- static void nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm) { (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0, ! NLM_RPC_RETRIES, zone_kcred()); } static void nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj) {