Print this page
Hyperaggressive asserts pt 2/N
Be far more judicious in the use of curzone-using macros.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/nfs/nfs4_srv.c
          +++ new/usr/src/uts/common/fs/nfs/nfs4_srv.c
↓ open down ↓ 945 lines elided ↑ open up ↑
 946  946  /*
 947  947   * Used by rfs4_op_secinfo to get the security information from the
 948  948   * export structure associated with the component.
 949  949   */
 950  950  /* ARGSUSED */
 951  951  static nfsstat4
 952  952  do_rfs4_op_secinfo(struct compound_state *cs, char *nm, SECINFO4res *resp)
 953  953  {
 954  954          int error, different_export = 0;
 955  955          vnode_t *dvp, *vp;
 956      -        struct exportinfo *exi = NULL;
      956 +        struct exportinfo *exi;
 957  957          fid_t fid;
 958  958          uint_t count, i;
 959  959          secinfo4 *resok_val;
 960  960          struct secinfo *secp;
 961  961          seconfig_t *si;
 962  962          bool_t did_traverse = FALSE;
 963  963          int dotdot, walk;
 964  964          nfs_export_t *ne = nfs_get_export();
 965  965  
 966  966          dvp = cs->vp;
      967 +        exi = cs->exi;
      968 +        ASSERT(exi != NULL);
 967  969          dotdot = (nm[0] == '.' && nm[1] == '.' && nm[2] == '\0');
 968  970  
 969  971          /*
 970  972           * If dotdotting, then need to check whether it's above the
 971  973           * root of a filesystem, or above an export point.
 972  974           */
 973  975          if (dotdot) {
 974      -
      976 +                ASSERT3U(exi->exi_zoneid, ==, curzone->zone_id);
 975  977                  /*
 976  978                   * If dotdotting at the root of a filesystem, then
 977  979                   * need to traverse back to the mounted-on filesystem
 978  980                   * and do the dotdot lookup there.
 979  981                   */
 980      -                if ((cs->vp->v_flag & VROOT) || VN_IS_CURZONEROOT(cs->vp)) {
      982 +                if ((dvp->v_flag & VROOT) || VN_IS_CURZONEROOT(dvp)) {
 981  983  
 982  984                          /*
 983  985                           * If at the system root, then can
 984  986                           * go up no further.
 985  987                           */
 986  988                          if (VN_CMP(dvp, ZONE_ROOTVP()))
 987  989                                  return (puterrno4(ENOENT));
 988  990  
 989  991                          /*
 990  992                           * Traverse back to the mounted-on filesystem
 991  993                           */
 992      -                        dvp = untraverse(cs->vp);
      994 +                        dvp = untraverse(dvp);
 993  995  
 994  996                          /*
 995  997                           * Set the different_export flag so we remember
 996  998                           * to pick up a new exportinfo entry for
 997  999                           * this new filesystem.
 998 1000                           */
 999 1001                          different_export = 1;
1000 1002                  } else {
1001 1003  
1002 1004                          /*
1003 1005                           * If dotdotting above an export point then set
1004 1006                           * the different_export to get new export info.
1005 1007                           */
1006      -                        different_export = nfs_exported(cs->exi, cs->vp);
     1008 +                        different_export = nfs_exported(exi, dvp);
1007 1009                  }
1008 1010          }
1009 1011  
1010 1012          /*
1011 1013           * Get the vnode for the component "nm".
1012 1014           */
1013 1015          error = VOP_LOOKUP(dvp, nm, &vp, NULL, 0, NULL, cs->cr,
1014 1016              NULL, NULL, NULL);
1015 1017          if (error)
1016 1018                  return (puterrno4(error));
1017 1019  
1018 1020          /*
1019 1021           * If the vnode is in a pseudo filesystem, or if the security flavor
1020 1022           * used in the request is valid but not an explicitly shared flavor,
1021 1023           * or the access bit indicates that this is a limited access,
1022 1024           * check whether this vnode is visible.
1023 1025           */
1024 1026          if (!different_export &&
1025      -            (PSEUDO(cs->exi) || ! is_exported_sec(cs->nfsflavor, cs->exi) ||
     1027 +            (PSEUDO(exi) || !is_exported_sec(cs->nfsflavor, exi) ||
1026 1028              cs->access & CS_ACCESS_LIMITED)) {
1027      -                if (! nfs_visible(cs->exi, vp, &different_export)) {
     1029 +                if (! nfs_visible(exi, vp, &different_export)) {
1028 1030                          VN_RELE(vp);
1029 1031                          return (puterrno4(ENOENT));
1030 1032                  }
1031 1033          }
1032 1034  
1033 1035          /*
1034 1036           * If it's a mountpoint, then traverse it.
1035 1037           */
1036 1038          if (vn_ismntpt(vp)) {
1037 1039                  if ((error = traverse(&vp)) != 0) {
↓ open down ↓ 21 lines elided ↑ open up ↑
1059 1061          if (different_export) {
1060 1062  
1061 1063                  bzero(&fid, sizeof (fid));
1062 1064                  fid.fid_len = MAXFIDSZ;
1063 1065                  error = vop_fid_pseudo(vp, &fid);
1064 1066                  if (error) {
1065 1067                          VN_RELE(vp);
1066 1068                          return (puterrno4(error));
1067 1069                  }
1068 1070  
     1071 +                /* We'll need to reassign "exi". */
1069 1072                  if (dotdot)
1070 1073                          exi = nfs_vptoexi(NULL, vp, cs->cr, &walk, NULL, TRUE);
1071 1074                  else
1072 1075                          exi = checkexport4(&vp->v_vfsp->vfs_fsid, &fid, vp);
1073 1076  
1074 1077                  if (exi == NULL) {
1075 1078                          if (did_traverse == TRUE) {
1076 1079                                  /*
1077 1080                                   * If this vnode is a mounted-on vnode,
1078 1081                                   * but the mounted-on file system is not
1079 1082                                   * exported, send back the secinfo for
1080 1083                                   * the exported node that the mounted-on
1081 1084                                   * vnode lives in.
1082 1085                                   */
1083 1086                                  exi = cs->exi;
1084 1087                          } else {
1085 1088                                  VN_RELE(vp);
1086 1089                                  return (puterrno4(EACCES));
1087 1090                          }
1088 1091                  }
1089      -        } else {
1090      -                exi = cs->exi;
1091 1092          }
1092 1093          ASSERT(exi != NULL);
1093 1094  
1094 1095  
1095 1096          /*
1096 1097           * Create the secinfo result based on the security information
1097 1098           * from the exportinfo structure (exi).
1098 1099           *
1099 1100           * Return all flavors for a pseudo node.
1100 1101           * For a real export node, return the flavor that the client
↓ open down ↓ 1610 lines elided ↑ open up ↑
2711 2712          }
2712 2713  
2713 2714          dotdot = (nm[0] == '.' && nm[1] == '.' && nm[2] == '\0');
2714 2715  
2715 2716          /*
2716 2717           * If dotdotting, then need to check whether it's
2717 2718           * above the root of a filesystem, or above an
2718 2719           * export point.
2719 2720           */
2720 2721          if (dotdot) {
2721      -
     2722 +                ASSERT(cs->exi != NULL);
     2723 +                ASSERT3U(cs->exi->exi_zoneid, ==, curzone->zone_id);
2722 2724                  /*
2723 2725                   * If dotdotting at the root of a filesystem, then
2724 2726                   * need to traverse back to the mounted-on filesystem
2725 2727                   * and do the dotdot lookup there.
2726 2728                   */
2727 2729                  if ((cs->vp->v_flag & VROOT) || VN_IS_CURZONEROOT(cs->vp)) {
2728 2730  
2729 2731                          /*
2730 2732                           * If at the system root, then can
2731 2733                           * go up no further.
↓ open down ↓ 7374 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX