Print this page
5548 Attempt to read ACLs from Illumos NFS client is toxic


  66 {
  67 
  68         if (!xdr_u_short(xdrs, (ushort_t *)objp))
  69                 return (FALSE);
  70         return (TRUE);
  71 }
  72 
  73 bool_t
  74 xdr_aclent(XDR *xdrs, aclent_t *objp)
  75 {
  76 
  77         if (!xdr_int(xdrs, &objp->a_type))
  78                 return (FALSE);
  79         if (!xdr_uid(xdrs, &objp->a_id))
  80                 return (FALSE);
  81         if (!xdr_o_mode(xdrs, &objp->a_perm))
  82                 return (FALSE);
  83         return (TRUE);
  84 }
  85 



  86 bool_t
  87 xdr_secattr(XDR *xdrs, vsecattr_t *objp)
  88 {
  89         uint_t count;

  90 
  91         if (!xdr_u_int(xdrs, &objp->vsa_mask))
  92                 return (FALSE);
  93         if (!xdr_int(xdrs, &objp->vsa_aclcnt))








  94                 return (FALSE);
  95         if (objp->vsa_aclentp != NULL)









  96                 count = (uint_t)objp->vsa_aclcnt;
  97         else
  98                 count = 0;
  99         if (!xdr_array(xdrs, (char **)&objp->vsa_aclentp, &count,
 100             NFS_ACL_MAX_ENTRIES, sizeof (aclent_t), (xdrproc_t)xdr_aclent))
 101                 return (FALSE);


 102         if (count != 0 && count != (uint_t)objp->vsa_aclcnt) {
 103                 /*
 104                  * Assign the actual array size to vsa_aclcnt before
 105                  * aborting on error
 106                  */
 107                 objp->vsa_aclcnt = (int)count;
 108                 return (FALSE);
 109         }
 110         if (!xdr_int(xdrs, &objp->vsa_dfaclcnt))







 111                 return (FALSE);
 112         if (objp->vsa_dfaclentp != NULL)
 113                 count = (uint_t)objp->vsa_dfaclcnt;
 114         else
 115                 count = 0;
 116         if (!xdr_array(xdrs, (char **)&objp->vsa_dfaclentp, &count,
 117             NFS_ACL_MAX_ENTRIES, sizeof (aclent_t), (xdrproc_t)xdr_aclent))
 118                 return (FALSE);
 119         if (count != 0 && count != (uint_t)objp->vsa_dfaclcnt) {










 120                 /*
 121                  * Assign the actual array size to vsa_dfaclcnt before
 122                  * aborting on error
 123                  */
 124                 objp->vsa_dfaclcnt = (int)count;
 125                 return (FALSE);
 126         }














 127         return (TRUE);
 128 }
 129 
 130 bool_t
 131 xdr_GETACL2args(XDR *xdrs, GETACL2args *objp)
 132 {
 133 
 134         if (!xdr_fhandle(xdrs, &objp->fh))
 135                 return (FALSE);
 136         if (!xdr_u_int(xdrs, &objp->mask))
 137                 return (FALSE);
 138         return (TRUE);
 139 }
 140 bool_t
 141 xdr_fastGETACL2args(XDR *xdrs, GETACL2args **objpp)
 142 {
 143         int32_t *ptr;
 144 #ifdef _LITTLE_ENDIAN
 145         GETACL2args *objp;
 146 #endif




  66 {
  67 
  68         if (!xdr_u_short(xdrs, (ushort_t *)objp))
  69                 return (FALSE);
  70         return (TRUE);
  71 }
  72 
  73 bool_t
  74 xdr_aclent(XDR *xdrs, aclent_t *objp)
  75 {
  76 
  77         if (!xdr_int(xdrs, &objp->a_type))
  78                 return (FALSE);
  79         if (!xdr_uid(xdrs, &objp->a_id))
  80                 return (FALSE);
  81         if (!xdr_o_mode(xdrs, &objp->a_perm))
  82                 return (FALSE);
  83         return (TRUE);
  84 }
  85 
  86 /*
  87  * Serialize and de-serialize access control attributes
  88  */
  89 bool_t
  90 xdr_secattr(XDR *xdrs, vsecattr_t *objp)
  91 {
  92         uint_t count = 0;
  93         uint_t dfacount = 0;
  94 
  95         if (!xdr_u_int(xdrs, &objp->vsa_mask)) {
  96                 return (FALSE);
  97         }
  98 
  99         /*
 100          * Refuse request if we do not understand it completely.
 101          * There should be at least one valid bit set in the mask and
 102          * none of the unknown bits set.
 103          */
 104         if ((objp->vsa_mask &
 105                 (VSA_ACL | VSA_ACLCNT | VSA_DFACL | VSA_DFACLCNT)) == 0) {
 106             return (FALSE);
 107         }
 108         if ((objp->vsa_mask &
 109                 ~(VSA_ACL | VSA_ACLCNT | VSA_DFACL | VSA_DFACLCNT)) != 0) {
 110             return (FALSE);
 111         }
 112 
 113         if (!xdr_int(xdrs, &objp->vsa_aclcnt)) {
 114                 return (FALSE);
 115         }
 116         if (objp->vsa_aclentp != NULL) {
 117                 count = (uint_t)objp->vsa_aclcnt;
 118         }
 119 
 120         if (!xdr_array(xdrs, (char **)&objp->vsa_aclentp, &count,
 121             NFS_ACL_MAX_ENTRIES, sizeof (aclent_t), (xdrproc_t)xdr_aclent)) {
 122                 return (FALSE);
 123         }
 124 
 125         if (count != 0 && count != (uint_t)objp->vsa_aclcnt) {
 126                 /*
 127                  * Assign the actual array size to vsa_aclcnt before
 128                  * aborting on error
 129                  */
 130                 objp->vsa_aclcnt = (int)count;
 131                 return (FALSE);
 132         }
 133 
 134         /*
 135          * For VSA_ACL the count should be zero or there should
 136          * be array attached.
 137          */
 138         if ((objp->vsa_mask & VSA_ACL) != 0) {
 139                 if ((objp->vsa_aclcnt != 0) && (objp->vsa_aclentp == NULL)) {
 140                         objp->vsa_aclcnt = 0;
 141                         return (FALSE);
 142                 }
 143         }
 144 
 145         if (!xdr_int(xdrs, &objp->vsa_dfaclcnt)) {


 146                 return (FALSE);
 147         }
 148         if (objp->vsa_dfaclentp != NULL) {
 149                 dfacount = (uint_t)objp->vsa_dfaclcnt;
 150         }
 151 
 152         if (!xdr_array(xdrs, (char **)&objp->vsa_dfaclentp, &dfacount,
 153             NFS_ACL_MAX_ENTRIES, sizeof (aclent_t), (xdrproc_t)xdr_aclent)) {
 154                 return (FALSE);
 155         }
 156 
 157         if (dfacount != 0 && dfacount != (uint_t)objp->vsa_dfaclcnt) {
 158                 /*
 159                  * Assign the actual array size to vsa_dfaclcnt before
 160                  * aborting on error
 161                  */
 162                 objp->vsa_dfaclcnt = (int)dfacount;
 163                 return (FALSE);
 164         }
 165 
 166         /*
 167          * for VSA_DFACL The count should be zero or there should
 168          * be array attached
 169          */
 170         if ((objp->vsa_mask & VSA_DFACL) != 0) {
 171                 if ((objp->vsa_dfaclcnt != 0) &&
 172                     (objp->vsa_dfaclentp == NULL)) {
 173                         objp->vsa_dfaclcnt = 0;
 174                         return (FALSE);
 175                 }
 176         }
 177 
 178 
 179         return (TRUE);
 180 }
 181 
 182 bool_t
 183 xdr_GETACL2args(XDR *xdrs, GETACL2args *objp)
 184 {
 185 
 186         if (!xdr_fhandle(xdrs, &objp->fh))
 187                 return (FALSE);
 188         if (!xdr_u_int(xdrs, &objp->mask))
 189                 return (FALSE);
 190         return (TRUE);
 191 }
 192 bool_t
 193 xdr_fastGETACL2args(XDR *xdrs, GETACL2args **objpp)
 194 {
 195         int32_t *ptr;
 196 #ifdef _LITTLE_ENDIAN
 197         GETACL2args *objp;
 198 #endif