1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
29 * Copyright 2018 Joyent, Inc.
30 * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
31 * Copyright 2023 Oxide Computer Company
32 */
33
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/thread.h>
37 #include <sys/sysmacros.h>
38 #include <sys/signal.h>
39 #include <sys/cred.h>
40 #include <sys/priv.h>
41 #include <sys/user.h>
42 #include <sys/file.h>
43 #include <sys/errno.h>
44 #include <sys/vnode.h>
45 #include <sys/mode.h>
46 #include <sys/vfs.h>
47 #include <sys/mman.h>
48 #include <sys/kmem.h>
49 #include <sys/proc.h>
50 #include <sys/pathname.h>
51 #include <sys/cmn_err.h>
52 #include <sys/systm.h>
53 #include <sys/elf.h>
54 #include <sys/vmsystm.h>
55 #include <sys/debug.h>
56 #include <sys/procfs.h>
57 #include <sys/regset.h>
58 #include <sys/auxv.h>
59 #include <sys/exec.h>
60 #include <sys/prsystm.h>
61 #include <sys/utsname.h>
62 #include <sys/zone.h>
63 #include <vm/as.h>
64 #include <vm/rm.h>
65 #include <sys/modctl.h>
66 #include <sys/systeminfo.h>
67 #include <sys/machelf.h>
68 #include <sys/sunddi.h>
69 #include "elf_impl.h"
70 #if defined(__i386_COMPAT)
71 #include <sys/sysi86.h>
72 #endif
73
74 void
75 setup_note_header(Phdr *v, proc_t *p)
76 {
77 int nlwp = p->p_lwpcnt;
78 int nzomb = p->p_zombcnt;
79 int nfd;
80 size_t size;
81 prcred_t *pcrp;
82 uf_info_t *fip;
83 uf_entry_t *ufp;
84 int fd;
85
86 fip = P_FINFO(p);
87 nfd = 0;
88 mutex_enter(&fip->fi_lock);
89 for (fd = 0; fd < fip->fi_nfiles; fd++) {
90 UF_ENTER(ufp, fip, fd);
91 if ((ufp->uf_file != NULL) && (ufp->uf_file->f_count > 0))
92 nfd++;
93 UF_EXIT(ufp);
94 }
95 mutex_exit(&fip->fi_lock);
96
97 v[0].p_type = PT_NOTE;
98 v[0].p_flags = PF_R;
99 v[0].p_filesz = (sizeof (Note) * (10 + 3 * nlwp + nzomb + nfd))
100 + roundup(sizeof (psinfo_t), sizeof (Word))
101 + roundup(sizeof (pstatus_t), sizeof (Word))
102 + roundup(prgetprivsize(), sizeof (Word))
103 + roundup(priv_get_implinfo_size(), sizeof (Word))
104 + roundup(strlen(platform) + 1, sizeof (Word))
105 + roundup(strlen(p->p_zone->zone_name) + 1, sizeof (Word))
106 + roundup(__KERN_NAUXV_IMPL * sizeof (aux_entry_t), sizeof (Word))
107 + roundup(sizeof (utsname), sizeof (Word))
108 + roundup(sizeof (core_content_t), sizeof (Word))
109 + roundup(sizeof (prsecflags_t), sizeof (Word))
110 + (nlwp + nzomb) * roundup(sizeof (lwpsinfo_t), sizeof (Word))
111 + nlwp * roundup(sizeof (lwpstatus_t), sizeof (Word))
112 + nlwp * roundup(sizeof (prlwpname_t), sizeof (Word))
113 + nfd * roundup(sizeof (prfdinfo_core_t), sizeof (Word));
114
115 if (curproc->p_agenttp != NULL) {
116 v[0].p_filesz += sizeof (Note) +
117 roundup(sizeof (psinfo_t), sizeof (Word));
118 }
119
120 size = sizeof (prcred_t) + sizeof (gid_t) * (ngroups_max - 1);
121 pcrp = kmem_alloc(size, KM_SLEEP);
122 prgetcred(p, pcrp);
123 if (pcrp->pr_ngroups != 0) {
124 v[0].p_filesz += sizeof (Note) + roundup(sizeof (prcred_t) +
125 sizeof (gid_t) * (pcrp->pr_ngroups - 1), sizeof (Word));
126 } else {
127 v[0].p_filesz += sizeof (Note) +
128 roundup(sizeof (prcred_t), sizeof (Word));
129 }
130 kmem_free(pcrp, size);
131
132
133 #if defined(__i386_COMPAT)
134 mutex_enter(&p->p_ldtlock);
135 size = prnldt(p) * sizeof (struct ssd);
136 mutex_exit(&p->p_ldtlock);
137 if (size != 0)
138 v[0].p_filesz += sizeof (Note) + roundup(size, sizeof (Word));
139 #endif /* __i386_COMPAT */
140
141 if ((size = prhasx(p) ? prgetprxregsize(p) : 0) != 0)
142 v[0].p_filesz += nlwp * sizeof (Note)
143 + nlwp * roundup(size, sizeof (Word));
144
145 #if defined(__sparc)
146 /*
147 * Figure out the number and sizes of register windows.
148 */
149 {
150 kthread_t *t = p->p_tlist;
151 do {
152 if ((size = prnwindows(ttolwp(t))) != 0) {
153 size = sizeof (gwindows_t) -
154 (SPARC_MAXREGWINDOW - size) *
155 sizeof (struct rwindow);
156 v[0].p_filesz += sizeof (Note) +
157 roundup(size, sizeof (Word));
158 }
159 } while ((t = t->t_forw) != p->p_tlist);
160 }
161 /*
162 * Space for the Ancillary State Registers.
163 */
164 if (p->p_model == DATAMODEL_LP64)
165 v[0].p_filesz += nlwp * sizeof (Note)
166 + nlwp * roundup(sizeof (asrset_t), sizeof (Word));
167 #endif /* __sparc */
168
169 mutex_enter(&p->p_lock);
170 if ((p->p_upanicflag & P_UPF_PANICKED) != 0) {
171 v[0].p_filesz += sizeof (Note) +
172 roundup(sizeof (prupanic_t), sizeof (Word));
173 }
174 mutex_exit(&p->p_lock);
175 }
176
177 int
178 write_elfnotes(proc_t *p, int sig, vnode_t *vp, offset_t offset,
179 rlim64_t rlimit, cred_t *credp, core_content_t content)
180 {
181 union {
182 psinfo_t psinfo;
183 pstatus_t pstatus;
184 lwpsinfo_t lwpsinfo;
185 lwpstatus_t lwpstatus;
186 #if defined(__sparc)
187 gwindows_t gwindows;
188 asrset_t asrset;
189 #endif /* __sparc */
190 char xregs[1];
191 aux_entry_t auxv[__KERN_NAUXV_IMPL];
192 prcred_t pcred;
193 prpriv_t ppriv;
194 priv_impl_info_t prinfo;
195 struct utsname uts;
196 prsecflags_t psecflags;
197 prupanic_t upanic;
198 } *bigwad;
199
200 size_t xregsize = prhasx(p) ? prgetprxregsize(p) : 0;
201 size_t crsize = sizeof (prcred_t) + sizeof (gid_t) * (ngroups_max - 1);
202 size_t psize = prgetprivsize();
203 size_t bigsize = MAX(psize, MAX(sizeof (*bigwad),
204 MAX(xregsize, crsize)));
205
206 priv_impl_info_t *prii;
207
208 lwpdir_t *ldp;
209 lwpent_t *lep;
210 kthread_t *t;
211 klwp_t *lwp;
212 user_t *up;
213 int i;
214 int nlwp;
215 int nzomb;
216 int error;
217 uchar_t oldsig;
218 uf_info_t *fip;
219 int fd;
220 vnode_t *vroot;
221
222 #if defined(__i386_COMPAT)
223 struct ssd *ssd;
224 size_t ssdsize;
225 #endif /* __i386_COMPAT */
226
227 bigsize = MAX(bigsize, priv_get_implinfo_size());
228
229 bigwad = kmem_alloc(bigsize, KM_SLEEP);
230
231 /*
232 * The order of the elfnote entries should be same here
233 * and in the gcore(1) command. Synchronization is
234 * needed between the kernel and gcore(1).
235 */
236
237 /*
238 * Get the psinfo, and set the wait status to indicate that a core was
239 * dumped. We have to forge this since p->p_wcode is not set yet.
240 */
241 mutex_enter(&p->p_lock);
242 prgetpsinfo(p, &bigwad->psinfo);
243 mutex_exit(&p->p_lock);
244 bigwad->psinfo.pr_wstat = wstat(CLD_DUMPED, sig);
245
246 error = elfnote(vp, &offset, NT_PSINFO, sizeof (bigwad->psinfo),
247 (caddr_t)&bigwad->psinfo, rlimit, credp);
248 if (error)
249 goto done;
250
251 /*
252 * Modify t_whystop and lwp_cursig so it appears that the current LWP
253 * is stopped after faulting on the signal that caused the core dump.
254 * As a result, prgetstatus() will record that signal, the saved
255 * lwp_siginfo, and its signal handler in the core file status. We
256 * restore lwp_cursig in case a subsequent signal was received while
257 * dumping core.
258 */
259 mutex_enter(&p->p_lock);
260 lwp = ttolwp(curthread);
261
262 oldsig = lwp->lwp_cursig;
263 lwp->lwp_cursig = (uchar_t)sig;
264 curthread->t_whystop = PR_FAULTED;
265
266 prgetstatus(p, &bigwad->pstatus, p->p_zone);
267 bigwad->pstatus.pr_lwp.pr_why = 0;
268
269 curthread->t_whystop = 0;
270 lwp->lwp_cursig = oldsig;
271 mutex_exit(&p->p_lock);
272
273 error = elfnote(vp, &offset, NT_PSTATUS, sizeof (bigwad->pstatus),
274 (caddr_t)&bigwad->pstatus, rlimit, credp);
275 if (error)
276 goto done;
277
278 error = elfnote(vp, &offset, NT_PLATFORM, strlen(platform) + 1,
279 platform, rlimit, credp);
280 if (error)
281 goto done;
282
283 up = PTOU(p);
284 for (i = 0; i < __KERN_NAUXV_IMPL; i++) {
285 bigwad->auxv[i].a_type = up->u_auxv[i].a_type;
286 bigwad->auxv[i].a_un.a_val = up->u_auxv[i].a_un.a_val;
287 }
288 error = elfnote(vp, &offset, NT_AUXV, sizeof (bigwad->auxv),
289 (caddr_t)bigwad->auxv, rlimit, credp);
290 if (error)
291 goto done;
292
293 bcopy(&utsname, &bigwad->uts, sizeof (struct utsname));
294 if (!INGLOBALZONE(p)) {
295 bcopy(p->p_zone->zone_nodename, &bigwad->uts.nodename,
296 _SYS_NMLN);
297 }
298 error = elfnote(vp, &offset, NT_UTSNAME, sizeof (struct utsname),
299 (caddr_t)&bigwad->uts, rlimit, credp);
300 if (error)
301 goto done;
302
303 prgetsecflags(p, &bigwad->psecflags);
304 error = elfnote(vp, &offset, NT_SECFLAGS, sizeof (prsecflags_t),
305 (caddr_t)&bigwad->psecflags, rlimit, credp);
306 if (error)
307 goto done;
308
309 prgetcred(p, &bigwad->pcred);
310
311 if (bigwad->pcred.pr_ngroups != 0) {
312 crsize = sizeof (prcred_t) +
313 sizeof (gid_t) * (bigwad->pcred.pr_ngroups - 1);
314 } else
315 crsize = sizeof (prcred_t);
316
317 error = elfnote(vp, &offset, NT_PRCRED, crsize,
318 (caddr_t)&bigwad->pcred, rlimit, credp);
319 if (error)
320 goto done;
321
322 error = elfnote(vp, &offset, NT_CONTENT, sizeof (core_content_t),
323 (caddr_t)&content, rlimit, credp);
324 if (error)
325 goto done;
326
327 prgetpriv(p, &bigwad->ppriv);
328
329 error = elfnote(vp, &offset, NT_PRPRIV, psize,
330 (caddr_t)&bigwad->ppriv, rlimit, credp);
331 if (error)
332 goto done;
333
334 prii = priv_hold_implinfo();
335 error = elfnote(vp, &offset, NT_PRPRIVINFO, priv_get_implinfo_size(),
336 (caddr_t)prii, rlimit, credp);
337 priv_release_implinfo();
338 if (error)
339 goto done;
340
341 /* zone can't go away as long as process exists */
342 error = elfnote(vp, &offset, NT_ZONENAME,
343 strlen(p->p_zone->zone_name) + 1, p->p_zone->zone_name,
344 rlimit, credp);
345 if (error)
346 goto done;
347
348
349 /* open file table */
350 vroot = PTOU(p)->u_rdir;
351 if (vroot == NULL)
352 vroot = rootdir;
353
354 VN_HOLD(vroot);
355
356 fip = P_FINFO(p);
357
358 for (fd = 0; fd < fip->fi_nfiles; fd++) {
359 uf_entry_t *ufp;
360 vnode_t *fvp;
361 struct file *fp;
362 vattr_t vattr;
363 prfdinfo_core_t fdinfo;
364
365 bzero(&fdinfo, sizeof (fdinfo));
366
367 mutex_enter(&fip->fi_lock);
368 UF_ENTER(ufp, fip, fd);
369 if (((fp = ufp->uf_file) == NULL) || (fp->f_count < 1)) {
370 UF_EXIT(ufp);
371 mutex_exit(&fip->fi_lock);
372 continue;
373 }
374
375 fdinfo.pr_fd = fd;
376 fdinfo.pr_fdflags = ufp->uf_flag;
377 fdinfo.pr_fileflags = fp->f_flag2;
378 fdinfo.pr_fileflags <<= 16;
379 fdinfo.pr_fileflags |= fp->f_flag;
380 if ((fdinfo.pr_fileflags & (FSEARCH | FEXEC)) == 0)
381 fdinfo.pr_fileflags += FOPEN;
382 fdinfo.pr_offset = fp->f_offset;
383
384
385 fvp = fp->f_vnode;
386 VN_HOLD(fvp);
387 UF_EXIT(ufp);
388 mutex_exit(&fip->fi_lock);
389
390 /*
391 * There are some vnodes that have no corresponding
392 * path. Its reasonable for this to fail, in which
393 * case the path will remain an empty string.
394 */
395 (void) vnodetopath(vroot, fvp, fdinfo.pr_path,
396 sizeof (fdinfo.pr_path), credp);
397
398 if (VOP_GETATTR(fvp, &vattr, 0, credp, NULL) != 0) {
399 /*
400 * Try to write at least a subset of information
401 */
402 fdinfo.pr_major = 0;
403 fdinfo.pr_minor = 0;
404 fdinfo.pr_ino = 0;
405 fdinfo.pr_mode = 0;
406 fdinfo.pr_uid = (uid_t)-1;
407 fdinfo.pr_gid = (gid_t)-1;
408 fdinfo.pr_rmajor = 0;
409 fdinfo.pr_rminor = 0;
410 fdinfo.pr_size = -1;
411
412 error = elfnote(vp, &offset, NT_FDINFO,
413 sizeof (fdinfo), &fdinfo, rlimit, credp);
414 VN_RELE(fvp);
415 if (error) {
416 VN_RELE(vroot);
417 goto done;
418 }
419 continue;
420 }
421
422 if (fvp->v_type == VSOCK)
423 fdinfo.pr_fileflags |= sock_getfasync(fvp);
424
425 VN_RELE(fvp);
426
427 /*
428 * This logic mirrors fstat(), which we cannot use
429 * directly, as it calls copyout().
430 */
431 fdinfo.pr_major = getmajor(vattr.va_fsid);
432 fdinfo.pr_minor = getminor(vattr.va_fsid);
433 fdinfo.pr_ino = (ino64_t)vattr.va_nodeid;
434 fdinfo.pr_mode = VTTOIF(vattr.va_type) | vattr.va_mode;
435 fdinfo.pr_uid = vattr.va_uid;
436 fdinfo.pr_gid = vattr.va_gid;
437 fdinfo.pr_rmajor = getmajor(vattr.va_rdev);
438 fdinfo.pr_rminor = getminor(vattr.va_rdev);
439 fdinfo.pr_size = (off64_t)vattr.va_size;
440
441 error = elfnote(vp, &offset, NT_FDINFO,
442 sizeof (fdinfo), &fdinfo, rlimit, credp);
443 if (error) {
444 VN_RELE(vroot);
445 goto done;
446 }
447 }
448
449 VN_RELE(vroot);
450
451 #if defined(__i386_COMPAT)
452 mutex_enter(&p->p_ldtlock);
453 ssdsize = prnldt(p) * sizeof (struct ssd);
454 if (ssdsize != 0) {
455 ssd = kmem_alloc(ssdsize, KM_SLEEP);
456 prgetldt(p, ssd);
457 error = elfnote(vp, &offset, NT_LDT, ssdsize,
458 (caddr_t)ssd, rlimit, credp);
459 kmem_free(ssd, ssdsize);
460 }
461 mutex_exit(&p->p_ldtlock);
462 if (error)
463 goto done;
464 #endif /* defined(__i386_COMPAT) */
465
466 nlwp = p->p_lwpcnt;
467 nzomb = p->p_zombcnt;
468 /* for each entry in the lwp directory ... */
469 for (ldp = p->p_lwpdir; nlwp + nzomb != 0; ldp++) {
470 prlwpname_t name = { 0, };
471
472 if ((lep = ldp->ld_entry) == NULL) /* empty slot */
473 continue;
474
475 if ((t = lep->le_thread) != NULL) { /* active lwp */
476 ASSERT(nlwp != 0);
477 nlwp--;
478 lwp = ttolwp(t);
479 mutex_enter(&p->p_lock);
480 prgetlwpsinfo(t, &bigwad->lwpsinfo);
481 if (t->t_name != NULL) {
482 (void) strlcpy(name.pr_lwpname, t->t_name,
483 sizeof (name.pr_lwpname));
484 }
485 mutex_exit(&p->p_lock);
486 } else { /* zombie lwp */
487 ASSERT(nzomb != 0);
488 nzomb--;
489 bzero(&bigwad->lwpsinfo, sizeof (bigwad->lwpsinfo));
490 bigwad->lwpsinfo.pr_lwpid = lep->le_lwpid;
491 bigwad->lwpsinfo.pr_state = SZOMB;
492 bigwad->lwpsinfo.pr_sname = 'Z';
493 bigwad->lwpsinfo.pr_start.tv_sec = lep->le_start;
494 }
495
496 name.pr_lwpid = bigwad->lwpsinfo.pr_lwpid;
497
498 error = elfnote(vp, &offset, NT_LWPSINFO,
499 sizeof (bigwad->lwpsinfo), (caddr_t)&bigwad->lwpsinfo,
500 rlimit, credp);
501 if (error)
502 goto done;
503
504 if (t == NULL) /* nothing more to do for a zombie */
505 continue;
506
507 mutex_enter(&p->p_lock);
508 if (t == curthread) {
509 /*
510 * Modify t_whystop and lwp_cursig so it appears that
511 * the current LWP is stopped after faulting on the
512 * signal that caused the core dump. As a result,
513 * prgetlwpstatus() will record that signal, the saved
514 * lwp_siginfo, and its signal handler in the core file
515 * status. We restore lwp_cursig in case a subsequent
516 * signal was received while dumping core.
517 */
518 oldsig = lwp->lwp_cursig;
519 lwp->lwp_cursig = (uchar_t)sig;
520 t->t_whystop = PR_FAULTED;
521
522 prgetlwpstatus(t, &bigwad->lwpstatus, p->p_zone);
523 bigwad->lwpstatus.pr_why = 0;
524
525 t->t_whystop = 0;
526 lwp->lwp_cursig = oldsig;
527 } else {
528 prgetlwpstatus(t, &bigwad->lwpstatus, p->p_zone);
529 }
530 mutex_exit(&p->p_lock);
531 error = elfnote(vp, &offset, NT_LWPSTATUS,
532 sizeof (bigwad->lwpstatus), (caddr_t)&bigwad->lwpstatus,
533 rlimit, credp);
534 if (error)
535 goto done;
536
537 if ((error = elfnote(vp, &offset, NT_LWPNAME, sizeof (name),
538 (caddr_t)&name, rlimit, credp)) != 0)
539 goto done;
540
541
542 #if defined(__sparc)
543 /*
544 * Unspilled SPARC register windows.
545 */
546 {
547 size_t size = prnwindows(lwp);
548
549 if (size != 0) {
550 size = sizeof (gwindows_t) -
551 (SPARC_MAXREGWINDOW - size) *
552 sizeof (struct rwindow);
553 prgetwindows(lwp, &bigwad->gwindows);
554 error = elfnote(vp, &offset, NT_GWINDOWS,
555 size, (caddr_t)&bigwad->gwindows,
556 rlimit, credp);
557 if (error)
558 goto done;
559 }
560 }
561 /*
562 * Ancillary State Registers.
563 */
564 if (p->p_model == DATAMODEL_LP64) {
565 prgetasregs(lwp, bigwad->asrset);
566 error = elfnote(vp, &offset, NT_ASRS,
567 sizeof (asrset_t), (caddr_t)bigwad->asrset,
568 rlimit, credp);
569 if (error)
570 goto done;
571 }
572 #endif /* __sparc */
573
574 if (xregsize) {
575 prgetprxregs(lwp, (prxregset_t *)bigwad->xregs);
576 error = elfnote(vp, &offset, NT_PRXREG,
577 xregsize, bigwad->xregs, rlimit, credp);
578 if (error)
579 goto done;
580 }
581
582 if (t->t_lwp->lwp_spymaster != NULL) {
583 void *psaddr = t->t_lwp->lwp_spymaster;
584 #ifdef _ELF32_COMPAT
585 /*
586 * On a 64-bit kernel with 32-bit ELF compatibility,
587 * this file is compiled into two different objects:
588 * one is compiled normally, and the other is compiled
589 * with _ELF32_COMPAT set -- and therefore with a
590 * psinfo_t defined to be a psinfo32_t. However, the
591 * psinfo_t denoting our spymaster is always of the
592 * native type; if we are in the _ELF32_COMPAT case,
593 * we need to explicitly convert it.
594 */
595 if (p->p_model == DATAMODEL_ILP32) {
596 psinfo_kto32(psaddr, &bigwad->psinfo);
597 psaddr = &bigwad->psinfo;
598 }
599 #endif
600
601 error = elfnote(vp, &offset, NT_SPYMASTER,
602 sizeof (psinfo_t), psaddr, rlimit, credp);
603 if (error)
604 goto done;
605 }
606 }
607 ASSERT(nlwp == 0);
608
609 /*
610 * If a upanic occurred, add a note for it.
611 */
612 mutex_enter(&p->p_lock);
613 if ((p->p_upanicflag & P_UPF_PANICKED) != 0) {
614 bzero(&bigwad->upanic, sizeof (prupanic_t));
615 bigwad->upanic.pru_version = PRUPANIC_VERSION_1;
616 if ((p->p_upanicflag & P_UPF_INVALMSG) != 0) {
617 bigwad->upanic.pru_flags |= PRUPANIC_FLAG_MSG_ERROR;
618 }
619
620 if ((p->p_upanicflag & P_UPF_TRUNCMSG) != 0) {
621 bigwad->upanic.pru_flags |= PRUPANIC_FLAG_MSG_TRUNC;
622 }
623
624 if ((p->p_upanicflag & P_UPF_HAVEMSG) != 0) {
625 bigwad->upanic.pru_flags |= PRUPANIC_FLAG_MSG_VALID;
626 bcopy(p->p_upanic, bigwad->upanic.pru_data,
627 PRUPANIC_BUFLEN);
628 }
629
630 mutex_exit(&p->p_lock);
631 error = elfnote(vp, &offset, NT_UPANIC, sizeof (prupanic_t),
632 &bigwad->upanic, rlimit, credp);
633 if (error != 0) {
634 goto done;
635 }
636 } else {
637 mutex_exit(&p->p_lock);
638 }
639
640 done:
641 kmem_free(bigwad, bigsize);
642 return (error);
643 }