Print this page
3354 kernel crash in rpcsec_gss after using gsscred
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Carlos Neira <cneirabustos@gmail.com>
Approved by: Robert Mustacchi <rm@joyent.com>
NEX-4123 xdrmblk_getpos() is unreliable
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
re #13613 rb4516 Tunables needs volatile keyword


   6  * You may not use this file except in compliance with the License.
   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 /*
  23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24  *  Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  25  * Copyright (c) 2012 by Delphix. All rights reserved.


  26  */
  27 
  28 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  29 /*        All Rights Reserved   */
  30 
  31 /*
  32  * Portions of this source code were derived from Berkeley 4.3 BSD
  33  * under license from the Regents of the University of California.
  34  */
  35 
  36 /*
  37  * svc_cots.c
  38  * Server side for connection-oriented RPC in the kernel.
  39  *
  40  */
  41 
  42 #include <sys/param.h>
  43 #include <sys/types.h>
  44 #include <sys/sysmacros.h>
  45 #include <sys/file.h>


  87 static void             svc_cots_kclone_destroy(SVCXPRT *);
  88 static void             svc_cots_kstart(SVCMASTERXPRT *);
  89 static void             svc_cots_ktattrs(SVCXPRT *, int, void **);
  90 
  91 /*
  92  * Server transport operations vector.
  93  */
  94 struct svc_ops svc_cots_op = {
  95         svc_cots_krecv,         /* Get requests */
  96         svc_cots_kgetargs,      /* Deserialize arguments */
  97         svc_cots_ksend,         /* Send reply */
  98         svc_cots_kfreeargs,     /* Free argument data space */
  99         svc_cots_kdestroy,      /* Destroy transport handle */
 100         svc_cots_kdup,          /* Check entry in dup req cache */
 101         svc_cots_kdupdone,      /* Mark entry in dup req cache as done */
 102         svc_cots_kgetres,       /* Get pointer to response buffer */
 103         svc_cots_kfreeres,      /* Destroy pre-serialized response header */
 104         svc_cots_kclone_destroy, /* Destroy a clone xprt */
 105         svc_cots_kstart,        /* Tell `ready-to-receive' to rpcmod */
 106         NULL,                   /* Transport specific clone xprt */
 107         svc_cots_ktattrs        /* Transport Attributes */


 108 };
 109 
 110 /*
 111  * Master transport private data.
 112  * Kept in xprt->xp_p2.
 113  */
 114 struct cots_master_data {
 115         char    *cmd_src_addr;  /* client's address */
 116         int     cmd_xprt_started; /* flag for clone routine to call */
 117                                 /* rpcmod's start routine. */
 118         struct rpc_cots_server *cmd_stats;      /* stats for zone */
 119 };
 120 
 121 /*
 122  * Transport private data.
 123  * Kept in clone_xprt->xp_p2buf.
 124  */
 125 typedef struct cots_data {
 126         mblk_t  *cd_mp;         /* pre-allocated reply message */
 127         mblk_t  *cd_req_mp;     /* request message */


 710  */
 711 
 712 /*
 713  * MAXDUPREQS is the number of cached items.  It should be adjusted
 714  * to the service load so that there is likely to be a response entry
 715  * when the first retransmission comes in.
 716  */
 717 #define MAXDUPREQS      8192
 718 
 719 /*
 720  * This should be appropriately scaled to MAXDUPREQS.  To produce as less as
 721  * possible collisions it is suggested to set this to a prime.
 722  */
 723 #define DRHASHSZ        2053
 724 
 725 #define XIDHASH(xid)    ((xid) % DRHASHSZ)
 726 #define DRHASH(dr)      XIDHASH((dr)->dr_xid)
 727 #define REQTOXID(req)   ((req)->rq_xprt->xp_xid)
 728 
 729 static int      cotsndupreqs = 0;
 730 int     cotsmaxdupreqs = MAXDUPREQS;
 731 static kmutex_t cotsdupreq_lock;
 732 static struct dupreq *cotsdrhashtbl[DRHASHSZ];
 733 static int      cotsdrhashstat[DRHASHSZ];
 734 
 735 static void unhash(struct dupreq *);
 736 
 737 /*
 738  * cotsdrmru points to the head of a circular linked list in lru order.
 739  * cotsdrmru->dr_next == drlru
 740  */
 741 struct dupreq *cotsdrmru;
 742 
 743 /*
 744  * PSARC 2003/523 Contract Private Interface
 745  * svc_cots_kdup
 746  * Changes must be reviewed by Solaris File Sharing
 747  * Changes must be communicated to contract-2003-523@sun.com
 748  *
 749  * svc_cots_kdup searches the request cache and returns 0 if the
 750  * request is not found in the cache.  If it is found, then it




   6  * You may not use this file except in compliance with the License.
   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 /*
  23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  25  * Copyright (c) 2012 by Delphix. All rights reserved.
  26  * Copyright 2012 Marcel Telka <marcel@telka.sk>
  27  * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  28  */
  29 
  30 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  31 /*      All Rights Reserved     */
  32 
  33 /*
  34  * Portions of this source code were derived from Berkeley 4.3 BSD
  35  * under license from the Regents of the University of California.
  36  */
  37 
  38 /*
  39  * svc_cots.c
  40  * Server side for connection-oriented RPC in the kernel.
  41  *
  42  */
  43 
  44 #include <sys/param.h>
  45 #include <sys/types.h>
  46 #include <sys/sysmacros.h>
  47 #include <sys/file.h>


  89 static void             svc_cots_kclone_destroy(SVCXPRT *);
  90 static void             svc_cots_kstart(SVCMASTERXPRT *);
  91 static void             svc_cots_ktattrs(SVCXPRT *, int, void **);
  92 
  93 /*
  94  * Server transport operations vector.
  95  */
  96 struct svc_ops svc_cots_op = {
  97         svc_cots_krecv,         /* Get requests */
  98         svc_cots_kgetargs,      /* Deserialize arguments */
  99         svc_cots_ksend,         /* Send reply */
 100         svc_cots_kfreeargs,     /* Free argument data space */
 101         svc_cots_kdestroy,      /* Destroy transport handle */
 102         svc_cots_kdup,          /* Check entry in dup req cache */
 103         svc_cots_kdupdone,      /* Mark entry in dup req cache as done */
 104         svc_cots_kgetres,       /* Get pointer to response buffer */
 105         svc_cots_kfreeres,      /* Destroy pre-serialized response header */
 106         svc_cots_kclone_destroy, /* Destroy a clone xprt */
 107         svc_cots_kstart,        /* Tell `ready-to-receive' to rpcmod */
 108         NULL,                   /* Transport specific clone xprt */
 109         svc_cots_ktattrs,       /* Transport Attributes */
 110         mir_svc_hold,           /* Increment transport reference count */
 111         mir_svc_release         /* Decrement transport reference count */
 112 };
 113 
 114 /*
 115  * Master transport private data.
 116  * Kept in xprt->xp_p2.
 117  */
 118 struct cots_master_data {
 119         char    *cmd_src_addr;  /* client's address */
 120         int     cmd_xprt_started; /* flag for clone routine to call */
 121                                 /* rpcmod's start routine. */
 122         struct rpc_cots_server *cmd_stats;      /* stats for zone */
 123 };
 124 
 125 /*
 126  * Transport private data.
 127  * Kept in clone_xprt->xp_p2buf.
 128  */
 129 typedef struct cots_data {
 130         mblk_t  *cd_mp;         /* pre-allocated reply message */
 131         mblk_t  *cd_req_mp;     /* request message */


 714  */
 715 
 716 /*
 717  * MAXDUPREQS is the number of cached items.  It should be adjusted
 718  * to the service load so that there is likely to be a response entry
 719  * when the first retransmission comes in.
 720  */
 721 #define MAXDUPREQS      8192
 722 
 723 /*
 724  * This should be appropriately scaled to MAXDUPREQS.  To produce as less as
 725  * possible collisions it is suggested to set this to a prime.
 726  */
 727 #define DRHASHSZ        2053
 728 
 729 #define XIDHASH(xid)    ((xid) % DRHASHSZ)
 730 #define DRHASH(dr)      XIDHASH((dr)->dr_xid)
 731 #define REQTOXID(req)   ((req)->rq_xprt->xp_xid)
 732 
 733 static int      cotsndupreqs = 0;
 734 volatile int    cotsmaxdupreqs = MAXDUPREQS;
 735 static kmutex_t cotsdupreq_lock;
 736 static struct dupreq *cotsdrhashtbl[DRHASHSZ];
 737 static int      cotsdrhashstat[DRHASHSZ];
 738 
 739 static void unhash(struct dupreq *);
 740 
 741 /*
 742  * cotsdrmru points to the head of a circular linked list in lru order.
 743  * cotsdrmru->dr_next == drlru
 744  */
 745 struct dupreq *cotsdrmru;
 746 
 747 /*
 748  * PSARC 2003/523 Contract Private Interface
 749  * svc_cots_kdup
 750  * Changes must be reviewed by Solaris File Sharing
 751  * Changes must be communicated to contract-2003-523@sun.com
 752  *
 753  * svc_cots_kdup searches the request cache and returns 0 if the
 754  * request is not found in the cache.  If it is found, then it