17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
2734bdffbfSGarrett D'Amore /*
2834bdffbfSGarrett D'Amore * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
29ab618543SJohn Levon * Copyright 2018 Joyent, Inc.
30a02120c4SAndy Fiddaman * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
31ed093b41SRobert Mustacchi * Copyright 2023 Oxide Computer Company
3234bdffbfSGarrett D'Amore */
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate #include <sys/param.h>
367c478bd9Sstevel@tonic-gate #include <sys/thread.h>
377c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
387c478bd9Sstevel@tonic-gate #include <sys/signal.h>
397c478bd9Sstevel@tonic-gate #include <sys/cred.h>
407c478bd9Sstevel@tonic-gate #include <sys/priv.h>
417c478bd9Sstevel@tonic-gate #include <sys/user.h>
4234bdffbfSGarrett D'Amore #include <sys/file.h>
437c478bd9Sstevel@tonic-gate #include <sys/errno.h>
447c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
4534bdffbfSGarrett D'Amore #include <sys/mode.h>
4634bdffbfSGarrett D'Amore #include <sys/vfs.h>
477c478bd9Sstevel@tonic-gate #include <sys/mman.h>
487c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
497c478bd9Sstevel@tonic-gate #include <sys/proc.h>
507c478bd9Sstevel@tonic-gate #include <sys/pathname.h>
517c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
527c478bd9Sstevel@tonic-gate #include <sys/systm.h>
537c478bd9Sstevel@tonic-gate #include <sys/elf.h>
547c478bd9Sstevel@tonic-gate #include <sys/vmsystm.h>
557c478bd9Sstevel@tonic-gate #include <sys/debug.h>
567c478bd9Sstevel@tonic-gate #include <sys/procfs.h>
577c478bd9Sstevel@tonic-gate #include <sys/regset.h>
587c478bd9Sstevel@tonic-gate #include <sys/auxv.h>
597c478bd9Sstevel@tonic-gate #include <sys/exec.h>
607c478bd9Sstevel@tonic-gate #include <sys/prsystm.h>
617c478bd9Sstevel@tonic-gate #include <sys/utsname.h>
627c478bd9Sstevel@tonic-gate #include <sys/zone.h>
637c478bd9Sstevel@tonic-gate #include <vm/as.h>
647c478bd9Sstevel@tonic-gate #include <vm/rm.h>
657c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
667c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h>
677c478bd9Sstevel@tonic-gate #include <sys/machelf.h>
6834bdffbfSGarrett D'Amore #include <sys/sunddi.h>
697c478bd9Sstevel@tonic-gate #include "elf_impl.h"
7086ef0a63SRichard Lowe #if defined(__i386_COMPAT)
717c478bd9Sstevel@tonic-gate #include <sys/sysi86.h>
727c478bd9Sstevel@tonic-gate #endif
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate void
setup_note_header(Phdr * v,proc_t * p)757c478bd9Sstevel@tonic-gate setup_note_header(Phdr *v, proc_t *p)
767c478bd9Sstevel@tonic-gate {
777c478bd9Sstevel@tonic-gate int nlwp = p->p_lwpcnt;
787c478bd9Sstevel@tonic-gate int nzomb = p->p_zombcnt;
7934bdffbfSGarrett D'Amore int nfd;
807c478bd9Sstevel@tonic-gate size_t size;
817c478bd9Sstevel@tonic-gate prcred_t *pcrp;
8234bdffbfSGarrett D'Amore uf_info_t *fip;
8334bdffbfSGarrett D'Amore uf_entry_t *ufp;
8434bdffbfSGarrett D'Amore int fd;
8534bdffbfSGarrett D'Amore
8634bdffbfSGarrett D'Amore fip = P_FINFO(p);
8734bdffbfSGarrett D'Amore nfd = 0;
8834bdffbfSGarrett D'Amore mutex_enter(&fip->fi_lock);
8934bdffbfSGarrett D'Amore for (fd = 0; fd < fip->fi_nfiles; fd++) {
9034bdffbfSGarrett D'Amore UF_ENTER(ufp, fip, fd);
9134bdffbfSGarrett D'Amore if ((ufp->uf_file != NULL) && (ufp->uf_file->f_count > 0))
9234bdffbfSGarrett D'Amore nfd++;
9334bdffbfSGarrett D'Amore UF_EXIT(ufp);
9434bdffbfSGarrett D'Amore }
9534bdffbfSGarrett D'Amore mutex_exit(&fip->fi_lock);
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate v[0].p_type = PT_NOTE;
987c478bd9Sstevel@tonic-gate v[0].p_flags = PF_R;
99ab618543SJohn Levon v[0].p_filesz = (sizeof (Note) * (10 + 3 * nlwp + nzomb + nfd))
1007c478bd9Sstevel@tonic-gate + roundup(sizeof (psinfo_t), sizeof (Word))
1017c478bd9Sstevel@tonic-gate + roundup(sizeof (pstatus_t), sizeof (Word))
1027c478bd9Sstevel@tonic-gate + roundup(prgetprivsize(), sizeof (Word))
1037c478bd9Sstevel@tonic-gate + roundup(priv_get_implinfo_size(), sizeof (Word))
1047c478bd9Sstevel@tonic-gate + roundup(strlen(platform) + 1, sizeof (Word))
1057c478bd9Sstevel@tonic-gate + roundup(strlen(p->p_zone->zone_name) + 1, sizeof (Word))
1067c478bd9Sstevel@tonic-gate + roundup(__KERN_NAUXV_IMPL * sizeof (aux_entry_t), sizeof (Word))
1077c478bd9Sstevel@tonic-gate + roundup(sizeof (utsname), sizeof (Word))
1087c478bd9Sstevel@tonic-gate + roundup(sizeof (core_content_t), sizeof (Word))
109d2a70789SRichard Lowe + roundup(sizeof (prsecflags_t), sizeof (Word))
1107c478bd9Sstevel@tonic-gate + (nlwp + nzomb) * roundup(sizeof (lwpsinfo_t), sizeof (Word))
11134bdffbfSGarrett D'Amore + nlwp * roundup(sizeof (lwpstatus_t), sizeof (Word))
112ab618543SJohn Levon + nlwp * roundup(sizeof (prlwpname_t), sizeof (Word))
113a02120c4SAndy Fiddaman + nfd * roundup(sizeof (prfdinfo_core_t), sizeof (Word));
1147c478bd9Sstevel@tonic-gate
115f971a346SBryan Cantrill if (curproc->p_agenttp != NULL) {
116f971a346SBryan Cantrill v[0].p_filesz += sizeof (Note) +
117f971a346SBryan Cantrill roundup(sizeof (psinfo_t), sizeof (Word));
118f971a346SBryan Cantrill }
119f971a346SBryan Cantrill
1207c478bd9Sstevel@tonic-gate size = sizeof (prcred_t) + sizeof (gid_t) * (ngroups_max - 1);
121*552c19f2SRobert Mustacchi pcrp = kmem_zalloc(size, KM_SLEEP);
1227c478bd9Sstevel@tonic-gate prgetcred(p, pcrp);
1237c478bd9Sstevel@tonic-gate if (pcrp->pr_ngroups != 0) {
1247c478bd9Sstevel@tonic-gate v[0].p_filesz += sizeof (Note) + roundup(sizeof (prcred_t) +
1257c478bd9Sstevel@tonic-gate sizeof (gid_t) * (pcrp->pr_ngroups - 1), sizeof (Word));
1267c478bd9Sstevel@tonic-gate } else {
1277c478bd9Sstevel@tonic-gate v[0].p_filesz += sizeof (Note) +
1287c478bd9Sstevel@tonic-gate roundup(sizeof (prcred_t), sizeof (Word));
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate kmem_free(pcrp, size);
1317c478bd9Sstevel@tonic-gate
13234bdffbfSGarrett D'Amore
13386ef0a63SRichard Lowe #if defined(__i386_COMPAT)
1347c478bd9Sstevel@tonic-gate mutex_enter(&p->p_ldtlock);
1357c478bd9Sstevel@tonic-gate size = prnldt(p) * sizeof (struct ssd);
1367c478bd9Sstevel@tonic-gate mutex_exit(&p->p_ldtlock);
1377c478bd9Sstevel@tonic-gate if (size != 0)
1387c478bd9Sstevel@tonic-gate v[0].p_filesz += sizeof (Note) + roundup(size, sizeof (Word));
13986ef0a63SRichard Lowe #endif /* __i386_COMPAT */
1407c478bd9Sstevel@tonic-gate
141ed093b41SRobert Mustacchi if ((size = prhasx(p) ? prgetprxregsize(p) : 0) != 0)
1427c478bd9Sstevel@tonic-gate v[0].p_filesz += nlwp * sizeof (Note)
1437c478bd9Sstevel@tonic-gate + nlwp * roundup(size, sizeof (Word));
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gate #if defined(__sparc)
1467c478bd9Sstevel@tonic-gate /*
1477c478bd9Sstevel@tonic-gate * Figure out the number and sizes of register windows.
1487c478bd9Sstevel@tonic-gate */
1497c478bd9Sstevel@tonic-gate {
1507c478bd9Sstevel@tonic-gate kthread_t *t = p->p_tlist;
1517c478bd9Sstevel@tonic-gate do {
1527c478bd9Sstevel@tonic-gate if ((size = prnwindows(ttolwp(t))) != 0) {
1537c478bd9Sstevel@tonic-gate size = sizeof (gwindows_t) -
1547c478bd9Sstevel@tonic-gate (SPARC_MAXREGWINDOW - size) *
1557c478bd9Sstevel@tonic-gate sizeof (struct rwindow);
1567c478bd9Sstevel@tonic-gate v[0].p_filesz += sizeof (Note) +
1577c478bd9Sstevel@tonic-gate roundup(size, sizeof (Word));
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate } while ((t = t->t_forw) != p->p_tlist);
1607c478bd9Sstevel@tonic-gate }
1617c478bd9Sstevel@tonic-gate /*
1627c478bd9Sstevel@tonic-gate * Space for the Ancillary State Registers.
1637c478bd9Sstevel@tonic-gate */
1647c478bd9Sstevel@tonic-gate if (p->p_model == DATAMODEL_LP64)
1657c478bd9Sstevel@tonic-gate v[0].p_filesz += nlwp * sizeof (Note)
1667c478bd9Sstevel@tonic-gate + nlwp * roundup(sizeof (asrset_t), sizeof (Word));
1677c478bd9Sstevel@tonic-gate #endif /* __sparc */
168350ffdd5SRobert Mustacchi
169350ffdd5SRobert Mustacchi mutex_enter(&p->p_lock);
170350ffdd5SRobert Mustacchi if ((p->p_upanicflag & P_UPF_PANICKED) != 0) {
171350ffdd5SRobert Mustacchi v[0].p_filesz += sizeof (Note) +
172350ffdd5SRobert Mustacchi roundup(sizeof (prupanic_t), sizeof (Word));
173350ffdd5SRobert Mustacchi }
174350ffdd5SRobert Mustacchi mutex_exit(&p->p_lock);
1757c478bd9Sstevel@tonic-gate }
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate int
write_elfnotes(proc_t * p,int sig,vnode_t * vp,offset_t offset,rlim64_t rlimit,cred_t * credp,core_content_t content)1787c478bd9Sstevel@tonic-gate write_elfnotes(proc_t *p, int sig, vnode_t *vp, offset_t offset,
1797c478bd9Sstevel@tonic-gate rlim64_t rlimit, cred_t *credp, core_content_t content)
1807c478bd9Sstevel@tonic-gate {
1817c478bd9Sstevel@tonic-gate union {
1827c478bd9Sstevel@tonic-gate psinfo_t psinfo;
1837c478bd9Sstevel@tonic-gate pstatus_t pstatus;
1847c478bd9Sstevel@tonic-gate lwpsinfo_t lwpsinfo;
1857c478bd9Sstevel@tonic-gate lwpstatus_t lwpstatus;
1867c478bd9Sstevel@tonic-gate #if defined(__sparc)
1877c478bd9Sstevel@tonic-gate gwindows_t gwindows;
1887c478bd9Sstevel@tonic-gate asrset_t asrset;
1897c478bd9Sstevel@tonic-gate #endif /* __sparc */
1907c478bd9Sstevel@tonic-gate char xregs[1];
1917c478bd9Sstevel@tonic-gate aux_entry_t auxv[__KERN_NAUXV_IMPL];
1927c478bd9Sstevel@tonic-gate prcred_t pcred;
1937c478bd9Sstevel@tonic-gate prpriv_t ppriv;
1947c478bd9Sstevel@tonic-gate priv_impl_info_t prinfo;
1957c478bd9Sstevel@tonic-gate struct utsname uts;
196d2a70789SRichard Lowe prsecflags_t psecflags;
197350ffdd5SRobert Mustacchi prupanic_t upanic;
1987c478bd9Sstevel@tonic-gate } *bigwad;
1997c478bd9Sstevel@tonic-gate
200ed093b41SRobert Mustacchi size_t xregsize = prhasx(p) ? prgetprxregsize(p) : 0;
2017c478bd9Sstevel@tonic-gate size_t crsize = sizeof (prcred_t) + sizeof (gid_t) * (ngroups_max - 1);
2027c478bd9Sstevel@tonic-gate size_t psize = prgetprivsize();
2037c478bd9Sstevel@tonic-gate size_t bigsize = MAX(psize, MAX(sizeof (*bigwad),
20434bdffbfSGarrett D'Amore MAX(xregsize, crsize)));
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate priv_impl_info_t *prii;
2077c478bd9Sstevel@tonic-gate
2087c478bd9Sstevel@tonic-gate lwpdir_t *ldp;
2097c478bd9Sstevel@tonic-gate lwpent_t *lep;
2107c478bd9Sstevel@tonic-gate kthread_t *t;
2117c478bd9Sstevel@tonic-gate klwp_t *lwp;
2127c478bd9Sstevel@tonic-gate user_t *up;
2137c478bd9Sstevel@tonic-gate int i;
2147c478bd9Sstevel@tonic-gate int nlwp;
2157c478bd9Sstevel@tonic-gate int nzomb;
2167c478bd9Sstevel@tonic-gate int error;
2177c478bd9Sstevel@tonic-gate uchar_t oldsig;
21834bdffbfSGarrett D'Amore uf_info_t *fip;
21934bdffbfSGarrett D'Amore int fd;
22034bdffbfSGarrett D'Amore vnode_t *vroot;
22134bdffbfSGarrett D'Amore
22286ef0a63SRichard Lowe #if defined(__i386_COMPAT)
2237c478bd9Sstevel@tonic-gate struct ssd *ssd;
2247c478bd9Sstevel@tonic-gate size_t ssdsize;
22586ef0a63SRichard Lowe #endif /* __i386_COMPAT */
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate bigsize = MAX(bigsize, priv_get_implinfo_size());
2287c478bd9Sstevel@tonic-gate
2297c478bd9Sstevel@tonic-gate bigwad = kmem_alloc(bigsize, KM_SLEEP);
2307c478bd9Sstevel@tonic-gate
2317c478bd9Sstevel@tonic-gate /*
2327c478bd9Sstevel@tonic-gate * The order of the elfnote entries should be same here
2337c478bd9Sstevel@tonic-gate * and in the gcore(1) command. Synchronization is
2347c478bd9Sstevel@tonic-gate * needed between the kernel and gcore(1).
2357c478bd9Sstevel@tonic-gate */
2367c478bd9Sstevel@tonic-gate
2377c478bd9Sstevel@tonic-gate /*
2387c478bd9Sstevel@tonic-gate * Get the psinfo, and set the wait status to indicate that a core was
2397c478bd9Sstevel@tonic-gate * dumped. We have to forge this since p->p_wcode is not set yet.
2407c478bd9Sstevel@tonic-gate */
2417c478bd9Sstevel@tonic-gate mutex_enter(&p->p_lock);
2427c478bd9Sstevel@tonic-gate prgetpsinfo(p, &bigwad->psinfo);
2437c478bd9Sstevel@tonic-gate mutex_exit(&p->p_lock);
2447c478bd9Sstevel@tonic-gate bigwad->psinfo.pr_wstat = wstat(CLD_DUMPED, sig);
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_PSINFO, sizeof (bigwad->psinfo),
2477c478bd9Sstevel@tonic-gate (caddr_t)&bigwad->psinfo, rlimit, credp);
2487c478bd9Sstevel@tonic-gate if (error)
2497c478bd9Sstevel@tonic-gate goto done;
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate /*
2527c478bd9Sstevel@tonic-gate * Modify t_whystop and lwp_cursig so it appears that the current LWP
2537c478bd9Sstevel@tonic-gate * is stopped after faulting on the signal that caused the core dump.
2547c478bd9Sstevel@tonic-gate * As a result, prgetstatus() will record that signal, the saved
2557c478bd9Sstevel@tonic-gate * lwp_siginfo, and its signal handler in the core file status. We
2567c478bd9Sstevel@tonic-gate * restore lwp_cursig in case a subsequent signal was received while
2577c478bd9Sstevel@tonic-gate * dumping core.
2587c478bd9Sstevel@tonic-gate */
2597c478bd9Sstevel@tonic-gate mutex_enter(&p->p_lock);
2607c478bd9Sstevel@tonic-gate lwp = ttolwp(curthread);
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate oldsig = lwp->lwp_cursig;
2637c478bd9Sstevel@tonic-gate lwp->lwp_cursig = (uchar_t)sig;
2647c478bd9Sstevel@tonic-gate curthread->t_whystop = PR_FAULTED;
2657c478bd9Sstevel@tonic-gate
2667c478bd9Sstevel@tonic-gate prgetstatus(p, &bigwad->pstatus, p->p_zone);
2677c478bd9Sstevel@tonic-gate bigwad->pstatus.pr_lwp.pr_why = 0;
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gate curthread->t_whystop = 0;
2707c478bd9Sstevel@tonic-gate lwp->lwp_cursig = oldsig;
2717c478bd9Sstevel@tonic-gate mutex_exit(&p->p_lock);
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_PSTATUS, sizeof (bigwad->pstatus),
2747c478bd9Sstevel@tonic-gate (caddr_t)&bigwad->pstatus, rlimit, credp);
2757c478bd9Sstevel@tonic-gate if (error)
2767c478bd9Sstevel@tonic-gate goto done;
2777c478bd9Sstevel@tonic-gate
2787c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_PLATFORM, strlen(platform) + 1,
2797c478bd9Sstevel@tonic-gate platform, rlimit, credp);
2807c478bd9Sstevel@tonic-gate if (error)
2817c478bd9Sstevel@tonic-gate goto done;
2827c478bd9Sstevel@tonic-gate
2837c478bd9Sstevel@tonic-gate up = PTOU(p);
2847c478bd9Sstevel@tonic-gate for (i = 0; i < __KERN_NAUXV_IMPL; i++) {
2857c478bd9Sstevel@tonic-gate bigwad->auxv[i].a_type = up->u_auxv[i].a_type;
2867c478bd9Sstevel@tonic-gate bigwad->auxv[i].a_un.a_val = up->u_auxv[i].a_un.a_val;
2877c478bd9Sstevel@tonic-gate }
2887c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_AUXV, sizeof (bigwad->auxv),
2897c478bd9Sstevel@tonic-gate (caddr_t)bigwad->auxv, rlimit, credp);
2907c478bd9Sstevel@tonic-gate if (error)
2917c478bd9Sstevel@tonic-gate goto done;
2927c478bd9Sstevel@tonic-gate
2937c478bd9Sstevel@tonic-gate bcopy(&utsname, &bigwad->uts, sizeof (struct utsname));
2947c478bd9Sstevel@tonic-gate if (!INGLOBALZONE(p)) {
2957c478bd9Sstevel@tonic-gate bcopy(p->p_zone->zone_nodename, &bigwad->uts.nodename,
2967c478bd9Sstevel@tonic-gate _SYS_NMLN);
2977c478bd9Sstevel@tonic-gate }
2987c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_UTSNAME, sizeof (struct utsname),
2997c478bd9Sstevel@tonic-gate (caddr_t)&bigwad->uts, rlimit, credp);
3007c478bd9Sstevel@tonic-gate if (error)
3017c478bd9Sstevel@tonic-gate goto done;
3027c478bd9Sstevel@tonic-gate
303d2a70789SRichard Lowe prgetsecflags(p, &bigwad->psecflags);
304d2a70789SRichard Lowe error = elfnote(vp, &offset, NT_SECFLAGS, sizeof (prsecflags_t),
305d2a70789SRichard Lowe (caddr_t)&bigwad->psecflags, rlimit, credp);
306d2a70789SRichard Lowe if (error)
307d2a70789SRichard Lowe goto done;
308d2a70789SRichard Lowe
309*552c19f2SRobert Mustacchi bzero(bigwad, crsize);
3107c478bd9Sstevel@tonic-gate prgetcred(p, &bigwad->pcred);
3117c478bd9Sstevel@tonic-gate
3127c478bd9Sstevel@tonic-gate if (bigwad->pcred.pr_ngroups != 0) {
3137c478bd9Sstevel@tonic-gate crsize = sizeof (prcred_t) +
3147c478bd9Sstevel@tonic-gate sizeof (gid_t) * (bigwad->pcred.pr_ngroups - 1);
3157c478bd9Sstevel@tonic-gate } else
3167c478bd9Sstevel@tonic-gate crsize = sizeof (prcred_t);
3177c478bd9Sstevel@tonic-gate
3187c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_PRCRED, crsize,
3197c478bd9Sstevel@tonic-gate (caddr_t)&bigwad->pcred, rlimit, credp);
3207c478bd9Sstevel@tonic-gate if (error)
3217c478bd9Sstevel@tonic-gate goto done;
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_CONTENT, sizeof (core_content_t),
3247c478bd9Sstevel@tonic-gate (caddr_t)&content, rlimit, credp);
3257c478bd9Sstevel@tonic-gate if (error)
3267c478bd9Sstevel@tonic-gate goto done;
3277c478bd9Sstevel@tonic-gate
3287c478bd9Sstevel@tonic-gate prgetpriv(p, &bigwad->ppriv);
3297c478bd9Sstevel@tonic-gate
3307c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_PRPRIV, psize,
3317c478bd9Sstevel@tonic-gate (caddr_t)&bigwad->ppriv, rlimit, credp);
3327c478bd9Sstevel@tonic-gate if (error)
3337c478bd9Sstevel@tonic-gate goto done;
3347c478bd9Sstevel@tonic-gate
3357c478bd9Sstevel@tonic-gate prii = priv_hold_implinfo();
3367c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_PRPRIVINFO, priv_get_implinfo_size(),
3377c478bd9Sstevel@tonic-gate (caddr_t)prii, rlimit, credp);
3387c478bd9Sstevel@tonic-gate priv_release_implinfo();
3397c478bd9Sstevel@tonic-gate if (error)
3407c478bd9Sstevel@tonic-gate goto done;
3417c478bd9Sstevel@tonic-gate
3427c478bd9Sstevel@tonic-gate /* zone can't go away as long as process exists */
3437c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_ZONENAME,
3447c478bd9Sstevel@tonic-gate strlen(p->p_zone->zone_name) + 1, p->p_zone->zone_name,
3457c478bd9Sstevel@tonic-gate rlimit, credp);
3467c478bd9Sstevel@tonic-gate if (error)
3477c478bd9Sstevel@tonic-gate goto done;
3487c478bd9Sstevel@tonic-gate
34934bdffbfSGarrett D'Amore
35034bdffbfSGarrett D'Amore /* open file table */
35134bdffbfSGarrett D'Amore vroot = PTOU(p)->u_rdir;
35234bdffbfSGarrett D'Amore if (vroot == NULL)
35334bdffbfSGarrett D'Amore vroot = rootdir;
35434bdffbfSGarrett D'Amore
35534bdffbfSGarrett D'Amore VN_HOLD(vroot);
35634bdffbfSGarrett D'Amore
35734bdffbfSGarrett D'Amore fip = P_FINFO(p);
35834bdffbfSGarrett D'Amore
35934bdffbfSGarrett D'Amore for (fd = 0; fd < fip->fi_nfiles; fd++) {
36034bdffbfSGarrett D'Amore uf_entry_t *ufp;
36134bdffbfSGarrett D'Amore vnode_t *fvp;
36234bdffbfSGarrett D'Amore struct file *fp;
36334bdffbfSGarrett D'Amore vattr_t vattr;
364a02120c4SAndy Fiddaman prfdinfo_core_t fdinfo;
36534bdffbfSGarrett D'Amore
36634bdffbfSGarrett D'Amore bzero(&fdinfo, sizeof (fdinfo));
36734bdffbfSGarrett D'Amore
36834bdffbfSGarrett D'Amore mutex_enter(&fip->fi_lock);
36934bdffbfSGarrett D'Amore UF_ENTER(ufp, fip, fd);
37034bdffbfSGarrett D'Amore if (((fp = ufp->uf_file) == NULL) || (fp->f_count < 1)) {
37134bdffbfSGarrett D'Amore UF_EXIT(ufp);
37234bdffbfSGarrett D'Amore mutex_exit(&fip->fi_lock);
37334bdffbfSGarrett D'Amore continue;
37434bdffbfSGarrett D'Amore }
37534bdffbfSGarrett D'Amore
37634bdffbfSGarrett D'Amore fdinfo.pr_fd = fd;
37734bdffbfSGarrett D'Amore fdinfo.pr_fdflags = ufp->uf_flag;
37834bdffbfSGarrett D'Amore fdinfo.pr_fileflags = fp->f_flag2;
37934bdffbfSGarrett D'Amore fdinfo.pr_fileflags <<= 16;
38034bdffbfSGarrett D'Amore fdinfo.pr_fileflags |= fp->f_flag;
38134bdffbfSGarrett D'Amore if ((fdinfo.pr_fileflags & (FSEARCH | FEXEC)) == 0)
38234bdffbfSGarrett D'Amore fdinfo.pr_fileflags += FOPEN;
38334bdffbfSGarrett D'Amore fdinfo.pr_offset = fp->f_offset;
38434bdffbfSGarrett D'Amore
38534bdffbfSGarrett D'Amore
38634bdffbfSGarrett D'Amore fvp = fp->f_vnode;
38734bdffbfSGarrett D'Amore VN_HOLD(fvp);
38834bdffbfSGarrett D'Amore UF_EXIT(ufp);
38934bdffbfSGarrett D'Amore mutex_exit(&fip->fi_lock);
39034bdffbfSGarrett D'Amore
39134bdffbfSGarrett D'Amore /*
39234bdffbfSGarrett D'Amore * There are some vnodes that have no corresponding
39334bdffbfSGarrett D'Amore * path. Its reasonable for this to fail, in which
39434bdffbfSGarrett D'Amore * case the path will remain an empty string.
39534bdffbfSGarrett D'Amore */
39634bdffbfSGarrett D'Amore (void) vnodetopath(vroot, fvp, fdinfo.pr_path,
39734bdffbfSGarrett D'Amore sizeof (fdinfo.pr_path), credp);
39834bdffbfSGarrett D'Amore
39933d794d1SSimon Klinkert if (VOP_GETATTR(fvp, &vattr, 0, credp, NULL) != 0) {
40033d794d1SSimon Klinkert /*
40133d794d1SSimon Klinkert * Try to write at least a subset of information
40233d794d1SSimon Klinkert */
40333d794d1SSimon Klinkert fdinfo.pr_major = 0;
40433d794d1SSimon Klinkert fdinfo.pr_minor = 0;
40533d794d1SSimon Klinkert fdinfo.pr_ino = 0;
40633d794d1SSimon Klinkert fdinfo.pr_mode = 0;
407f2f1e742SDan McDonald fdinfo.pr_uid = (uid_t)-1;
408f2f1e742SDan McDonald fdinfo.pr_gid = (gid_t)-1;
40933d794d1SSimon Klinkert fdinfo.pr_rmajor = 0;
41033d794d1SSimon Klinkert fdinfo.pr_rminor = 0;
41133d794d1SSimon Klinkert fdinfo.pr_size = -1;
41233d794d1SSimon Klinkert
41333d794d1SSimon Klinkert error = elfnote(vp, &offset, NT_FDINFO,
41433d794d1SSimon Klinkert sizeof (fdinfo), &fdinfo, rlimit, credp);
41534bdffbfSGarrett D'Amore VN_RELE(fvp);
41669f14d1fSSimon Klinkert if (error) {
41769f14d1fSSimon Klinkert VN_RELE(vroot);
41833d794d1SSimon Klinkert goto done;
41969f14d1fSSimon Klinkert }
42033d794d1SSimon Klinkert continue;
42134bdffbfSGarrett D'Amore }
42234bdffbfSGarrett D'Amore
42334bdffbfSGarrett D'Amore if (fvp->v_type == VSOCK)
42434bdffbfSGarrett D'Amore fdinfo.pr_fileflags |= sock_getfasync(fvp);
42534bdffbfSGarrett D'Amore
42634bdffbfSGarrett D'Amore VN_RELE(fvp);
42734bdffbfSGarrett D'Amore
42834bdffbfSGarrett D'Amore /*
42934bdffbfSGarrett D'Amore * This logic mirrors fstat(), which we cannot use
43034bdffbfSGarrett D'Amore * directly, as it calls copyout().
43134bdffbfSGarrett D'Amore */
43234bdffbfSGarrett D'Amore fdinfo.pr_major = getmajor(vattr.va_fsid);
43334bdffbfSGarrett D'Amore fdinfo.pr_minor = getminor(vattr.va_fsid);
43434bdffbfSGarrett D'Amore fdinfo.pr_ino = (ino64_t)vattr.va_nodeid;
43534bdffbfSGarrett D'Amore fdinfo.pr_mode = VTTOIF(vattr.va_type) | vattr.va_mode;
43634bdffbfSGarrett D'Amore fdinfo.pr_uid = vattr.va_uid;
43734bdffbfSGarrett D'Amore fdinfo.pr_gid = vattr.va_gid;
43834bdffbfSGarrett D'Amore fdinfo.pr_rmajor = getmajor(vattr.va_rdev);
43934bdffbfSGarrett D'Amore fdinfo.pr_rminor = getminor(vattr.va_rdev);
44034bdffbfSGarrett D'Amore fdinfo.pr_size = (off64_t)vattr.va_size;
44134bdffbfSGarrett D'Amore
44234bdffbfSGarrett D'Amore error = elfnote(vp, &offset, NT_FDINFO,
44334bdffbfSGarrett D'Amore sizeof (fdinfo), &fdinfo, rlimit, credp);
44434bdffbfSGarrett D'Amore if (error) {
4454b835deeSRobert Mustacchi VN_RELE(vroot);
44634bdffbfSGarrett D'Amore goto done;
44734bdffbfSGarrett D'Amore }
44834bdffbfSGarrett D'Amore }
44934bdffbfSGarrett D'Amore
4504b835deeSRobert Mustacchi VN_RELE(vroot);
4514b835deeSRobert Mustacchi
45286ef0a63SRichard Lowe #if defined(__i386_COMPAT)
4537c478bd9Sstevel@tonic-gate mutex_enter(&p->p_ldtlock);
4547c478bd9Sstevel@tonic-gate ssdsize = prnldt(p) * sizeof (struct ssd);
4557c478bd9Sstevel@tonic-gate if (ssdsize != 0) {
4567c478bd9Sstevel@tonic-gate ssd = kmem_alloc(ssdsize, KM_SLEEP);
4577c478bd9Sstevel@tonic-gate prgetldt(p, ssd);
4587c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_LDT, ssdsize,
4597c478bd9Sstevel@tonic-gate (caddr_t)ssd, rlimit, credp);
4607c478bd9Sstevel@tonic-gate kmem_free(ssd, ssdsize);
4617c478bd9Sstevel@tonic-gate }
4627c478bd9Sstevel@tonic-gate mutex_exit(&p->p_ldtlock);
4637c478bd9Sstevel@tonic-gate if (error)
4647c478bd9Sstevel@tonic-gate goto done;
46586ef0a63SRichard Lowe #endif /* defined(__i386_COMPAT) */
4667c478bd9Sstevel@tonic-gate
4677c478bd9Sstevel@tonic-gate nlwp = p->p_lwpcnt;
4687c478bd9Sstevel@tonic-gate nzomb = p->p_zombcnt;
4697c478bd9Sstevel@tonic-gate /* for each entry in the lwp directory ... */
4707c478bd9Sstevel@tonic-gate for (ldp = p->p_lwpdir; nlwp + nzomb != 0; ldp++) {
471ab618543SJohn Levon prlwpname_t name = { 0, };
4727c478bd9Sstevel@tonic-gate
4737c478bd9Sstevel@tonic-gate if ((lep = ldp->ld_entry) == NULL) /* empty slot */
4747c478bd9Sstevel@tonic-gate continue;
4757c478bd9Sstevel@tonic-gate
4767c478bd9Sstevel@tonic-gate if ((t = lep->le_thread) != NULL) { /* active lwp */
4777c478bd9Sstevel@tonic-gate ASSERT(nlwp != 0);
4787c478bd9Sstevel@tonic-gate nlwp--;
4797c478bd9Sstevel@tonic-gate lwp = ttolwp(t);
4807c478bd9Sstevel@tonic-gate mutex_enter(&p->p_lock);
4817c478bd9Sstevel@tonic-gate prgetlwpsinfo(t, &bigwad->lwpsinfo);
482ab618543SJohn Levon if (t->t_name != NULL) {
483ab618543SJohn Levon (void) strlcpy(name.pr_lwpname, t->t_name,
484ab618543SJohn Levon sizeof (name.pr_lwpname));
485ab618543SJohn Levon }
4867c478bd9Sstevel@tonic-gate mutex_exit(&p->p_lock);
4877c478bd9Sstevel@tonic-gate } else { /* zombie lwp */
4887c478bd9Sstevel@tonic-gate ASSERT(nzomb != 0);
4897c478bd9Sstevel@tonic-gate nzomb--;
4907c478bd9Sstevel@tonic-gate bzero(&bigwad->lwpsinfo, sizeof (bigwad->lwpsinfo));
4917c478bd9Sstevel@tonic-gate bigwad->lwpsinfo.pr_lwpid = lep->le_lwpid;
4927c478bd9Sstevel@tonic-gate bigwad->lwpsinfo.pr_state = SZOMB;
4937c478bd9Sstevel@tonic-gate bigwad->lwpsinfo.pr_sname = 'Z';
4947c478bd9Sstevel@tonic-gate bigwad->lwpsinfo.pr_start.tv_sec = lep->le_start;
4957c478bd9Sstevel@tonic-gate }
496ab618543SJohn Levon
497ab618543SJohn Levon name.pr_lwpid = bigwad->lwpsinfo.pr_lwpid;
498ab618543SJohn Levon
4997c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_LWPSINFO,
5007c478bd9Sstevel@tonic-gate sizeof (bigwad->lwpsinfo), (caddr_t)&bigwad->lwpsinfo,
5017c478bd9Sstevel@tonic-gate rlimit, credp);
5027c478bd9Sstevel@tonic-gate if (error)
5037c478bd9Sstevel@tonic-gate goto done;
504ab618543SJohn Levon
5057c478bd9Sstevel@tonic-gate if (t == NULL) /* nothing more to do for a zombie */
5067c478bd9Sstevel@tonic-gate continue;
5077c478bd9Sstevel@tonic-gate
5087c478bd9Sstevel@tonic-gate mutex_enter(&p->p_lock);
5097c478bd9Sstevel@tonic-gate if (t == curthread) {
5107c478bd9Sstevel@tonic-gate /*
5117c478bd9Sstevel@tonic-gate * Modify t_whystop and lwp_cursig so it appears that
5127c478bd9Sstevel@tonic-gate * the current LWP is stopped after faulting on the
5137c478bd9Sstevel@tonic-gate * signal that caused the core dump. As a result,
5147c478bd9Sstevel@tonic-gate * prgetlwpstatus() will record that signal, the saved
5157c478bd9Sstevel@tonic-gate * lwp_siginfo, and its signal handler in the core file
5167c478bd9Sstevel@tonic-gate * status. We restore lwp_cursig in case a subsequent
5177c478bd9Sstevel@tonic-gate * signal was received while dumping core.
5187c478bd9Sstevel@tonic-gate */
5197c478bd9Sstevel@tonic-gate oldsig = lwp->lwp_cursig;
5207c478bd9Sstevel@tonic-gate lwp->lwp_cursig = (uchar_t)sig;
5217c478bd9Sstevel@tonic-gate t->t_whystop = PR_FAULTED;
5227c478bd9Sstevel@tonic-gate
5237c478bd9Sstevel@tonic-gate prgetlwpstatus(t, &bigwad->lwpstatus, p->p_zone);
5247c478bd9Sstevel@tonic-gate bigwad->lwpstatus.pr_why = 0;
5257c478bd9Sstevel@tonic-gate
5267c478bd9Sstevel@tonic-gate t->t_whystop = 0;
5277c478bd9Sstevel@tonic-gate lwp->lwp_cursig = oldsig;
5287c478bd9Sstevel@tonic-gate } else {
5297c478bd9Sstevel@tonic-gate prgetlwpstatus(t, &bigwad->lwpstatus, p->p_zone);
5307c478bd9Sstevel@tonic-gate }
5317c478bd9Sstevel@tonic-gate mutex_exit(&p->p_lock);
5327c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_LWPSTATUS,
5337c478bd9Sstevel@tonic-gate sizeof (bigwad->lwpstatus), (caddr_t)&bigwad->lwpstatus,
5347c478bd9Sstevel@tonic-gate rlimit, credp);
5357c478bd9Sstevel@tonic-gate if (error)
5367c478bd9Sstevel@tonic-gate goto done;
5377c478bd9Sstevel@tonic-gate
538ab618543SJohn Levon if ((error = elfnote(vp, &offset, NT_LWPNAME, sizeof (name),
539ab618543SJohn Levon (caddr_t)&name, rlimit, credp)) != 0)
540ab618543SJohn Levon goto done;
541ab618543SJohn Levon
542ab618543SJohn Levon
5437c478bd9Sstevel@tonic-gate #if defined(__sparc)
5447c478bd9Sstevel@tonic-gate /*
5457c478bd9Sstevel@tonic-gate * Unspilled SPARC register windows.
5467c478bd9Sstevel@tonic-gate */
5477c478bd9Sstevel@tonic-gate {
5487c478bd9Sstevel@tonic-gate size_t size = prnwindows(lwp);
5497c478bd9Sstevel@tonic-gate
5507c478bd9Sstevel@tonic-gate if (size != 0) {
5517c478bd9Sstevel@tonic-gate size = sizeof (gwindows_t) -
5527c478bd9Sstevel@tonic-gate (SPARC_MAXREGWINDOW - size) *
5537c478bd9Sstevel@tonic-gate sizeof (struct rwindow);
5547c478bd9Sstevel@tonic-gate prgetwindows(lwp, &bigwad->gwindows);
5557c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_GWINDOWS,
5567c478bd9Sstevel@tonic-gate size, (caddr_t)&bigwad->gwindows,
5577c478bd9Sstevel@tonic-gate rlimit, credp);
5587c478bd9Sstevel@tonic-gate if (error)
5597c478bd9Sstevel@tonic-gate goto done;
5607c478bd9Sstevel@tonic-gate }
5617c478bd9Sstevel@tonic-gate }
5627c478bd9Sstevel@tonic-gate /*
5637c478bd9Sstevel@tonic-gate * Ancillary State Registers.
5647c478bd9Sstevel@tonic-gate */
5657c478bd9Sstevel@tonic-gate if (p->p_model == DATAMODEL_LP64) {
5667c478bd9Sstevel@tonic-gate prgetasregs(lwp, bigwad->asrset);
5677c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_ASRS,
5687c478bd9Sstevel@tonic-gate sizeof (asrset_t), (caddr_t)bigwad->asrset,
5697c478bd9Sstevel@tonic-gate rlimit, credp);
5707c478bd9Sstevel@tonic-gate if (error)
5717c478bd9Sstevel@tonic-gate goto done;
5727c478bd9Sstevel@tonic-gate }
5737c478bd9Sstevel@tonic-gate #endif /* __sparc */
5747c478bd9Sstevel@tonic-gate
5757c478bd9Sstevel@tonic-gate if (xregsize) {
576ed093b41SRobert Mustacchi prgetprxregs(lwp, (prxregset_t *)bigwad->xregs);
5777c478bd9Sstevel@tonic-gate error = elfnote(vp, &offset, NT_PRXREG,
5787c478bd9Sstevel@tonic-gate xregsize, bigwad->xregs, rlimit, credp);
5797c478bd9Sstevel@tonic-gate if (error)
5807c478bd9Sstevel@tonic-gate goto done;
5817c478bd9Sstevel@tonic-gate }
582f971a346SBryan Cantrill
583f971a346SBryan Cantrill if (t->t_lwp->lwp_spymaster != NULL) {
584f971a346SBryan Cantrill void *psaddr = t->t_lwp->lwp_spymaster;
585f971a346SBryan Cantrill #ifdef _ELF32_COMPAT
586f971a346SBryan Cantrill /*
587f971a346SBryan Cantrill * On a 64-bit kernel with 32-bit ELF compatibility,
588f971a346SBryan Cantrill * this file is compiled into two different objects:
589f971a346SBryan Cantrill * one is compiled normally, and the other is compiled
590f971a346SBryan Cantrill * with _ELF32_COMPAT set -- and therefore with a
591f971a346SBryan Cantrill * psinfo_t defined to be a psinfo32_t. However, the
592f971a346SBryan Cantrill * psinfo_t denoting our spymaster is always of the
593f971a346SBryan Cantrill * native type; if we are in the _ELF32_COMPAT case,
594f971a346SBryan Cantrill * we need to explicitly convert it.
595f971a346SBryan Cantrill */
596f971a346SBryan Cantrill if (p->p_model == DATAMODEL_ILP32) {
597f971a346SBryan Cantrill psinfo_kto32(psaddr, &bigwad->psinfo);
598f971a346SBryan Cantrill psaddr = &bigwad->psinfo;
599f971a346SBryan Cantrill }
600f971a346SBryan Cantrill #endif
601f971a346SBryan Cantrill
602f971a346SBryan Cantrill error = elfnote(vp, &offset, NT_SPYMASTER,
603f971a346SBryan Cantrill sizeof (psinfo_t), psaddr, rlimit, credp);
604f971a346SBryan Cantrill if (error)
605f971a346SBryan Cantrill goto done;
606f971a346SBryan Cantrill }
6077c478bd9Sstevel@tonic-gate }
6087c478bd9Sstevel@tonic-gate ASSERT(nlwp == 0);
6097c478bd9Sstevel@tonic-gate
610350ffdd5SRobert Mustacchi /*
611350ffdd5SRobert Mustacchi * If a upanic occurred, add a note for it.
612350ffdd5SRobert Mustacchi */
613350ffdd5SRobert Mustacchi mutex_enter(&p->p_lock);
614350ffdd5SRobert Mustacchi if ((p->p_upanicflag & P_UPF_PANICKED) != 0) {
615350ffdd5SRobert Mustacchi bzero(&bigwad->upanic, sizeof (prupanic_t));
616350ffdd5SRobert Mustacchi bigwad->upanic.pru_version = PRUPANIC_VERSION_1;
617350ffdd5SRobert Mustacchi if ((p->p_upanicflag & P_UPF_INVALMSG) != 0) {
618350ffdd5SRobert Mustacchi bigwad->upanic.pru_flags |= PRUPANIC_FLAG_MSG_ERROR;
619350ffdd5SRobert Mustacchi }
620350ffdd5SRobert Mustacchi
621350ffdd5SRobert Mustacchi if ((p->p_upanicflag & P_UPF_TRUNCMSG) != 0) {
622350ffdd5SRobert Mustacchi bigwad->upanic.pru_flags |= PRUPANIC_FLAG_MSG_TRUNC;
623350ffdd5SRobert Mustacchi }
624350ffdd5SRobert Mustacchi
625350ffdd5SRobert Mustacchi if ((p->p_upanicflag & P_UPF_HAVEMSG) != 0) {
626350ffdd5SRobert Mustacchi bigwad->upanic.pru_flags |= PRUPANIC_FLAG_MSG_VALID;
627350ffdd5SRobert Mustacchi bcopy(p->p_upanic, bigwad->upanic.pru_data,
628350ffdd5SRobert Mustacchi PRUPANIC_BUFLEN);
629350ffdd5SRobert Mustacchi }
630350ffdd5SRobert Mustacchi
631b7335573SRobert Mustacchi mutex_exit(&p->p_lock);
632350ffdd5SRobert Mustacchi error = elfnote(vp, &offset, NT_UPANIC, sizeof (prupanic_t),
633350ffdd5SRobert Mustacchi &bigwad->upanic, rlimit, credp);
634350ffdd5SRobert Mustacchi if (error != 0) {
635350ffdd5SRobert Mustacchi goto done;
636350ffdd5SRobert Mustacchi }
637b7335573SRobert Mustacchi } else {
638b7335573SRobert Mustacchi mutex_exit(&p->p_lock);
639350ffdd5SRobert Mustacchi }
640350ffdd5SRobert Mustacchi
6417c478bd9Sstevel@tonic-gate done:
6427c478bd9Sstevel@tonic-gate kmem_free(bigwad, bigsize);
6437c478bd9Sstevel@tonic-gate return (error);
6447c478bd9Sstevel@tonic-gate }
645