2007-12-21 02:02:38 +03:00
|
|
|
/* $NetBSD: kern_sig_13.c,v 1.17 2007/12/20 23:02:44 dsl Exp $ */
|
1997-11-25 22:32:15 +03:00
|
|
|
|
|
|
|
/*-
|
1998-09-11 16:50:05 +04:00
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
1997-11-25 22:32:15 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
1998-09-11 16:50:05 +04:00
|
|
|
* by Charles M. Hannum.
|
1997-11-25 22:32:15 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 05:07:52 +03:00
|
|
|
#include <sys/cdefs.h>
|
2007-12-21 02:02:38 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: kern_sig_13.c,v 1.17 2007/12/20 23:02:44 dsl Exp $");
|
2001-11-13 05:07:52 +03:00
|
|
|
|
1997-11-25 22:32:15 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/signal.h>
|
1998-09-11 16:50:05 +04:00
|
|
|
#include <sys/signalvar.h>
|
1997-11-25 22:32:15 +03:00
|
|
|
#include <sys/systm.h>
|
|
|
|
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/syscallargs.h>
|
|
|
|
|
1997-11-29 21:38:20 +03:00
|
|
|
#include <machine/limits.h>
|
|
|
|
|
2005-09-13 05:42:32 +04:00
|
|
|
#include <compat/sys/signal.h>
|
|
|
|
#include <compat/sys/signalvar.h>
|
1997-11-25 22:32:15 +03:00
|
|
|
#include <compat/common/compat_util.h>
|
2007-06-17 00:04:27 +04:00
|
|
|
#include <compat/common/compat_sigaltstack.h>
|
1997-11-25 22:32:15 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
void
|
2007-12-08 21:35:53 +03:00
|
|
|
native_sigset13_to_sigset(const sigset13_t *oss, sigset_t *ss)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
ss->__bits[0] = *oss;
|
|
|
|
ss->__bits[1] = 0;
|
|
|
|
ss->__bits[2] = 0;
|
|
|
|
ss->__bits[3] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-12-08 21:35:53 +03:00
|
|
|
native_sigset_to_sigset13(const sigset_t *ss, sigset13_t *oss)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
*oss = ss->__bits[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-12-08 21:35:53 +03:00
|
|
|
native_sigaction13_to_sigaction(const struct sigaction13 *osa, struct sigaction *sa)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
|
|
|
|
2002-11-26 21:43:20 +03:00
|
|
|
sa->sa_handler = osa->osa_handler;
|
|
|
|
native_sigset13_to_sigset(&osa->osa_mask, &sa->sa_mask);
|
|
|
|
sa->sa_flags = osa->osa_flags;
|
1998-09-11 16:50:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-12-08 21:35:53 +03:00
|
|
|
native_sigaction_to_sigaction13(const struct sigaction *sa, struct sigaction13 *osa)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
|
|
|
|
2002-11-26 21:43:20 +03:00
|
|
|
osa->osa_handler = sa->sa_handler;
|
|
|
|
native_sigset_to_sigset13(&sa->sa_mask, &osa->osa_mask);
|
|
|
|
osa->osa_flags = sa->sa_flags;
|
1998-09-11 16:50:05 +04:00
|
|
|
}
|
|
|
|
|
1997-11-25 22:32:15 +03:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_13_sys_sigaltstack(struct lwp *l, const struct compat_13_sys_sigaltstack_args *uap, register_t *retval)
|
1997-11-25 22:32:15 +03:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1997-11-25 22:32:15 +03:00
|
|
|
syscallarg(const struct sigaltstack13 *) nss;
|
|
|
|
syscallarg(struct sigaltstack13 *) oss;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2007-06-17 00:04:27 +04:00
|
|
|
compat_sigaltstack(uap, sigaltstack13, SS_ONSTACK, SS_DISABLE);
|
1998-09-11 16:50:05 +04:00
|
|
|
}
|
1997-11-25 22:32:15 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_13_sys_sigaction(struct lwp *l, const struct compat_13_sys_sigaction_args *uap, register_t *retval)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(int) signum;
|
|
|
|
syscallarg(const struct sigaction13 *) nsa;
|
|
|
|
syscallarg(struct sigaction13 *) osa;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-09-11 16:50:05 +04:00
|
|
|
struct sigaction13 nesa, oesa;
|
|
|
|
struct sigaction nbsa, obsa;
|
|
|
|
int error;
|
1997-11-25 22:32:15 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
if (SCARG(uap, nsa)) {
|
|
|
|
error = copyin(SCARG(uap, nsa), &nesa, sizeof(nesa));
|
|
|
|
if (error)
|
1997-11-25 22:32:15 +03:00
|
|
|
return (error);
|
1998-09-11 16:50:05 +04:00
|
|
|
native_sigaction13_to_sigaction(&nesa, &nbsa);
|
|
|
|
}
|
2007-02-10 00:55:00 +03:00
|
|
|
error = sigaction1(l, SCARG(uap, signum),
|
2002-07-05 03:32:02 +04:00
|
|
|
SCARG(uap, nsa) ? &nbsa : 0, SCARG(uap, osa) ? &obsa : 0,
|
|
|
|
NULL, 0);
|
1998-09-11 16:50:05 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
if (SCARG(uap, osa)) {
|
|
|
|
native_sigaction_to_sigaction13(&obsa, &oesa);
|
|
|
|
error = copyout(&oesa, SCARG(uap, osa), sizeof(oesa));
|
|
|
|
if (error)
|
1997-11-25 22:32:15 +03:00
|
|
|
return (error);
|
1998-09-11 16:50:05 +04:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
1997-11-25 22:32:15 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_13_sys_sigprocmask(struct lwp *l, const struct compat_13_sys_sigprocmask_args *uap, register_t *retval)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(int) how;
|
|
|
|
syscallarg(int) mask;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
2003-01-18 10:28:34 +03:00
|
|
|
struct proc *p = l->l_proc;
|
1998-09-11 16:50:05 +04:00
|
|
|
sigset13_t ness, oess;
|
|
|
|
sigset_t nbss, obss;
|
|
|
|
int error;
|
1997-11-25 22:32:15 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
ness = SCARG(uap, mask);
|
|
|
|
native_sigset13_to_sigset(&ness, &nbss);
|
2007-02-10 00:55:00 +03:00
|
|
|
mutex_enter(&p->p_smutex);
|
|
|
|
error = sigprocmask1(l, SCARG(uap, how), &nbss, &obss);
|
|
|
|
mutex_exit(&p->p_smutex);
|
1998-09-11 16:50:05 +04:00
|
|
|
if (error)
|
1997-11-25 22:32:15 +03:00
|
|
|
return (error);
|
1998-09-11 16:50:05 +04:00
|
|
|
native_sigset_to_sigset13(&obss, &oess);
|
|
|
|
*retval = oess;
|
|
|
|
return (0);
|
|
|
|
}
|
1997-11-25 22:32:15 +03:00
|
|
|
|
1998-09-11 16:50:05 +04:00
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_13_sys_sigpending(struct lwp *l, const void *v, register_t *retval)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
|
|
|
sigset13_t ess;
|
|
|
|
sigset_t bss;
|
1997-11-25 22:32:15 +03:00
|
|
|
|
2007-02-10 00:55:00 +03:00
|
|
|
sigpending1(l, &bss);
|
1998-09-11 16:50:05 +04:00
|
|
|
native_sigset_to_sigset13(&bss, &ess);
|
|
|
|
*retval = ess;
|
1997-11-25 22:32:15 +03:00
|
|
|
return (0);
|
|
|
|
}
|
1998-09-11 16:50:05 +04:00
|
|
|
|
|
|
|
int
|
2007-12-21 02:02:38 +03:00
|
|
|
compat_13_sys_sigsuspend(struct lwp *l, const struct compat_13_sys_sigsuspend_args *uap, register_t *retval)
|
1998-09-11 16:50:05 +04:00
|
|
|
{
|
2007-12-21 02:02:38 +03:00
|
|
|
/* {
|
1998-09-11 16:50:05 +04:00
|
|
|
syscallarg(sigset13_t) mask;
|
2007-12-21 02:02:38 +03:00
|
|
|
} */
|
1998-09-11 16:50:05 +04:00
|
|
|
sigset13_t ess;
|
|
|
|
sigset_t bss;
|
|
|
|
|
|
|
|
ess = SCARG(uap, mask);
|
|
|
|
native_sigset13_to_sigset(&ess, &bss);
|
2007-02-10 00:55:00 +03:00
|
|
|
return (sigsuspend1(l, &bss));
|
1998-09-11 16:50:05 +04:00
|
|
|
}
|