Print this page
Two NLM fixes: use zone_kcred() and plug cl_auth leaks

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/klm/nlm_impl.c
          +++ new/usr/src/uts/common/klm/nlm_impl.c
↓ open down ↓ 841 lines elided ↑ open up ↑
 842  842                      int, retries);
 843  843                  error = ENOENT;
 844  844                  goto error;
 845  845          }
 846  846  
 847  847          /*
 848  848           * Create an RPC handle that'll be used for communication with local
 849  849           * statd using the status monitor protocol.
 850  850           */
 851  851          error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS,
 852      -            0, NLM_RPC_RETRIES, kcred, &nsm->ns_handle);
      852 +            0, NLM_RPC_RETRIES, zone_kcred(), &nsm->ns_handle);
 853  853          if (error != 0)
 854  854                  goto error;
 855  855  
 856  856          /*
 857  857           * Create an RPC handle that'll be used for communication with the
 858  858           * local statd using the address registration protocol.
 859  859           */
 860  860          error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM,
 861      -            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, kcred, &nsm->ns_addr_handle);
      861 +            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, zone_kcred(),
      862 +            &nsm->ns_addr_handle);
 862  863          if (error != 0)
 863  864                  goto error;
 864  865  
 865  866          sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL);
 866  867          return (0);
 867  868  
 868  869  error:
 869  870          kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
 870      -        if (nsm->ns_handle)
      871 +        if (nsm->ns_handle) {
      872 +                ASSERT(nsm->ns_handle->cl_auth != NULL);
      873 +                auth_destroy(nsm->ns_handle->cl_auth);
 871  874                  CLNT_DESTROY(nsm->ns_handle);
      875 +        }
 872  876  
 873  877          return (error);
 874  878  }
 875  879  
 876  880  static void
 877  881  nlm_nsm_fini(struct nlm_nsm *nsm)
 878  882  {
 879  883          kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
      884 +        if (nsm->ns_addr_handle->cl_auth != NULL)
      885 +                auth_destroy(nsm->ns_addr_handle->cl_auth);
 880  886          CLNT_DESTROY(nsm->ns_addr_handle);
 881  887          nsm->ns_addr_handle = NULL;
      888 +        if (nsm->ns_handle->cl_auth != NULL)
      889 +                auth_destroy(nsm->ns_handle->cl_auth);
 882  890          CLNT_DESTROY(nsm->ns_handle);
 883  891          nsm->ns_handle = NULL;
 884  892          sema_destroy(&nsm->ns_sem);
 885  893  }
 886  894  
 887  895  static enum clnt_stat
 888  896  nlm_nsm_simu_crash(struct nlm_nsm *nsm)
 889  897  {
 890  898          enum clnt_stat stat;
 891  899  
↓ open down ↓ 1909 lines elided ↑ open up ↑
2801 2809          TAILQ_FOREACH(g, &nlm_zones_list, nlm_link)
2802 2810                  nlm_resume_zone(g);
2803 2811  
2804 2812          rw_exit(&lm_lck);
2805 2813  }
2806 2814  
2807 2815  void
2808 2816  nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
2809 2817  {
2810 2818          (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
2811      -            NLM_RPC_RETRIES, kcred);
     2819 +            NLM_RPC_RETRIES, zone_kcred());
2812 2820  }
2813 2821  
2814 2822  void
2815 2823  nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
2816 2824  {
2817 2825          /* LINTED pointer alignment */
2818 2826          struct sockaddr *sa = (struct sockaddr *)addr->buf;
2819 2827  
2820 2828          *family = sa->sa_family;
2821 2829  
↓ open down ↓ 24 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX