Print this page
NEX-14051 Be careful with RPC groups
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
8085 Handle RPC groups better
Reviewed by: "Joshua M. Clulow" <josh@sysmgr.org>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Approved by: Dan McDonald <danmcd@omniti.com>
OS-20 share_nfs(1m) charset handling is unreliable
OS-22 Page fault at nfscmd_dropped_entrysize+0x1e()
OS-23 NFSv2/3/4: READDIR responses are inconsistent when charset conversion fails
OS-24 rfs3_readdir(): Issues related to nfscmd_convdirent()
Reviewed by: Jan Kryl <jan.kryl@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>


   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2017 Joyent Inc
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 




  27 #include <sys/types.h>
  28 #include <sys/systm.h>
  29 #include <sys/cmn_err.h>
  30 #include <sys/kmem.h>
  31 #include <sys/cred.h>
  32 #include <sys/dirent.h>
  33 #include <sys/debug.h>
  34 #include <rpc/types.h>
  35 #include <nfs/nfs.h>
  36 #include <nfs/export.h>
  37 #include <rpc/svc.h>
  38 #include <rpc/xdr.h>
  39 #include <rpc/rpcb_prot.h>
  40 #include <rpc/clnt.h>
  41 #include <nfs/nfs_log.h>
  42 
  43 /*
  44  * nfsl_principal_name_get - extracts principal from transport struct.
  45  * Based on "uts/common/rpc/sec/sec_svc.c" function sec_svc_getcred.
  46  */


 777 {
 778         return (xdr_nfslog_nfs_fh3(xdrs, &objp->dir));
 779 }
 780 
 781 bool_t
 782 xdr_nfslog_READDIR3res(XDR *xdrs, READDIR3res *objp)
 783 {
 784         return (xdr_enum(xdrs, (enum_t *)&objp->status));
 785 }
 786 
 787 bool_t
 788 xdr_nfslog_READDIRPLUS3args(XDR *xdrs, READDIRPLUS3args *objp)
 789 {
 790         if (!xdr_nfslog_nfs_fh3(xdrs, &objp->dir))
 791                 return (FALSE);
 792         if (!xdr_uint32(xdrs, &objp->dircount))
 793                 return (FALSE);
 794         return (xdr_uint32(xdrs, &objp->maxcount));
 795 }
 796 
 797 #ifdef  nextdp
 798 #undef  nextdp
 799 #endif
 800 #define nextdp(dp)      ((struct dirent64 *)((char *)(dp) + (dp)->d_reclen))
 801 
 802 bool_t
 803 xdr_nfslog_READDIRPLUS3resok(XDR *xdrs, READDIRPLUS3resok *objp)
 804 {
 805         struct dirent64 *dp;
 806         bool_t true = TRUE;
 807         bool_t false = FALSE;
 808         int nents;
 809         char *name;
 810         entryplus3_info *infop;
 811 
 812         dp = (struct dirent64 *)objp->reply.entries;
 813         nents = objp->size;
 814         infop = objp->infop;
 815         while (nents > 0) {
 816                 if (dp->d_reclen == 0)
 817                         return (FALSE);
 818                 if (dp->d_ino == 0) {
 819                         dp = nextdp(dp);
 820                         infop++;
 821                         nents--;
 822                         continue;
 823                 }
 824                 name = dp->d_name;
 825 
 826                 if (!xdr_bool(xdrs, &true) ||
 827                     !xdr_post_op_fh3(xdrs, &infop->fh) ||
 828                     !xdr_string(xdrs, &name, ~0)) {
 829                         return (FALSE);
 830                 }
 831                 dp = nextdp(dp);
 832                 infop++;
 833                 nents--;
 834         }

 835         if (!xdr_bool(xdrs, &false))
 836                 return (FALSE);
 837 
 838         return (xdr_bool(xdrs, &objp->reply.eof));
 839 }
 840 
 841 bool_t
 842 xdr_nfslog_READDIRPLUS3res(XDR *xdrs, READDIRPLUS3res *objp)
 843 {
 844         if (!xdr_enum(xdrs, (enum_t *)&objp->status))
 845                 return (FALSE);
 846         switch (objp->status) {
 847         case NFS3_OK:
 848                 if (!xdr_nfslog_READDIRPLUS3resok(xdrs, &objp->res_u.ok))
 849                         return (FALSE);
 850                 break;
 851         }
 852         return (TRUE);
 853 }
 854 




   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2017 Joyent Inc
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/systm.h>
  33 #include <sys/cmn_err.h>
  34 #include <sys/kmem.h>
  35 #include <sys/cred.h>
  36 #include <sys/dirent.h>
  37 #include <sys/debug.h>
  38 #include <rpc/types.h>
  39 #include <nfs/nfs.h>
  40 #include <nfs/export.h>
  41 #include <rpc/svc.h>
  42 #include <rpc/xdr.h>
  43 #include <rpc/rpcb_prot.h>
  44 #include <rpc/clnt.h>
  45 #include <nfs/nfs_log.h>
  46 
  47 /*
  48  * nfsl_principal_name_get - extracts principal from transport struct.
  49  * Based on "uts/common/rpc/sec/sec_svc.c" function sec_svc_getcred.
  50  */


 781 {
 782         return (xdr_nfslog_nfs_fh3(xdrs, &objp->dir));
 783 }
 784 
 785 bool_t
 786 xdr_nfslog_READDIR3res(XDR *xdrs, READDIR3res *objp)
 787 {
 788         return (xdr_enum(xdrs, (enum_t *)&objp->status));
 789 }
 790 
 791 bool_t
 792 xdr_nfslog_READDIRPLUS3args(XDR *xdrs, READDIRPLUS3args *objp)
 793 {
 794         if (!xdr_nfslog_nfs_fh3(xdrs, &objp->dir))
 795                 return (FALSE);
 796         if (!xdr_uint32(xdrs, &objp->dircount))
 797                 return (FALSE);
 798         return (xdr_uint32(xdrs, &objp->maxcount));
 799 }
 800 





 801 bool_t
 802 xdr_nfslog_READDIRPLUS3resok(XDR *xdrs, READDIRPLUS3resok *objp)
 803 {
 804         entryplus3 *entry;
 805         bool_t true = TRUE;
 806         bool_t false = FALSE;



 807 
 808         for (entry = objp->reply.entries; entry != NULL;
 809             entry = entry->nextentry) {












 810                 if (!xdr_bool(xdrs, &true) ||
 811                     !xdr_post_op_fh3(xdrs, &entry->name_handle) ||
 812                     !xdr_string(xdrs, &entry->name, MAXPATHLEN)) {
 813                         return (FALSE);
 814                 }



 815         }
 816 
 817         if (!xdr_bool(xdrs, &false))
 818                 return (FALSE);
 819 
 820         return (xdr_bool(xdrs, &objp->reply.eof));
 821 }
 822 
 823 bool_t
 824 xdr_nfslog_READDIRPLUS3res(XDR *xdrs, READDIRPLUS3res *objp)
 825 {
 826         if (!xdr_enum(xdrs, (enum_t *)&objp->status))
 827                 return (FALSE);
 828         switch (objp->status) {
 829         case NFS3_OK:
 830                 if (!xdr_nfslog_READDIRPLUS3resok(xdrs, &objp->res_u.ok))
 831                         return (FALSE);
 832                 break;
 833         }
 834         return (TRUE);
 835 }
 836