summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/linux_machdep.c44
-rw-r--r--sys/compat/linux/linux_signal.c22
-rw-r--r--sys/compat/linux/linux_signal.h5
3 files changed, 60 insertions, 11 deletions
diff --git a/sys/arch/i386/i386/linux_machdep.c b/sys/arch/i386/i386/linux_machdep.c
index fd946fcd964..2a04de13f07 100644
--- a/sys/arch/i386/i386/linux_machdep.c
+++ b/sys/arch/i386/i386/linux_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_machdep.c,v 1.16 2001/05/01 19:15:16 aaron Exp $ */
+/* $OpenBSD: linux_machdep.c,v 1.17 2001/07/27 06:10:38 csapuntz Exp $ */
/* $NetBSD: linux_machdep.c,v 1.29 1996/05/03 19:42:11 christos Exp $ */
/*
@@ -499,32 +499,58 @@ linux_machdepioctl(p, v, retval)
case LINUX_VT_OPENQRY:
com = VT_OPENQRY;
break;
- case LINUX_VT_GETMODE:
+ case LINUX_VT_GETMODE: {
+ int sig;
+
SCARG(&bia, com) = VT_GETMODE;
if ((error = sys_ioctl(p, &bia, retval)))
return error;
if ((error = copyin(SCARG(uap, data), (caddr_t)&lvt,
sizeof (struct vt_mode))))
return error;
- lvt.relsig = bsd_to_linux_sig[lvt.relsig];
- lvt.acqsig = bsd_to_linux_sig[lvt.acqsig];
- lvt.frsig = bsd_to_linux_sig[lvt.frsig];
+ /* We need to bounds check here in case there
+ is a race with another thread */
+ if ((error = bsd_to_linux_signal(lvt.relsig, &sig)))
+ return error;
+ lvt.relsig = sig;
+
+ if ((error = bsd_to_linux_signal(lvt.acqsig, &sig)))
+ return error;
+ lvt.acqsig = sig;
+
+ if ((error = bsd_to_linux_signal(lvt.frsig, &sig)))
+ return error;
+ lvt.frsig = sig;
+
return copyout((caddr_t)&lvt, SCARG(uap, data),
sizeof (struct vt_mode));
- case LINUX_VT_SETMODE:
+ }
+ case LINUX_VT_SETMODE: {
+ int sig;
+
com = VT_SETMODE;
if ((error = copyin(SCARG(uap, data), (caddr_t)&lvt,
sizeof (struct vt_mode))))
return error;
- lvt.relsig = linux_to_bsd_sig[lvt.relsig];
- lvt.acqsig = linux_to_bsd_sig[lvt.acqsig];
- lvt.frsig = linux_to_bsd_sig[lvt.frsig];
+ if ((error = linux_to_bsd_signal(lvt.relsig, &sig)))
+ return error;
+ lvt.relsig = sig;
+
+ if ((error = linux_to_bsd_signal(lvt.acqsig, &sig)))
+ return error;
+ lvt.acqsig = sig;
+
+ if ((error = linux_to_bsd_signal(lvt.frsig, &sig)))
+ return error;
+ lvt.frsig = sig;
+
sg = stackgap_init(p->p_emul);
bvtp = stackgap_alloc(&sg, sizeof (struct vt_mode));
if ((error = copyout(&lvt, bvtp, sizeof (struct vt_mode))))
return error;
SCARG(&bia, data) = bvtp;
break;
+ }
case LINUX_VT_DISALLOCATE:
/* XXX should use WSDISPLAYIO_DELSCREEN */
return 0;
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
index 6c52c88eb4a..1a0b12f8476 100644
--- a/sys/compat/linux/linux_signal.c
+++ b/sys/compat/linux/linux_signal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_signal.c,v 1.9 2001/04/09 06:52:26 tholo Exp $ */
+/* $OpenBSD: linux_signal.c,v 1.10 2001/07/27 06:10:38 csapuntz Exp $ */
/* $NetBSD: linux_signal.c,v 1.10 1996/04/04 23:51:36 christos Exp $ */
/*
@@ -351,6 +351,26 @@ bsd_to_linux_sigaction(bsa, lsa)
lsa->sa__handler = bsa->sa_handler;
}
+int
+linux_to_bsd_signal(int linuxsig, int *bsdsig)
+{
+ if (linuxsig < 0 || linuxsig > LINUX__NSIG)
+ return (EINVAL);
+
+ *bsdsig = linux_to_bsd_sig[linuxsig];
+ return (0);
+}
+
+int
+bsd_to_linux_signal(int bsdsig, int *linuxsig)
+{
+ if (bsdsig < 0 || bsdsig > NSIG)
+ return (EINVAL);
+
+ *linuxsig = bsd_to_linux_sig[bsdsig];
+ return (0);
+}
+
/*
* The Linux sigaction() system call. Do the usual conversions,
* and just call sigaction(). Some flags and values are silently
diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h
index bfa67cd2ee6..c968de65efc 100644
--- a/sys/compat/linux/linux_signal.h
+++ b/sys/compat/linux/linux_signal.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_signal.h,v 1.5 2000/06/07 14:11:38 niklas Exp $ */
+/* $OpenBSD: linux_signal.h,v 1.6 2001/07/27 06:10:38 csapuntz Exp $ */
/* $NetBSD: linux_signal.h,v 1.4 1995/08/27 20:51:51 fvdl Exp $ */
/*
@@ -138,4 +138,7 @@ void linux_to_bsd_sigaction __P((struct linux_sigaction *,
void bsd_to_linux_sigaction __P((struct sigaction *,
struct linux_sigaction *));
+int linux_to_bsd_signal (int, int *);
+int bsd_to_linux_signal (int, int *);
+
#endif /* !_LINUX_SIGNAL_H */