1 /* $NetBSD: netbsd32_signal.c,v 1.55 2024/11/22 10:41:50 mlelstv Exp $ */ 2 3 /* 4 * Copyright (c) 1998, 2001 Matthew R. Green 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #include <sys/cdefs.h> 30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_signal.c,v 1.55 2024/11/22 10:41:50 mlelstv Exp $"); 31 32 #if defined(_KERNEL_OPT) 33 #include "opt_ktrace.h" 34 #endif 35 36 #include <sys/param.h> 37 #include <sys/systm.h> 38 #include <sys/mount.h> 39 #include <sys/stat.h> 40 #include <sys/time.h> 41 #include <sys/signalvar.h> 42 #include <sys/ktrace.h> 43 #include <sys/proc.h> 44 #include <sys/wait.h> 45 #include <sys/dirent.h> 46 #include <sys/module.h> 47 #include <sys/exec.h> 48 49 #include <uvm/uvm_extern.h> 50 51 #include <compat/netbsd32/netbsd32.h> 52 #include <compat/netbsd32/netbsd32_conv.h> 53 #include <compat/netbsd32/netbsd32_exec.h> 54 #include <compat/netbsd32/netbsd32_syscallargs.h> 55 56 #include <compat/sys/signal.h> 57 #include <compat/sys/signalvar.h> 58 #include <compat/sys/siginfo.h> 59 #include <compat/sys/ucontext.h> 60 #include <compat/common/compat_sigaltstack.h> 61 62 int 63 netbsd32_sigaction(struct lwp *l, const struct netbsd32_sigaction_args *uap, register_t *retval) 64 { 65 /* { 66 syscallarg(int) signum; 67 syscallarg(const netbsd32_sigactionp_t) nsa; 68 syscallarg(netbsd32_sigactionp_t) osa; 69 } */ 70 struct sigaction nsa, osa; 71 struct netbsd32_sigaction13 *sa32p, sa32; 72 int error; 73 74 if (SCARG_P32(uap, nsa)) { 75 sa32p = SCARG_P32(uap, nsa); 76 if (copyin(sa32p, &sa32, sizeof(sa32))) 77 return EFAULT; 78 nsa.sa_handler = (void *)NETBSD32PTR64(sa32.netbsd32_sa_handler); 79 memset(&nsa.sa_mask, 0, sizeof(nsa.sa_mask)); 80 nsa.sa_mask.__bits[0] = sa32.netbsd32_sa_mask; 81 nsa.sa_flags = sa32.netbsd32_sa_flags; 82 } 83 error = sigaction1(l, SCARG(uap, signum), 84 SCARG_P32(uap, nsa) ? &nsa : 0, 85 SCARG_P32(uap, osa) ? &osa : 0, 86 NULL, 0); 87 88 if (error) 89 return error; 90 91 if (SCARG_P32(uap, osa)) { 92 memset(&sa32, 0, sizeof(sa32)); 93 NETBSD32PTR32(sa32.netbsd32_sa_handler, osa.sa_handler); 94 sa32.netbsd32_sa_mask = osa.sa_mask.__bits[0]; 95 sa32.netbsd32_sa_flags = osa.sa_flags; 96 sa32p = SCARG_P32(uap, osa); 97 if (copyout(&sa32, sa32p, sizeof(sa32))) 98 return EFAULT; 99 } 100 101 return 0; 102 } 103 104 int 105 netbsd32___sigaltstack14(struct lwp *l, const struct netbsd32___sigaltstack14_args *uap, register_t *retval) 106 { 107 /* { 108 syscallarg(const netbsd32_sigaltstackp_t) nss; 109 syscallarg(netbsd32_sigaltstackp_t) oss; 110 } */ 111 compat_sigaltstack(uap, netbsd32_sigaltstack, SS_ONSTACK, SS_DISABLE); 112 } 113 114 /* ARGSUSED */ 115 int 116 netbsd32___sigaction14(struct lwp *l, const struct netbsd32___sigaction14_args *uap, register_t *retval) 117 { 118 /* { 119 syscallarg(int) signum; 120 syscallarg(const struct sigaction *) nsa; 121 syscallarg(struct sigaction *) osa; 122 } */ 123 struct netbsd32_sigaction sa32; 124 struct sigaction nsa, osa; 125 int error; 126 127 if (SCARG_P32(uap, nsa)) { 128 error = copyin(SCARG_P32(uap, nsa), &sa32, sizeof(sa32)); 129 if (error) 130 return error; 131 nsa.sa_handler = NETBSD32PTR64(sa32.netbsd32_sa_handler); 132 nsa.sa_mask = sa32.netbsd32_sa_mask; 133 nsa.sa_flags = sa32.netbsd32_sa_flags; 134 } 135 error = sigaction1(l, SCARG(uap, signum), 136 SCARG_P32(uap, nsa) ? &nsa : 0, 137 SCARG_P32(uap, osa) ? &osa : 0, 138 NULL, 0); 139 if (error) 140 return error; 141 if (SCARG_P32(uap, osa)) { 142 memset(&sa32, 0, sizeof(sa32)); 143 NETBSD32PTR32(sa32.netbsd32_sa_handler, osa.sa_handler); 144 sa32.netbsd32_sa_mask = osa.sa_mask; 145 sa32.netbsd32_sa_flags = osa.sa_flags; 146 error = copyout(&sa32, SCARG_P32(uap, osa), sizeof(sa32)); 147 if (error) 148 return error; 149 } 150 return 0; 151 } 152 153 /* ARGSUSED */ 154 int 155 netbsd32___sigaction_sigtramp(struct lwp *l, const struct netbsd32___sigaction_sigtramp_args *uap, register_t *retval) 156 { 157 /* { 158 syscallarg(int) signum; 159 syscallarg(const netbsd32_sigactionp_t) nsa; 160 syscallarg(netbsd32_sigactionp_t) osa; 161 syscallarg(netbsd32_voidp) tramp; 162 syscallarg(int) vers; 163 } */ 164 struct netbsd32_sigaction sa32; 165 struct sigaction nsa, osa; 166 int error, vers; 167 168 if (SCARG_P32(uap, nsa)) { 169 error = copyin(SCARG_P32(uap, nsa), &sa32, sizeof(sa32)); 170 if (error) 171 return error; 172 nsa.sa_handler = NETBSD32PTR64(sa32.netbsd32_sa_handler); 173 nsa.sa_mask = sa32.netbsd32_sa_mask; 174 nsa.sa_flags = sa32.netbsd32_sa_flags; 175 } 176 vers = SCARG(uap, vers); 177 #ifndef __HAVE_MD_NETBSD32_SENDSIG /* XXX paying for yesterday's sins */ 178 if (vers < __SIGTRAMP_SIGINFO_VERSION_MIN) { 179 /* 180 * sigaction1() doesn't enforce sigcontext-ness for 181 * __SIGTRAMP_SIGCODE_VERSION because it might be 182 * a foreign emulation. However, we know these are 183 * native NetBSD 32-bit binaries, so we do. 184 */ 185 #ifdef __HAVE_STRUCT_SIGCONTEXT 186 struct proc *p = l->l_proc; 187 bool sigcontext_valid; 188 189 /* 190 * We need to ensure the compat_netbsd32_16 module 191 * is loaded, because sigaction1() gives a free pass 192 * to processes marked PK_32 (it can't be sure which 193 * 32-bit compat module is needed). 194 */ 195 if ((p->p_lflag & PL_SIGCOMPAT) == 0) { 196 kernconfig_lock(); 197 (void)module_autoload("compat_netbsd32_16", 198 MODULE_CLASS_ANY); 199 sigcontext_valid = netbsd32_sendsig_sigcontext_16_hook.hooked; 200 mutex_enter(&proc_lock); 201 /* 202 * Prevent unload of compat module while 203 * this process remains. 204 */ 205 p->p_lflag |= PL_SIGCOMPAT; 206 mutex_exit(&proc_lock); 207 kernconfig_unlock(); 208 } else { 209 /* 210 * Module is already loaded and locked in memory 211 */ 212 sigcontext_valid = netbsd32_sendsig_sigcontext_16_hook.hooked; 213 } 214 if (!sigcontext_valid) { 215 return EINVAL; 216 } 217 // #else /* ! __HAVE_STRUCT_SIGCONTEXT */ 218 // return EINVAL; 219 #endif /* __HAVE_STRUCT_SIGCONTEXT */ 220 } 221 #endif /* __HAVE_MD_NETBSD32_SENDSIG */ 222 error = sigaction1(l, SCARG(uap, signum), 223 SCARG_P32(uap, nsa) ? &nsa : 0, 224 SCARG_P32(uap, osa) ? &osa : 0, 225 SCARG_P32(uap, tramp), vers); 226 if (error) 227 return error; 228 if (SCARG_P32(uap, osa)) { 229 memset(&sa32, 0, sizeof(sa32)); 230 NETBSD32PTR32(sa32.netbsd32_sa_handler, osa.sa_handler); 231 sa32.netbsd32_sa_mask = osa.sa_mask; 232 sa32.netbsd32_sa_flags = osa.sa_flags; 233 error = copyout(&sa32, SCARG_P32(uap, osa), sizeof(sa32)); 234 if (error) 235 return error; 236 } 237 return 0; 238 } 239 240 #ifndef __HAVE_MD_NETBSD32_SENDSIG /* XXX paying for yesterday's sins */ 241 #ifdef __HAVE_STRUCT_SIGCONTEXT 242 struct netbsd32_sendsig_sigcontext_16_hook_t netbsd32_sendsig_sigcontext_16_hook; 243 #endif 244 245 void 246 netbsd32_sendsig(const struct ksiginfo *ksi, const sigset_t *mask) 247 { 248 struct sigacts *sa; 249 int sig; 250 251 sig = ksi->ksi_signo; 252 sa = curproc->p_sigacts; 253 254 switch (sa->sa_sigdesc[sig].sd_vers) { 255 #ifdef __HAVE_STRUCT_SIGCONTEXT 256 case __SIGTRAMP_SIGCODE_VERSION: 257 case __SIGTRAMP_SIGCONTEXT_VERSION_MIN ... 258 __SIGTRAMP_SIGCONTEXT_VERSION_MAX: 259 /* Compat for 1.6 and earlier. */ 260 MODULE_HOOK_CALL_VOID(netbsd32_sendsig_sigcontext_16_hook, 261 (ksi, mask), break); 262 return; 263 #endif /* __HAVE_STRUCT_SIGCONTEXT */ 264 case __SIGTRAMP_SIGINFO_VERSION_MIN ... 265 __SIGTRAMP_SIGINFO_VERSION_MAX: 266 netbsd32_sendsig_siginfo(ksi, mask); 267 return; 268 default: 269 break; 270 } 271 272 printf("%s: bad version %d\n", __func__, sa->sa_sigdesc[sig].sd_vers); 273 sigexit(curlwp, SIGILL); 274 } 275 #endif /* __HAVE_MD_NETBSD32_SENDSIG */ 276 277 void 278 netbsd32_ksi32_to_ksi(struct _ksiginfo *si, const struct __ksiginfo32 *si32) 279 { 280 size_t i; 281 282 memset(si, 0, sizeof (*si)); 283 si->_signo = si32->_signo; 284 si->_code = si32->_code; 285 si->_errno = si32->_errno; 286 287 if (si32->_code == SI_NOINFO) 288 return; 289 else if (si32->_code <= 0) /* codes described in siginfo(2) */ 290 goto fill_rt; 291 292 switch (si32->_signo) { 293 case SIGILL: 294 case SIGFPE: 295 case SIGBUS: 296 case SIGSEGV: 297 fill_fault: 298 si->_reason._fault._addr = 299 NETBSD32IPTR64(si32->_reason._fault._addr); 300 si->_reason._fault._trap = si32->_reason._fault._trap; 301 break; 302 case SIGTRAP: 303 switch (si32->_code) { 304 case TRAP_EXEC: 305 break; 306 case TRAP_CHLD: 307 case TRAP_LWP: 308 si->_reason._ptrace_state._pe_report_event = 309 si32->_reason._ptrace_state._pe_report_event; 310 CTASSERT(sizeof(si->_reason._ptrace_state._option._pe_other_pid) == 311 sizeof(si->_reason._ptrace_state._option._pe_lwp)); 312 si->_reason._ptrace_state._option._pe_other_pid = 313 si32->_reason._ptrace_state._option._pe_other_pid; 314 break; 315 case TRAP_SCE: 316 case TRAP_SCX: 317 si->_reason._syscall._sysnum = 318 si32->_reason._syscall._sysnum; 319 si->_reason._syscall._retval[0] = 320 si32->_reason._syscall._retval[0]; 321 si->_reason._syscall._retval[1] = 322 si32->_reason._syscall._retval[1]; 323 si->_reason._syscall._error = 324 si32->_reason._syscall._error; 325 for (i = 0; 326 i < __arraycount(si->_reason._syscall._args); i++) 327 si->_reason._syscall._args[i] = 328 si32->_reason._syscall._args[i]; 329 break; 330 default: 331 goto fill_fault; 332 } 333 break; 334 case SIGALRM: 335 case SIGVTALRM: 336 case SIGPROF: 337 default: /* see sigqueue() and kill1() */ 338 fill_rt: 339 si->_reason._rt._pid = si32->_reason._rt._pid; 340 si->_reason._rt._uid = si32->_reason._rt._uid; 341 si->_reason._rt._value.sival_int = 342 si32->_reason._rt._value.sival_int; 343 break; 344 case SIGURG: 345 case SIGIO: 346 si->_reason._poll._band = si32->_reason._poll._band; 347 si->_reason._poll._fd = si32->_reason._poll._fd; 348 break; 349 case SIGCHLD: 350 si->_reason._child._pid = si32->_reason._child._pid; 351 si->_reason._child._uid = si32->_reason._child._uid; 352 si->_reason._child._status = si32->_reason._child._status; 353 si->_reason._child._utime = si32->_reason._child._utime; 354 si->_reason._child._stime = si32->_reason._child._stime; 355 break; 356 } 357 } 358 359 void 360 netbsd32_si32_to_si(siginfo_t *si, const siginfo32_t *si32) 361 { 362 363 memset(si, 0, sizeof (*si)); 364 netbsd32_ksi32_to_ksi(&si->_info, &si32->_info); 365 } 366 367 static void 368 netbsd32_ksi_to_ksi32(struct __ksiginfo32 *si32, const struct _ksiginfo *si) 369 { 370 size_t i; 371 372 memset(si32, 0, sizeof (*si32)); 373 si32->_signo = si->_signo; 374 si32->_code = si->_code; 375 si32->_errno = si->_errno; 376 377 if (si->_code == SI_NOINFO) 378 return; 379 else if (si->_code <= 0) /* codes described in siginfo(2) */ 380 goto fill_rt; 381 382 switch (si->_signo) { 383 case SIGILL: 384 case SIGFPE: 385 case SIGBUS: 386 case SIGSEGV: 387 fill_fault: 388 si32->_reason._fault._addr = 389 NETBSD32PTR32I(si->_reason._fault._addr); 390 si32->_reason._fault._trap = si->_reason._fault._trap; 391 break; 392 case SIGTRAP: 393 switch (si->_code) { 394 case TRAP_EXEC: 395 break; 396 case TRAP_CHLD: 397 case TRAP_LWP: 398 si32->_reason._ptrace_state._pe_report_event = 399 si->_reason._ptrace_state._pe_report_event; 400 CTASSERT(sizeof(si32->_reason._ptrace_state._option._pe_other_pid) == 401 sizeof(si32->_reason._ptrace_state._option._pe_lwp)); 402 si32->_reason._ptrace_state._option._pe_other_pid = 403 si->_reason._ptrace_state._option._pe_other_pid; 404 break; 405 case TRAP_SCE: 406 case TRAP_SCX: 407 si32->_reason._syscall._sysnum = 408 si->_reason._syscall._sysnum; 409 si32->_reason._syscall._retval[0] = 410 si->_reason._syscall._retval[0]; 411 si32->_reason._syscall._retval[1] = 412 si->_reason._syscall._retval[1]; 413 si32->_reason._syscall._error = 414 si->_reason._syscall._error; 415 for (i = 0; 416 i < __arraycount(si->_reason._syscall._args); i++) 417 si32->_reason._syscall._args[i] = 418 si->_reason._syscall._args[i]; 419 break; 420 default: 421 goto fill_fault; 422 } 423 break; 424 case SIGALRM: 425 case SIGVTALRM: 426 case SIGPROF: 427 default: /* see sigqueue() and kill1() */ 428 fill_rt: 429 si32->_reason._rt._pid = si->_reason._rt._pid; 430 si32->_reason._rt._uid = si->_reason._rt._uid; 431 si32->_reason._rt._value.sival_int = 432 si->_reason._rt._value.sival_int; 433 break; 434 case SIGURG: 435 case SIGIO: 436 si32->_reason._poll._band = si->_reason._poll._band; 437 si32->_reason._poll._fd = si->_reason._poll._fd; 438 break; 439 case SIGCHLD: 440 si32->_reason._child._pid = si->_reason._child._pid; 441 si32->_reason._child._uid = si->_reason._child._uid; 442 si32->_reason._child._status = si->_reason._child._status; 443 si32->_reason._child._utime = si->_reason._child._utime; 444 si32->_reason._child._stime = si->_reason._child._stime; 445 break; 446 } 447 } 448 449 void 450 netbsd32_si_to_si32(siginfo32_t *si32, const siginfo_t *si) 451 { 452 453 memset(si32, 0, sizeof (*si32)); 454 netbsd32_ksi_to_ksi32(&si32->_info, &si->_info); 455 } 456 457 void 458 getucontext32(struct lwp *l, ucontext32_t *ucp) 459 { 460 struct proc *p = l->l_proc; 461 462 KASSERT(mutex_owned(p->p_lock)); 463 464 ucp->uc_flags = 0; 465 ucp->uc_link = (uint32_t)(intptr_t)l->l_ctxlink; 466 ucp->uc_sigmask = l->l_sigmask; 467 ucp->uc_flags |= _UC_SIGMASK; 468 469 /* 470 * The (unsupplied) definition of the `current execution stack' 471 * in the System V Interface Definition appears to allow returning 472 * the main context stack. 473 */ 474 if ((l->l_sigstk.ss_flags & SS_ONSTACK) == 0) { 475 ucp->uc_stack.ss_sp = USRSTACK32; 476 ucp->uc_stack.ss_size = ctob(p->p_vmspace->vm_ssize); 477 ucp->uc_stack.ss_flags = 0; /* XXX, def. is Very Fishy */ 478 } else { 479 /* Simply copy alternate signal execution stack. */ 480 ucp->uc_stack.ss_sp = 481 (uint32_t)(intptr_t)l->l_sigstk.ss_sp; 482 ucp->uc_stack.ss_size = l->l_sigstk.ss_size; 483 ucp->uc_stack.ss_flags = l->l_sigstk.ss_flags; 484 } 485 ucp->uc_flags |= _UC_STACK; 486 mutex_exit(p->p_lock); 487 cpu_getmcontext32(l, &ucp->uc_mcontext, &ucp->uc_flags); 488 mutex_enter(p->p_lock); 489 } 490 491 int 492 netbsd32_getcontext(struct lwp *l, const struct netbsd32_getcontext_args *uap, register_t *retval) 493 { 494 /* { 495 syscallarg(netbsd32_ucontextp) ucp; 496 } */ 497 struct proc *p = l->l_proc; 498 ucontext32_t uc; 499 500 memset(&uc, 0, sizeof(uc)); 501 502 mutex_enter(p->p_lock); 503 getucontext32(l, &uc); 504 mutex_exit(p->p_lock); 505 506 return copyout(&uc, SCARG_P32(uap, ucp), sizeof (ucontext32_t)); 507 } 508 509 int 510 setucontext32(struct lwp *l, const ucontext32_t *ucp) 511 { 512 struct proc *p = l->l_proc; 513 int error; 514 515 KASSERT(mutex_owned(p->p_lock)); 516 517 if ((ucp->uc_flags & _UC_SIGMASK) != 0) { 518 error = sigprocmask1(l, SIG_SETMASK, &ucp->uc_sigmask, NULL); 519 if (error != 0) 520 return error; 521 } 522 523 mutex_exit(p->p_lock); 524 error = cpu_setmcontext32(l, &ucp->uc_mcontext, ucp->uc_flags); 525 mutex_enter(p->p_lock); 526 if (error != 0) 527 return error; 528 529 l->l_ctxlink = (void *)(intptr_t)ucp->uc_link; 530 531 /* 532 * If there was stack information, update whether or not we are 533 * still running on an alternate signal stack. 534 */ 535 if ((ucp->uc_flags & _UC_STACK) != 0) { 536 if (ucp->uc_stack.ss_flags & SS_ONSTACK) 537 l->l_sigstk.ss_flags |= SS_ONSTACK; 538 else 539 l->l_sigstk.ss_flags &= ~SS_ONSTACK; 540 } 541 542 return 0; 543 } 544 545 /* ARGSUSED */ 546 int 547 netbsd32_setcontext(struct lwp *l, const struct netbsd32_setcontext_args *uap, register_t *retval) 548 { 549 /* { 550 syscallarg(netbsd32_ucontextp) ucp; 551 } */ 552 ucontext32_t uc; 553 int error; 554 struct proc *p = l->l_proc; 555 556 error = copyin(SCARG_P32(uap, ucp), &uc, sizeof (uc)); 557 if (error) 558 return error; 559 if (!(uc.uc_flags & _UC_CPU)) 560 return EINVAL; 561 mutex_enter(p->p_lock); 562 error = setucontext32(l, &uc); 563 mutex_exit(p->p_lock); 564 if (error) 565 return error; 566 567 return EJUSTRETURN; 568 } 569 570 static int 571 netbsd32_sigtimedwait_put_info(const void *src, void *dst, size_t size) 572 { 573 const siginfo_t *info = src; 574 siginfo32_t info32; 575 576 netbsd32_si_to_si32(&info32, info); 577 578 return copyout(&info32, dst, sizeof(info32)); 579 } 580 581 static int 582 netbsd32_sigtimedwait_fetch_timeout(const void *src, void *dst, size_t size) 583 { 584 struct timespec *ts = dst; 585 struct netbsd32_timespec ts32; 586 int error; 587 588 error = copyin(src, &ts32, sizeof(ts32)); 589 if (error) 590 return error; 591 592 netbsd32_to_timespec(&ts32, ts); 593 return 0; 594 } 595 596 static int 597 netbsd32_sigtimedwait_put_timeout(const void *src, void *dst, size_t size) 598 { 599 const struct timespec *ts = src; 600 struct netbsd32_timespec ts32; 601 602 netbsd32_from_timespec(ts, &ts32); 603 604 return copyout(&ts32, dst, sizeof(ts32)); 605 } 606 607 int 608 netbsd32_____sigtimedwait50(struct lwp *l, const struct netbsd32_____sigtimedwait50_args *uap, register_t *retval) 609 { 610 /* { 611 syscallarg(netbsd32_sigsetp_t) set; 612 syscallarg(netbsd32_siginfop_t) info; 613 syscallarg(netbsd32_timespec50p_t) timeout; 614 } */ 615 struct sys_____sigtimedwait50_args ua; 616 617 NETBSD32TOP_UAP(set, const sigset_t); 618 NETBSD32TOP_UAP(info, siginfo_t); 619 NETBSD32TOP_UAP(timeout, struct timespec); 620 621 return sigtimedwait1(l, &ua, retval, 622 copyin, 623 netbsd32_sigtimedwait_put_info, 624 netbsd32_sigtimedwait_fetch_timeout, 625 netbsd32_sigtimedwait_put_timeout); 626 } 627 628 int 629 netbsd32_sigqueueinfo(struct lwp *l, 630 const struct netbsd32_sigqueueinfo_args *uap, register_t *retval) 631 { 632 /* { 633 syscallarg(pid_t) pid; 634 syscallarg(const netbsd32_siginfop_t) info; 635 } */ 636 struct __ksiginfo32 ksi32; 637 ksiginfo_t ksi; 638 int error; 639 640 if ((error = copyin(SCARG_P32(uap, info), &ksi32, 641 sizeof(ksi32))) != 0) 642 return error; 643 644 KSI_INIT(&ksi); 645 netbsd32_ksi32_to_ksi(&ksi.ksi_info, &ksi32); 646 647 return kill1(l, SCARG(uap, pid), &ksi, retval); 648 } 649 650 struct netbsd32_ktr_psig { 651 int signo; 652 netbsd32_pointer_t action; 653 sigset_t mask; 654 int code; 655 /* and optional siginfo_t */ 656 }; 657 658 #ifdef notyet 659 #ifdef KTRACE 660 void 661 netbsd32_ktrpsig(int sig, sig_t action, const sigset_t *mask, 662 const ksiginfo_t *ksi) 663 { 664 struct ktrace_entry *kte; 665 lwp_t *l = curlwp; 666 struct { 667 struct netbsd32_ktr_psig kp; 668 siginfo32_t si; 669 } *kbuf; 670 671 if (!KTRPOINT(l->l_proc, KTR_PSIG)) 672 return; 673 674 if (ktealloc(&kte, (void *)&kbuf, l, KTR_PSIG, sizeof(*kbuf))) 675 return; 676 677 kbuf->kp.signo = (char)sig; 678 NETBSD32PTR32(kbuf->kp.action, action); 679 kbuf->kp.mask = *mask; 680 681 if (ksi) { 682 kbuf->kp.code = KSI_TRAPCODE(ksi); 683 (void)memset(&kbuf->si, 0, sizeof(kbuf->si)); 684 netbsd32_ksi_to_ksi32(&kbuf->si._info, &ksi->ksi_info); 685 ktesethdrlen(kte, sizeof(*kbuf)); 686 } else { 687 kbuf->kp.code = 0; 688 ktesethdrlen(kte, sizeof(struct netbsd32_ktr_psig)); 689 } 690 691 ktraddentry(l, kte, KTA_WAITOK); 692 } 693 #endif 694 #endif 695