summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-10-25 19:10:58 +0000
committerpeter <peter@FreeBSD.org>2002-10-25 19:10:58 +0000
commitf7fa86b743f4851065b80a704e7ee6c9922b5bda (patch)
tree96a1089f558875f808b1fd36f885179cd78f55de /sys/kern
parentc689b5c88a817d10910bb530d1a68187b58db634 (diff)
downloadFreeBSD-src-f7fa86b743f4851065b80a704e7ee6c9922b5bda.zip
FreeBSD-src-f7fa86b743f4851065b80a704e7ee6c9922b5bda.tar.gz
Split 4.x and 5.x signal handling so that we can keep 4.x signal
handling clean and functional as 5.x evolves. This allows some of the nasty bandaids in the 5.x codepaths to be unwound. Encapsulate 4.x signal handling under COMPAT_FREEBSD4 (there is an anti-foot-shooting measure in place, 5.x folks need this for a while) and finish encapsulating the older stuff under COMPAT_43. Since the ancient stuff is required on alpha (longjmp(3) passes a 'struct osigcontext *' to the current sigreturn(2), instead of the 'ucontext_t *' that sigreturn is supposed to take), add a compile time check to prevent foot shooting there too. Add uniform COMPAT_43 stubs for ia64/sparc64/powerpc. Tested on: i386, alpha, ia64. Compiled on sparc64 (a few days ago). Approved by: re
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/init_sysent.c10
-rw-r--r--sys/kern/kern_sig.c77
-rw-r--r--sys/kern/syscalls.c10
-rw-r--r--sys/kern/syscalls.master11
4 files changed, 89 insertions, 19 deletions
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index fb28d32..601920b 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -131,7 +131,7 @@ struct sysent sysent[] = {
{ SYF_MPSAFE | AS(getpriority_args), (sy_call_t *)getpriority }, /* 100 = getpriority */
{ compat(SYF_MPSAFE | AS(osend_args),send) }, /* 101 = old send */
{ compat(SYF_MPSAFE | AS(orecv_args),recv) }, /* 102 = old recv */
- { SYF_MPSAFE | AS(osigreturn_args), (sy_call_t *)osigreturn }, /* 103 = osigreturn */
+ { compat(SYF_MPSAFE | AS(osigreturn_args),sigreturn) }, /* 103 = old sigreturn */
{ SYF_MPSAFE | AS(bind_args), (sy_call_t *)bind }, /* 104 = bind */
{ SYF_MPSAFE | AS(setsockopt_args), (sy_call_t *)setsockopt }, /* 105 = setsockopt */
{ SYF_MPSAFE | AS(listen_args), (sy_call_t *)listen }, /* 106 = listen */
@@ -370,9 +370,9 @@ struct sysent sysent[] = {
{ 0, (sy_call_t *)nosys }, /* 339 = pioctl */
{ SYF_MPSAFE | AS(sigprocmask_args), (sy_call_t *)sigprocmask }, /* 340 = sigprocmask */
{ SYF_MPSAFE | AS(sigsuspend_args), (sy_call_t *)sigsuspend }, /* 341 = sigsuspend */
- { SYF_MPSAFE | AS(sigaction_args), (sy_call_t *)sigaction }, /* 342 = sigaction */
+ { compat4(SYF_MPSAFE | AS(freebsd4_sigaction_args),sigaction) }, /* 342 = old sigaction */
{ SYF_MPSAFE | AS(sigpending_args), (sy_call_t *)sigpending }, /* 343 = sigpending */
- { SYF_MPSAFE | AS(sigreturn_args), (sy_call_t *)sigreturn }, /* 344 = sigreturn */
+ { compat4(SYF_MPSAFE | AS(freebsd4_sigreturn_args),sigreturn) }, /* 344 = old sigreturn */
{ 0, (sy_call_t *)nosys }, /* 345 = sigtimedwait */
{ 0, (sy_call_t *)nosys }, /* 346 = sigwaitinfo */
{ SYF_MPSAFE | AS(__acl_get_file_args), (sy_call_t *)__acl_get_file }, /* 347 = __acl_get_file */
@@ -444,8 +444,8 @@ struct sysent sysent[] = {
{ AS(extattr_get_link_args), (sy_call_t *)extattr_get_link }, /* 413 = extattr_get_link */
{ AS(extattr_delete_link_args), (sy_call_t *)extattr_delete_link }, /* 414 = extattr_delete_link */
{ 0, (sy_call_t *)nosys }, /* 415 = __execve_mac */
- { 0, (sy_call_t *)nosys }, /* 416 = newsigreturn */
- { 0, (sy_call_t *)nosys }, /* 417 = newsigaction */
+ { SYF_MPSAFE | AS(sigaction_args), (sy_call_t *)sigaction }, /* 416 = sigaction */
+ { SYF_MPSAFE | AS(sigreturn_args), (sy_call_t *)sigreturn }, /* 417 = sigreturn */
{ 0, (sy_call_t *)nosys }, /* 418 = __xstat */
{ 0, (sy_call_t *)nosys }, /* 419 = __xfstat */
{ 0, (sy_call_t *)nosys }, /* 420 = __xlstat */
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 0d5000e..3503609 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -73,6 +73,13 @@
#include <machine/cpu.h>
+#if !defined(COMPAT_FREEBSD4) && !defined(NO_COMPAT_FREEBSD4)
+#error "You *really* want COMPAT_FREEBSD4 on -current for a while"
+#endif
+#if defined (__alpha__) && !defined(COMPAT_43)
+#error "You *really* need COMPAT_43 on the alpha for longjmp(3)"
+#endif
+
#define ONSIG 32 /* NSIG for osig* syscalls. XXX. */
static int coredump(struct thread *);
@@ -229,14 +236,15 @@ sig_ffs(sigset_t *set)
/*
* kern_sigaction
* sigaction
+ * freebsd4_sigaction
* osigaction
*/
int
-kern_sigaction(td, sig, act, oact, old)
+kern_sigaction(td, sig, act, oact, flags)
struct thread *td;
register int sig;
struct sigaction *act, *oact;
- int old;
+ int flags;
{
register struct sigacts *ps;
struct proc *p = td->td_proc;
@@ -353,9 +361,18 @@ kern_sigaction(td, sig, act, oact, old)
else
SIGADDSET(p->p_sigcatch, sig);
}
+#ifdef COMPAT_FREEBSD4
+ if (ps->ps_sigact[_SIG_IDX(sig)] == SIG_IGN ||
+ ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL ||
+ (flags & KSA_FREEBSD4) == 0)
+ SIGDELSET(ps->ps_freebsd4, sig);
+ else
+ SIGADDSET(ps->ps_freebsd4, sig);
+#endif
#ifdef COMPAT_43
if (ps->ps_sigact[_SIG_IDX(sig)] == SIG_IGN ||
- ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL || !old)
+ ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL ||
+ (flags & KSA_OSIGSET) == 0)
SIGDELSET(ps->ps_osigset, sig);
else
SIGADDSET(ps->ps_osigset, sig);
@@ -403,6 +420,46 @@ done2:
return (error);
}
+#ifdef COMPAT_FREEBSD4
+#ifndef _SYS_SYSPROTO_H_
+struct freebsd4_sigaction_args {
+ int sig;
+ struct sigaction *act;
+ struct sigaction *oact;
+};
+#endif
+/*
+ * MPSAFE
+ */
+/* ARGSUSED */
+int
+freebsd4_sigaction(td, uap)
+ struct thread *td;
+ register struct freebsd4_sigaction_args *uap;
+{
+ struct sigaction act, oact;
+ register struct sigaction *actp, *oactp;
+ int error;
+
+ mtx_lock(&Giant);
+
+ actp = (uap->act != NULL) ? &act : NULL;
+ oactp = (uap->oact != NULL) ? &oact : NULL;
+ if (actp) {
+ error = copyin(uap->act, actp, sizeof(act));
+ if (error)
+ goto done2;
+ }
+ error = kern_sigaction(td, uap->sig, actp, oactp, KSA_FREEBSD4);
+ if (oactp && !error) {
+ error = copyout(oactp, uap->oact, sizeof(oact));
+ }
+done2:
+ mtx_unlock(&Giant);
+ return (error);
+}
+#endif /* COMAPT_FREEBSD4 */
+
#ifdef COMPAT_43 /* XXX - COMPAT_FBSD3 */
#ifndef _SYS_SYSPROTO_H_
struct osigaction_args {
@@ -441,7 +498,7 @@ osigaction(td, uap)
nsap->sa_flags = sa.sa_flags;
OSIG2SIG(sa.sa_mask, nsap->sa_mask);
}
- error = kern_sigaction(td, uap->signum, nsap, osap, 1);
+ error = kern_sigaction(td, uap->signum, nsap, osap, KSA_OSIGSET);
if (osap && !error) {
sa.sa_handler = osap->sa_handler;
sa.sa_flags = osap->sa_flags;
@@ -452,6 +509,18 @@ done2:
mtx_unlock(&Giant);
return (error);
}
+
+#if !defined(__i386__) && !defined(__alpha__)
+/* Avoid replicating the same stub everywhere */
+int
+osigreturn(td, uap)
+ struct thread *td;
+ struct osigreturn_args *uap;
+{
+
+ return (nosys(td, (struct nosys_args *)uap));
+}
+#endif
#endif /* COMPAT_43 */
/*
diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c
index 142e8f2..3215b63 100644
--- a/sys/kern/syscalls.c
+++ b/sys/kern/syscalls.c
@@ -110,7 +110,7 @@ char *syscallnames[] = {
"getpriority", /* 100 = getpriority */
"old.send", /* 101 = old send */
"old.recv", /* 102 = old recv */
- "osigreturn", /* 103 = osigreturn */
+ "old.sigreturn", /* 103 = old sigreturn */
"bind", /* 104 = bind */
"setsockopt", /* 105 = setsockopt */
"listen", /* 106 = listen */
@@ -349,9 +349,9 @@ char *syscallnames[] = {
"#339", /* 339 = pioctl */
"sigprocmask", /* 340 = sigprocmask */
"sigsuspend", /* 341 = sigsuspend */
- "sigaction", /* 342 = sigaction */
+ "old.sigaction", /* 342 = old sigaction */
"sigpending", /* 343 = sigpending */
- "sigreturn", /* 344 = sigreturn */
+ "old.sigreturn", /* 344 = old sigreturn */
"#345", /* 345 = sigtimedwait */
"#346", /* 346 = sigwaitinfo */
"__acl_get_file", /* 347 = __acl_get_file */
@@ -423,8 +423,8 @@ char *syscallnames[] = {
"extattr_get_link", /* 413 = extattr_get_link */
"extattr_delete_link", /* 414 = extattr_delete_link */
"#415", /* 415 = __execve_mac */
- "#416", /* 416 = newsigreturn */
- "#417", /* 417 = newsigaction */
+ "sigaction", /* 416 = sigaction */
+ "sigreturn", /* 417 = sigreturn */
"#418", /* 418 = __xstat */
"#419", /* 419 = __xfstat */
"#420", /* 420 = __xlstat */
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index a0172b8..482b2a9 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -175,7 +175,7 @@
100 MSTD BSD { int getpriority(int which, int who); }
101 MCOMPAT BSD { int send(int s, caddr_t buf, int len, int flags); }
102 MCOMPAT BSD { int recv(int s, caddr_t buf, int len, int flags); }
-103 MSTD BSD { int osigreturn(struct osigcontext *sigcntxp); }
+103 MCOMPAT BSD { int sigreturn(struct osigcontext *sigcntxp); }
104 MSTD BSD { int bind(int s, caddr_t name, int namelen); }
105 MSTD BSD { int setsockopt(int s, int level, int name, \
caddr_t val, int valsize); }
@@ -490,10 +490,10 @@
340 MSTD POSIX { int sigprocmask(int how, const sigset_t *set, \
sigset_t *oset); }
341 MSTD POSIX { int sigsuspend(const sigset_t *sigmask); }
-342 MSTD POSIX { int sigaction(int sig, const struct sigaction *act, \
+342 MCOMPAT4 POSIX { int sigaction(int sig, const struct sigaction *act, \
struct sigaction *oact); }
343 MSTD POSIX { int sigpending(sigset_t *set); }
-344 MSTD BSD { int sigreturn(const struct __ucontext *sigcntxp); }
+344 MCOMPAT4 BSD { int sigreturn(const struct ucontext4 *sigcntxp); }
345 UNIMPL NOHIDE sigtimedwait
346 UNIMPL NOHIDE sigwaitinfo
347 MSTD BSD { int __acl_get_file(const char *path, \
@@ -601,8 +601,9 @@
414 STD BSD { int extattr_delete_link(const char *path, \
int attrnamespace, const char *attrname); }
415 UNIMPL BSD __execve_mac
-416 UNIMPL BSD newsigreturn
-417 UNIMPL BSD newsigaction
+416 MSTD POSIX { int sigaction(int sig, const struct sigaction *act, \
+ struct sigaction *oact); }
+417 MSTD BSD { int sigreturn(const struct __ucontext *sigcntxp); }
418 UNIMPL BSD __xstat
419 UNIMPL BSD __xfstat
420 UNIMPL BSD __xlstat
OpenPOWER on IntegriCloud