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

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 ↓ 835 lines elided ↑ open up ↑
 836  836                      int, retries);
 837  837                  error = ENOENT;
 838  838                  goto error;
 839  839          }
 840  840  
 841  841          /*
 842  842           * Create an RPC handle that'll be used for communication with local
 843  843           * statd using the status monitor protocol.
 844  844           */
 845  845          error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS,
 846      -            0, NLM_RPC_RETRIES, kcred, &nsm->ns_handle);
      846 +            0, NLM_RPC_RETRIES, zone_kcred(), &nsm->ns_handle);
 847  847          if (error != 0)
 848  848                  goto error;
 849  849  
 850  850          /*
 851  851           * Create an RPC handle that'll be used for communication with the
 852  852           * local statd using the address registration protocol.
 853  853           */
 854  854          error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM,
 855      -            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, kcred, &nsm->ns_addr_handle);
      855 +            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, zone_kcred(),
      856 +            &nsm->ns_addr_handle);
 856  857          if (error != 0)
 857  858                  goto error;
 858  859  
 859  860          sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL);
 860  861          return (0);
 861  862  
 862  863  error:
 863  864          kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
 864      -        if (nsm->ns_handle)
      865 +        if (nsm->ns_handle) {
      866 +                ASSERT(nsm->ns_handle->cl_auth != NULL);
      867 +                auth_destroy(nsm->ns_handle->cl_auth);
 865  868                  CLNT_DESTROY(nsm->ns_handle);
      869 +        }
 866  870  
 867  871          return (error);
 868  872  }
 869  873  
 870  874  static void
 871  875  nlm_nsm_fini(struct nlm_nsm *nsm)
 872  876  {
 873  877          kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
      878 +        if (nsm->ns_addr_handle->cl_auth != NULL)
      879 +                auth_destroy(nsm->ns_addr_handle->cl_auth);
 874  880          CLNT_DESTROY(nsm->ns_addr_handle);
 875  881          nsm->ns_addr_handle = NULL;
      882 +        if (nsm->ns_handle->cl_auth != NULL)
      883 +                auth_destroy(nsm->ns_handle->cl_auth);
 876  884          CLNT_DESTROY(nsm->ns_handle);
 877  885          nsm->ns_handle = NULL;
 878  886          sema_destroy(&nsm->ns_sem);
 879  887  }
 880  888  
 881  889  static enum clnt_stat
 882  890  nlm_nsm_simu_crash(struct nlm_nsm *nsm)
 883  891  {
 884  892          enum clnt_stat stat;
 885  893  
↓ open down ↓ 1734 lines elided ↑ open up ↑
2620 2628          mutex_exit(&g->lock);
2621 2629  }
2622 2630  
2623 2631  void
2624 2632  nlm_unexport(struct exportinfo *exi)
2625 2633  {
2626 2634          struct nlm_globals *g;
2627 2635  
2628 2636          rw_enter(&lm_lck, RW_READER);
2629 2637          TAILQ_FOREACH(g, &nlm_zones_list, nlm_link) {
2630      -                if (g->nlm_zoneid != exi->exi_zoneid)
2631      -                        continue;
2632      -                nlm_zone_unexport(g, exi);
     2638 +                if (g->nlm_zoneid == exi->exi_zoneid) {
     2639 +                        /*
     2640 +                         * NOTE: If we want to drop lm_lock before
     2641 +                         * calling nlm_zone_unexport(), we should break,
     2642 +                         * and have a post-rw_exit() snippit like:
     2643 +                         *      if (g != NULL)
     2644 +                         *              nlm_zone_unexport(g, exi);
     2645 +                         */
     2646 +                        nlm_zone_unexport(g, exi);
     2647 +                        break; /* Only going to match once! */
     2648 +                }
2633 2649          }
2634 2650          rw_exit(&lm_lck);
2635 2651  }
2636 2652  
2637 2653  /*
2638 2654   * Allocate new unique sysid.
2639 2655   * In case of failure (no available sysids)
2640 2656   * return LM_NOSYSID.
2641 2657   */
2642 2658  sysid_t
↓ open down ↓ 152 lines elided ↑ open up ↑
2795 2811          TAILQ_FOREACH(g, &nlm_zones_list, nlm_link)
2796 2812                  nlm_resume_zone(g);
2797 2813  
2798 2814          rw_exit(&lm_lck);
2799 2815  }
2800 2816  
2801 2817  static void
2802 2818  nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
2803 2819  {
2804 2820          (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
2805      -            NLM_RPC_RETRIES, kcred);
     2821 +            NLM_RPC_RETRIES, zone_kcred());
2806 2822  }
2807 2823  
2808 2824  static void
2809 2825  nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
2810 2826  {
2811 2827          /* LINTED pointer alignment */
2812 2828          struct sockaddr *sa = (struct sockaddr *)addr->buf;
2813 2829  
2814 2830          *family = sa->sa_family;
2815 2831  
↓ open down ↓ 24 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX