Print this page
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.


 145         { PR_PAGEDATA,  17 * sizeof (prdirent_t), sizeof (prdirent_t),
 146                 "pagedata" },
 147         { PR_WATCH,     18 * sizeof (prdirent_t), sizeof (prdirent_t),
 148                 "watch" },
 149         { PR_CURDIR,    19 * sizeof (prdirent_t), sizeof (prdirent_t),
 150                 "cwd" },
 151         { PR_ROOTDIR,   20 * sizeof (prdirent_t), sizeof (prdirent_t),
 152                 "root" },
 153         { PR_FDDIR,     21 * sizeof (prdirent_t), sizeof (prdirent_t),
 154                 "fd" },
 155         { PR_OBJECTDIR, 22 * sizeof (prdirent_t), sizeof (prdirent_t),
 156                 "object" },
 157         { PR_LWPDIR,    23 * sizeof (prdirent_t), sizeof (prdirent_t),
 158                 "lwp" },
 159         { PR_PRIV,      24 * sizeof (prdirent_t), sizeof (prdirent_t),
 160                 "priv" },
 161         { PR_PATHDIR,   25 * sizeof (prdirent_t), sizeof (prdirent_t),
 162                 "path" },
 163         { PR_CTDIR,     26 * sizeof (prdirent_t), sizeof (prdirent_t),
 164                 "contracts" },


 165 #if defined(__x86)
 166         { PR_LDT,       27 * sizeof (prdirent_t), sizeof (prdirent_t),
 167                 "ldt" },
 168 #endif
 169 };
 170 
 171 #define NPIDDIRFILES    (sizeof (piddir) / sizeof (piddir[0]) - 2)
 172 
 173 /*
 174  * Contents of a /proc/<pid>/lwp/<lwpid> directory.
 175  */
 176 static prdirent_t lwpiddir[] = {
 177         { PR_LWPIDDIR,   1 * sizeof (prdirent_t), sizeof (prdirent_t),
 178                 "." },
 179         { PR_LWPDIR,     2 * sizeof (prdirent_t), sizeof (prdirent_t),
 180                 ".." },
 181         { PR_LWPCTL,     3 * sizeof (prdirent_t), sizeof (prdirent_t),
 182                 "lwpctl" },
 183         { PR_LWPSTATUS,  4 * sizeof (prdirent_t), sizeof (prdirent_t),
 184                 "lwpstatus" },
 185         { PR_LWPSINFO,   5 * sizeof (prdirent_t), sizeof (prdirent_t),
 186                 "lwpsinfo" },


 568                         allsetrun(p);
 569         }
 570 
 571         prunlock(pnp);
 572         return (0);
 573 }
 574 
 575 /*
 576  * Array of read functions, indexed by /proc file type.
 577  */
 578 static int pr_read_inval(), pr_read_as(), pr_read_status(),
 579         pr_read_lstatus(), pr_read_psinfo(), pr_read_lpsinfo(),
 580         pr_read_map(), pr_read_rmap(), pr_read_xmap(),
 581         pr_read_cred(), pr_read_sigact(), pr_read_auxv(),
 582 #if defined(__x86)
 583         pr_read_ldt(),
 584 #endif
 585         pr_read_usage(), pr_read_lusage(), pr_read_pagedata(),
 586         pr_read_watch(), pr_read_lwpstatus(), pr_read_lwpsinfo(),
 587         pr_read_lwpusage(), pr_read_xregs(), pr_read_priv(),
 588         pr_read_spymaster(),
 589 #if defined(__sparc)
 590         pr_read_gwindows(), pr_read_asrs(),
 591 #endif
 592         pr_read_piddir(), pr_read_pidfile(), pr_read_opagedata();
 593 
 594 static int (*pr_read_function[PR_NFILES])() = {
 595         pr_read_inval,          /* /proc                                */
 596         pr_read_inval,          /* /proc/self                           */
 597         pr_read_piddir,         /* /proc/<pid> (old /proc read()) */
 598         pr_read_as,             /* /proc/<pid>/as                 */
 599         pr_read_inval,          /* /proc/<pid>/ctl                        */
 600         pr_read_status,         /* /proc/<pid>/status                     */
 601         pr_read_lstatus,        /* /proc/<pid>/lstatus                    */
 602         pr_read_psinfo,         /* /proc/<pid>/psinfo                     */
 603         pr_read_lpsinfo,        /* /proc/<pid>/lpsinfo                    */
 604         pr_read_map,            /* /proc/<pid>/map                        */
 605         pr_read_rmap,           /* /proc/<pid>/rmap                       */
 606         pr_read_xmap,           /* /proc/<pid>/xmap                       */
 607         pr_read_cred,           /* /proc/<pid>/cred                       */
 608         pr_read_sigact,         /* /proc/<pid>/sigact                     */


 622         pr_read_inval,          /* /proc/<pid>/object/xxx         */
 623         pr_read_inval,          /* /proc/<pid>/lwp                        */
 624         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>          */
 625         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
 626         pr_read_lwpstatus,      /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
 627         pr_read_lwpsinfo,       /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
 628         pr_read_lwpusage,       /* /proc/<pid>/lwp/<lwpid>/lwpusage */
 629         pr_read_xregs,          /* /proc/<pid>/lwp/<lwpid>/xregs    */
 630         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates        */
 631         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
 632         pr_read_spymaster,      /* /proc/<pid>/lwp/<lwpid>/spymaster        */
 633 #if defined(__sparc)
 634         pr_read_gwindows,       /* /proc/<pid>/lwp/<lwpid>/gwindows */
 635         pr_read_asrs,           /* /proc/<pid>/lwp/<lwpid>/asrs             */
 636 #endif
 637         pr_read_priv,           /* /proc/<pid>/priv                       */
 638         pr_read_inval,          /* /proc/<pid>/path                       */
 639         pr_read_inval,          /* /proc/<pid>/path/xxx                   */
 640         pr_read_inval,          /* /proc/<pid>/contracts          */
 641         pr_read_inval,          /* /proc/<pid>/contracts/<ctid>             */

 642         pr_read_pidfile,        /* old process file                     */
 643         pr_read_pidfile,        /* old lwp file                         */
 644         pr_read_opagedata,      /* old pagedata file                    */
 645 };
 646 
 647 /* ARGSUSED */
 648 static int
 649 pr_read_inval(prnode_t *pnp, uio_t *uiop)
 650 {
 651         /*
 652          * No read() on any /proc directory, use getdents(2) instead.
 653          * Cannot read a control file either.
 654          * An underlying mapped object file cannot get here.
 655          */
 656         return (EINVAL);
 657 }
 658 
 659 static int
 660 pr_uioread(void *base, long count, uio_t *uiop)
 661 {


1584         klwp_t *lwp;
1585 
1586         ASSERT(pnp->pr_type == PR_SPYMASTER);
1587 
1588         if ((error = prlock(pnp, ZNO)) != 0)
1589                 return (error);
1590 
1591         lwp = pnp->pr_common->prc_thread->t_lwp;
1592 
1593         if (lwp->lwp_spymaster == NULL) {
1594                 prunlock(pnp);
1595                 return (0);
1596         }
1597 
1598         bcopy(lwp->lwp_spymaster, &psinfo, sizeof (psinfo_t));
1599         prunlock(pnp);
1600 
1601         return (pr_uioread(&psinfo, sizeof (psinfo), uiop));
1602 }
1603 



















1604 #if defined(__sparc)
1605 
1606 static int
1607 pr_read_gwindows(prnode_t *pnp, uio_t *uiop)
1608 {
1609         proc_t *p;
1610         kthread_t *t;
1611         gwindows_t *gwp;
1612         int error;
1613         size_t size;
1614 
1615         ASSERT(pnp->pr_type == PR_GWINDOWS);
1616 
1617         gwp = kmem_zalloc(sizeof (gwindows_t), KM_SLEEP);
1618 
1619         if ((error = prlock(pnp, ZNO)) != 0)
1620                 goto out;
1621 
1622         p = pnp->pr_common->prc_proc;
1623         t = pnp->pr_common->prc_thread;


1779         pr_read_inval,          /* /proc/<pid>/object/xxx         */
1780         pr_read_inval,          /* /proc/<pid>/lwp                        */
1781         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>          */
1782         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
1783         pr_read_lwpstatus_32,   /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
1784         pr_read_lwpsinfo_32,    /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
1785         pr_read_lwpusage_32,    /* /proc/<pid>/lwp/<lwpid>/lwpusage */
1786         pr_read_xregs,          /* /proc/<pid>/lwp/<lwpid>/xregs    */
1787         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates        */
1788         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
1789         pr_read_spymaster_32,   /* /proc/<pid>/lwp/<lwpid>/spymaster        */
1790 #if defined(__sparc)
1791         pr_read_gwindows_32,    /* /proc/<pid>/lwp/<lwpid>/gwindows */
1792         pr_read_asrs,           /* /proc/<pid>/lwp/<lwpid>/asrs             */
1793 #endif
1794         pr_read_priv,           /* /proc/<pid>/priv                       */
1795         pr_read_inval,          /* /proc/<pid>/path                       */
1796         pr_read_inval,          /* /proc/<pid>/path/xxx                   */
1797         pr_read_inval,          /* /proc/<pid>/contracts          */
1798         pr_read_inval,          /* /proc/<pid>/contracts/<ctid>             */

1799         pr_read_pidfile,        /* old process file                     */
1800         pr_read_pidfile,        /* old lwp file                         */
1801         pr_read_opagedata_32,   /* old pagedata file                    */
1802 };
1803 
1804 static int
1805 pr_read_status_32(prnode_t *pnp, uio_t *uiop)
1806 {
1807         pstatus32_t *sp;
1808         proc_t *p;
1809         int error;
1810 
1811         ASSERT(pnp->pr_type == PR_STATUS);
1812 
1813         /*
1814          * We kmem_alloc() the pstatus structure because
1815          * it is so big it might blow the kernel stack.
1816          */
1817         sp = kmem_alloc(sizeof (*sp), KM_SLEEP);
1818         if ((error = prlock(pnp, ZNO)) == 0) {


3022                                 vap->va_size = prnsegs(as, 0) *
3023                                     PR_OBJSIZE(prxmap32_t, prxmap_t);
3024                         else
3025                                 vap->va_size = prnsegs(as, type == PR_RMAP) *
3026                                     PR_OBJSIZE(prmap32_t, prmap_t);
3027                         AS_LOCK_EXIT(as);
3028                         mutex_enter(&p->p_lock);
3029                 }
3030                 break;
3031         case PR_CRED:
3032                 mutex_enter(&p->p_crlock);
3033                 vap->va_size = sizeof (prcred_t);
3034                 ngroups = crgetngroups(p->p_cred);
3035                 if (ngroups > 1)
3036                         vap->va_size += (ngroups - 1) * sizeof (gid_t);
3037                 mutex_exit(&p->p_crlock);
3038                 break;
3039         case PR_PRIV:
3040                 vap->va_size = prgetprivsize();
3041                 break;



3042         case PR_SIGACT:
3043                 nsig = PROC_IS_BRANDED(curproc)? BROP(curproc)->b_nsig : NSIG;
3044                 vap->va_size = (nsig-1) *
3045                     PR_OBJSIZE(struct sigaction32, struct sigaction);
3046                 break;
3047         case PR_AUXV:
3048                 vap->va_size = __KERN_NAUXV_IMPL * PR_OBJSIZE(auxv32_t, auxv_t);
3049                 break;
3050 #if defined(__x86)
3051         case PR_LDT:
3052                 mutex_exit(&p->p_lock);
3053                 mutex_enter(&p->p_ldtlock);
3054                 vap->va_size = prnldt(p) * sizeof (struct ssd);
3055                 mutex_exit(&p->p_ldtlock);
3056                 mutex_enter(&p->p_lock);
3057                 break;
3058 #endif
3059         case PR_USAGE:
3060                 vap->va_size = PR_OBJSIZE(prusage32_t, prusage_t);
3061                 break;


3319         pr_lookup_notdir,       /* /proc/<pid>/object/xxx         */
3320         pr_lookup_lwpdir,       /* /proc/<pid>/lwp                        */
3321         pr_lookup_lwpiddir,     /* /proc/<pid>/lwp/<lwpid>          */
3322         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
3323         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
3324         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
3325         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpusage */
3326         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/xregs    */
3327         pr_lookup_tmpldir,      /* /proc/<pid>/lwp/<lwpid>/templates        */
3328         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
3329         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/spymaster        */
3330 #if defined(__sparc)
3331         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/gwindows */
3332         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/asrs             */
3333 #endif
3334         pr_lookup_notdir,       /* /proc/<pid>/priv                       */
3335         pr_lookup_pathdir,      /* /proc/<pid>/path                       */
3336         pr_lookup_notdir,       /* /proc/<pid>/path/xxx                   */
3337         pr_lookup_ctdir,        /* /proc/<pid>/contracts          */
3338         pr_lookup_notdir,       /* /proc/<pid>/contracts/<ctid>             */

3339         pr_lookup_notdir,       /* old process file                     */
3340         pr_lookup_notdir,       /* old lwp file                         */
3341         pr_lookup_notdir,       /* old pagedata file                    */
3342 };
3343 
3344 static int
3345 prlookup(vnode_t *dp, char *comp, vnode_t **vpp, pathname_t *pathp,
3346         int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
3347         int *direntflags, pathname_t *realpnp)
3348 {
3349         prnode_t *pnp = VTOP(dp);
3350         prnodetype_t type = pnp->pr_type;
3351         int error;
3352 
3353         ASSERT(dp->v_type == VDIR);
3354         ASSERT(type < PR_NFILES);
3355 
3356         if (type != PR_PROCDIR && strcmp(comp, "..") == 0) {
3357                 VN_HOLD(pnp->pr_parent);
3358                 *vpp = pnp->pr_parent;


4668         pr_readdir_notdir,      /* /proc/<pid>/object/xxx         */
4669         pr_readdir_lwpdir,      /* /proc/<pid>/lwp                        */
4670         pr_readdir_lwpiddir,    /* /proc/<pid>/lwp/<lwpid>          */
4671         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
4672         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
4673         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
4674         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpusage */
4675         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/xregs    */
4676         pr_readdir_tmpldir,     /* /proc/<pid>/lwp/<lwpid>/templates        */
4677         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
4678         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/spymaster        */
4679 #if defined(__sparc)
4680         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/gwindows */
4681         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/asrs             */
4682 #endif
4683         pr_readdir_notdir,      /* /proc/<pid>/priv                       */
4684         pr_readdir_pathdir,     /* /proc/<pid>/path                       */
4685         pr_readdir_notdir,      /* /proc/<pid>/path/xxx                   */
4686         pr_readdir_ctdir,       /* /proc/<pid>/contracts          */
4687         pr_readdir_notdir,      /* /proc/<pid>/contracts/<ctid>             */

4688         pr_readdir_notdir,      /* old process file                     */
4689         pr_readdir_notdir,      /* old lwp file                         */
4690         pr_readdir_notdir,      /* old pagedata file                    */
4691 };
4692 
4693 /* ARGSUSED */
4694 static int
4695 prreaddir(vnode_t *vp, uio_t *uiop, cred_t *cr, int *eofp,
4696         caller_context_t *ct, int flags)
4697 {
4698         prnode_t *pnp = VTOP(vp);
4699 
4700         ASSERT(pnp->pr_type < PR_NFILES);
4701 
4702         /* XXX - Do we need to pass ct and flags? */
4703         return (pr_readdir_function[pnp->pr_type](pnp, uiop, eofp));
4704 }
4705 
4706 /* ARGSUSED */
4707 static int




 145         { PR_PAGEDATA,  17 * sizeof (prdirent_t), sizeof (prdirent_t),
 146                 "pagedata" },
 147         { PR_WATCH,     18 * sizeof (prdirent_t), sizeof (prdirent_t),
 148                 "watch" },
 149         { PR_CURDIR,    19 * sizeof (prdirent_t), sizeof (prdirent_t),
 150                 "cwd" },
 151         { PR_ROOTDIR,   20 * sizeof (prdirent_t), sizeof (prdirent_t),
 152                 "root" },
 153         { PR_FDDIR,     21 * sizeof (prdirent_t), sizeof (prdirent_t),
 154                 "fd" },
 155         { PR_OBJECTDIR, 22 * sizeof (prdirent_t), sizeof (prdirent_t),
 156                 "object" },
 157         { PR_LWPDIR,    23 * sizeof (prdirent_t), sizeof (prdirent_t),
 158                 "lwp" },
 159         { PR_PRIV,      24 * sizeof (prdirent_t), sizeof (prdirent_t),
 160                 "priv" },
 161         { PR_PATHDIR,   25 * sizeof (prdirent_t), sizeof (prdirent_t),
 162                 "path" },
 163         { PR_CTDIR,     26 * sizeof (prdirent_t), sizeof (prdirent_t),
 164                 "contracts" },
 165         { PR_SECFLAGS,  27 * sizeof (prdirent_t), sizeof (prdirent_t),
 166                 "secflags" },
 167 #if defined(__x86)
 168         { PR_LDT,       28 * sizeof (prdirent_t), sizeof (prdirent_t),
 169                 "ldt" },
 170 #endif
 171 };
 172 
 173 #define NPIDDIRFILES    (sizeof (piddir) / sizeof (piddir[0]) - 2)
 174 
 175 /*
 176  * Contents of a /proc/<pid>/lwp/<lwpid> directory.
 177  */
 178 static prdirent_t lwpiddir[] = {
 179         { PR_LWPIDDIR,   1 * sizeof (prdirent_t), sizeof (prdirent_t),
 180                 "." },
 181         { PR_LWPDIR,     2 * sizeof (prdirent_t), sizeof (prdirent_t),
 182                 ".." },
 183         { PR_LWPCTL,     3 * sizeof (prdirent_t), sizeof (prdirent_t),
 184                 "lwpctl" },
 185         { PR_LWPSTATUS,  4 * sizeof (prdirent_t), sizeof (prdirent_t),
 186                 "lwpstatus" },
 187         { PR_LWPSINFO,   5 * sizeof (prdirent_t), sizeof (prdirent_t),
 188                 "lwpsinfo" },


 570                         allsetrun(p);
 571         }
 572 
 573         prunlock(pnp);
 574         return (0);
 575 }
 576 
 577 /*
 578  * Array of read functions, indexed by /proc file type.
 579  */
 580 static int pr_read_inval(), pr_read_as(), pr_read_status(),
 581         pr_read_lstatus(), pr_read_psinfo(), pr_read_lpsinfo(),
 582         pr_read_map(), pr_read_rmap(), pr_read_xmap(),
 583         pr_read_cred(), pr_read_sigact(), pr_read_auxv(),
 584 #if defined(__x86)
 585         pr_read_ldt(),
 586 #endif
 587         pr_read_usage(), pr_read_lusage(), pr_read_pagedata(),
 588         pr_read_watch(), pr_read_lwpstatus(), pr_read_lwpsinfo(),
 589         pr_read_lwpusage(), pr_read_xregs(), pr_read_priv(),
 590         pr_read_spymaster(), pr_read_secflags(),
 591 #if defined(__sparc)
 592         pr_read_gwindows(), pr_read_asrs(),
 593 #endif
 594         pr_read_piddir(), pr_read_pidfile(), pr_read_opagedata();
 595 
 596 static int (*pr_read_function[PR_NFILES])() = {
 597         pr_read_inval,          /* /proc                                */
 598         pr_read_inval,          /* /proc/self                           */
 599         pr_read_piddir,         /* /proc/<pid> (old /proc read()) */
 600         pr_read_as,             /* /proc/<pid>/as                 */
 601         pr_read_inval,          /* /proc/<pid>/ctl                        */
 602         pr_read_status,         /* /proc/<pid>/status                     */
 603         pr_read_lstatus,        /* /proc/<pid>/lstatus                    */
 604         pr_read_psinfo,         /* /proc/<pid>/psinfo                     */
 605         pr_read_lpsinfo,        /* /proc/<pid>/lpsinfo                    */
 606         pr_read_map,            /* /proc/<pid>/map                        */
 607         pr_read_rmap,           /* /proc/<pid>/rmap                       */
 608         pr_read_xmap,           /* /proc/<pid>/xmap                       */
 609         pr_read_cred,           /* /proc/<pid>/cred                       */
 610         pr_read_sigact,         /* /proc/<pid>/sigact                     */


 624         pr_read_inval,          /* /proc/<pid>/object/xxx         */
 625         pr_read_inval,          /* /proc/<pid>/lwp                        */
 626         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>          */
 627         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
 628         pr_read_lwpstatus,      /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
 629         pr_read_lwpsinfo,       /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
 630         pr_read_lwpusage,       /* /proc/<pid>/lwp/<lwpid>/lwpusage */
 631         pr_read_xregs,          /* /proc/<pid>/lwp/<lwpid>/xregs    */
 632         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates        */
 633         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
 634         pr_read_spymaster,      /* /proc/<pid>/lwp/<lwpid>/spymaster        */
 635 #if defined(__sparc)
 636         pr_read_gwindows,       /* /proc/<pid>/lwp/<lwpid>/gwindows */
 637         pr_read_asrs,           /* /proc/<pid>/lwp/<lwpid>/asrs             */
 638 #endif
 639         pr_read_priv,           /* /proc/<pid>/priv                       */
 640         pr_read_inval,          /* /proc/<pid>/path                       */
 641         pr_read_inval,          /* /proc/<pid>/path/xxx                   */
 642         pr_read_inval,          /* /proc/<pid>/contracts          */
 643         pr_read_inval,          /* /proc/<pid>/contracts/<ctid>             */
 644         pr_read_secflags,       /* /proc/<pid>/secflags                   */
 645         pr_read_pidfile,        /* old process file                     */
 646         pr_read_pidfile,        /* old lwp file                         */
 647         pr_read_opagedata,      /* old pagedata file                    */
 648 };
 649 
 650 /* ARGSUSED */
 651 static int
 652 pr_read_inval(prnode_t *pnp, uio_t *uiop)
 653 {
 654         /*
 655          * No read() on any /proc directory, use getdents(2) instead.
 656          * Cannot read a control file either.
 657          * An underlying mapped object file cannot get here.
 658          */
 659         return (EINVAL);
 660 }
 661 
 662 static int
 663 pr_uioread(void *base, long count, uio_t *uiop)
 664 {


1587         klwp_t *lwp;
1588 
1589         ASSERT(pnp->pr_type == PR_SPYMASTER);
1590 
1591         if ((error = prlock(pnp, ZNO)) != 0)
1592                 return (error);
1593 
1594         lwp = pnp->pr_common->prc_thread->t_lwp;
1595 
1596         if (lwp->lwp_spymaster == NULL) {
1597                 prunlock(pnp);
1598                 return (0);
1599         }
1600 
1601         bcopy(lwp->lwp_spymaster, &psinfo, sizeof (psinfo_t));
1602         prunlock(pnp);
1603 
1604         return (pr_uioread(&psinfo, sizeof (psinfo), uiop));
1605 }
1606 
1607 static int
1608 pr_read_secflags(prnode_t *pnp, uio_t *uiop)
1609 {
1610         prsecflags_t ret;
1611         int error;
1612         proc_t *p;
1613 
1614         ASSERT(pnp->pr_type == PR_SECFLAGS);
1615 
1616         if ((error = prlock(pnp, ZNO)) != 0)
1617                 return (error);
1618 
1619         p = pnp->pr_common->prc_proc;
1620         prgetsecflags(p, &ret);
1621         prunlock(pnp);
1622 
1623         return (pr_uioread(&ret, sizeof (ret), uiop));
1624 }
1625 
1626 #if defined(__sparc)
1627 
1628 static int
1629 pr_read_gwindows(prnode_t *pnp, uio_t *uiop)
1630 {
1631         proc_t *p;
1632         kthread_t *t;
1633         gwindows_t *gwp;
1634         int error;
1635         size_t size;
1636 
1637         ASSERT(pnp->pr_type == PR_GWINDOWS);
1638 
1639         gwp = kmem_zalloc(sizeof (gwindows_t), KM_SLEEP);
1640 
1641         if ((error = prlock(pnp, ZNO)) != 0)
1642                 goto out;
1643 
1644         p = pnp->pr_common->prc_proc;
1645         t = pnp->pr_common->prc_thread;


1801         pr_read_inval,          /* /proc/<pid>/object/xxx         */
1802         pr_read_inval,          /* /proc/<pid>/lwp                        */
1803         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>          */
1804         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
1805         pr_read_lwpstatus_32,   /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
1806         pr_read_lwpsinfo_32,    /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
1807         pr_read_lwpusage_32,    /* /proc/<pid>/lwp/<lwpid>/lwpusage */
1808         pr_read_xregs,          /* /proc/<pid>/lwp/<lwpid>/xregs    */
1809         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates        */
1810         pr_read_inval,          /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
1811         pr_read_spymaster_32,   /* /proc/<pid>/lwp/<lwpid>/spymaster        */
1812 #if defined(__sparc)
1813         pr_read_gwindows_32,    /* /proc/<pid>/lwp/<lwpid>/gwindows */
1814         pr_read_asrs,           /* /proc/<pid>/lwp/<lwpid>/asrs             */
1815 #endif
1816         pr_read_priv,           /* /proc/<pid>/priv                       */
1817         pr_read_inval,          /* /proc/<pid>/path                       */
1818         pr_read_inval,          /* /proc/<pid>/path/xxx                   */
1819         pr_read_inval,          /* /proc/<pid>/contracts          */
1820         pr_read_inval,          /* /proc/<pid>/contracts/<ctid>             */
1821         pr_read_secflags,       /* /proc/<pid>/secflags                   */
1822         pr_read_pidfile,        /* old process file                     */
1823         pr_read_pidfile,        /* old lwp file                         */
1824         pr_read_opagedata_32,   /* old pagedata file                    */
1825 };
1826 
1827 static int
1828 pr_read_status_32(prnode_t *pnp, uio_t *uiop)
1829 {
1830         pstatus32_t *sp;
1831         proc_t *p;
1832         int error;
1833 
1834         ASSERT(pnp->pr_type == PR_STATUS);
1835 
1836         /*
1837          * We kmem_alloc() the pstatus structure because
1838          * it is so big it might blow the kernel stack.
1839          */
1840         sp = kmem_alloc(sizeof (*sp), KM_SLEEP);
1841         if ((error = prlock(pnp, ZNO)) == 0) {


3045                                 vap->va_size = prnsegs(as, 0) *
3046                                     PR_OBJSIZE(prxmap32_t, prxmap_t);
3047                         else
3048                                 vap->va_size = prnsegs(as, type == PR_RMAP) *
3049                                     PR_OBJSIZE(prmap32_t, prmap_t);
3050                         AS_LOCK_EXIT(as);
3051                         mutex_enter(&p->p_lock);
3052                 }
3053                 break;
3054         case PR_CRED:
3055                 mutex_enter(&p->p_crlock);
3056                 vap->va_size = sizeof (prcred_t);
3057                 ngroups = crgetngroups(p->p_cred);
3058                 if (ngroups > 1)
3059                         vap->va_size += (ngroups - 1) * sizeof (gid_t);
3060                 mutex_exit(&p->p_crlock);
3061                 break;
3062         case PR_PRIV:
3063                 vap->va_size = prgetprivsize();
3064                 break;
3065         case PR_SECFLAGS:
3066                 vap->va_size = sizeof (prsecflags_t);
3067                 break;
3068         case PR_SIGACT:
3069                 nsig = PROC_IS_BRANDED(curproc)? BROP(curproc)->b_nsig : NSIG;
3070                 vap->va_size = (nsig-1) *
3071                     PR_OBJSIZE(struct sigaction32, struct sigaction);
3072                 break;
3073         case PR_AUXV:
3074                 vap->va_size = __KERN_NAUXV_IMPL * PR_OBJSIZE(auxv32_t, auxv_t);
3075                 break;
3076 #if defined(__x86)
3077         case PR_LDT:
3078                 mutex_exit(&p->p_lock);
3079                 mutex_enter(&p->p_ldtlock);
3080                 vap->va_size = prnldt(p) * sizeof (struct ssd);
3081                 mutex_exit(&p->p_ldtlock);
3082                 mutex_enter(&p->p_lock);
3083                 break;
3084 #endif
3085         case PR_USAGE:
3086                 vap->va_size = PR_OBJSIZE(prusage32_t, prusage_t);
3087                 break;


3345         pr_lookup_notdir,       /* /proc/<pid>/object/xxx         */
3346         pr_lookup_lwpdir,       /* /proc/<pid>/lwp                        */
3347         pr_lookup_lwpiddir,     /* /proc/<pid>/lwp/<lwpid>          */
3348         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
3349         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
3350         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
3351         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/lwpusage */
3352         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/xregs    */
3353         pr_lookup_tmpldir,      /* /proc/<pid>/lwp/<lwpid>/templates        */
3354         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
3355         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/spymaster        */
3356 #if defined(__sparc)
3357         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/gwindows */
3358         pr_lookup_notdir,       /* /proc/<pid>/lwp/<lwpid>/asrs             */
3359 #endif
3360         pr_lookup_notdir,       /* /proc/<pid>/priv                       */
3361         pr_lookup_pathdir,      /* /proc/<pid>/path                       */
3362         pr_lookup_notdir,       /* /proc/<pid>/path/xxx                   */
3363         pr_lookup_ctdir,        /* /proc/<pid>/contracts          */
3364         pr_lookup_notdir,       /* /proc/<pid>/contracts/<ctid>             */
3365         pr_lookup_notdir,       /* /proc/<pid>/secflags                   */
3366         pr_lookup_notdir,       /* old process file                     */
3367         pr_lookup_notdir,       /* old lwp file                         */
3368         pr_lookup_notdir,       /* old pagedata file                    */
3369 };
3370 
3371 static int
3372 prlookup(vnode_t *dp, char *comp, vnode_t **vpp, pathname_t *pathp,
3373     int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
3374     int *direntflags, pathname_t *realpnp)
3375 {
3376         prnode_t *pnp = VTOP(dp);
3377         prnodetype_t type = pnp->pr_type;
3378         int error;
3379 
3380         ASSERT(dp->v_type == VDIR);
3381         ASSERT(type < PR_NFILES);
3382 
3383         if (type != PR_PROCDIR && strcmp(comp, "..") == 0) {
3384                 VN_HOLD(pnp->pr_parent);
3385                 *vpp = pnp->pr_parent;


4695         pr_readdir_notdir,      /* /proc/<pid>/object/xxx         */
4696         pr_readdir_lwpdir,      /* /proc/<pid>/lwp                        */
4697         pr_readdir_lwpiddir,    /* /proc/<pid>/lwp/<lwpid>          */
4698         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
4699         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
4700         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
4701         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/lwpusage */
4702         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/xregs    */
4703         pr_readdir_tmpldir,     /* /proc/<pid>/lwp/<lwpid>/templates        */
4704         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
4705         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/spymaster        */
4706 #if defined(__sparc)
4707         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/gwindows */
4708         pr_readdir_notdir,      /* /proc/<pid>/lwp/<lwpid>/asrs             */
4709 #endif
4710         pr_readdir_notdir,      /* /proc/<pid>/priv                       */
4711         pr_readdir_pathdir,     /* /proc/<pid>/path                       */
4712         pr_readdir_notdir,      /* /proc/<pid>/path/xxx                   */
4713         pr_readdir_ctdir,       /* /proc/<pid>/contracts          */
4714         pr_readdir_notdir,      /* /proc/<pid>/contracts/<ctid>             */
4715         pr_readdir_notdir,      /* /proc/<pid>/secflags                   */
4716         pr_readdir_notdir,      /* old process file                     */
4717         pr_readdir_notdir,      /* old lwp file                         */
4718         pr_readdir_notdir,      /* old pagedata file                    */
4719 };
4720 
4721 /* ARGSUSED */
4722 static int
4723 prreaddir(vnode_t *vp, uio_t *uiop, cred_t *cr, int *eofp,
4724     caller_context_t *ct, int flags)
4725 {
4726         prnode_t *pnp = VTOP(vp);
4727 
4728         ASSERT(pnp->pr_type < PR_NFILES);
4729 
4730         /* XXX - Do we need to pass ct and flags? */
4731         return (pr_readdir_function[pnp->pr_type](pnp, uiop, eofp));
4732 }
4733 
4734 /* ARGSUSED */
4735 static int