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