Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/mach Check for alternate receive buffer for mach_...



details:   https://anonhg.NetBSD.org/src/rev/a7e65f3d6569
branches:  trunk
changeset: 539888:a7e65f3d6569
user:      manu <manu%NetBSD.org@localhost>
date:      Thu Nov 28 21:21:32 2002 +0000

description:
Check for alternate receive buffer for mach_msg_overwrite_trap
Check for target buffer length, and fail if it is too short
Move mach_msg_trap and mach_msg_overwrite_trap to their own file
Remove some useless debug messages now we have ktrace
Remove __P()

diffstat:

 sys/compat/mach/files.mach     |    3 +-
 sys/compat/mach/mach_clock.c   |   13 ++-
 sys/compat/mach/mach_clock.h   |    5 +-
 sys/compat/mach/mach_errno.c   |   15 ++-
 sys/compat/mach/mach_errno.h   |   11 +-
 sys/compat/mach/mach_exec.c    |    8 +-
 sys/compat/mach/mach_exec.h    |    8 +-
 sys/compat/mach/mach_host.c    |   31 +++++-
 sys/compat/mach/mach_host.h    |   15 +-
 sys/compat/mach/mach_message.c |  193 +++++++++++++++++++++++++++++++++++++++++
 sys/compat/mach/mach_message.h |    5 +-
 sys/compat/mach/mach_misc.c    |  131 +---------------------------
 sys/compat/mach/mach_port.c    |   31 +++++-
 sys/compat/mach/mach_port.h    |   11 +-
 sys/compat/mach/mach_task.c    |   26 ++++-
 sys/compat/mach/mach_task.h    |    8 +-
 sys/compat/mach/mach_thread.c  |   13 ++-
 sys/compat/mach/mach_thread.h  |    5 +-
 sys/compat/mach/mach_vm.c      |   39 ++++++-
 sys/compat/mach/mach_vm.h      |   11 +-
 20 files changed, 382 insertions(+), 200 deletions(-)

diffs (truncated from 1119 to 300 lines):

diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/files.mach
--- a/sys/compat/mach/files.mach        Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/files.mach        Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.mach,v 1.7 2002/11/26 08:10:14 manu Exp $
+#      $NetBSD: files.mach,v 1.8 2002/11/28 21:21:32 manu Exp $
 #
 # Config file description for machine-independent Mach compat code.
 # Included by ports that need it.
@@ -11,6 +11,7 @@
 file   compat/mach/mach_exec.c         compat_mach | compat_darwin
 file   compat/mach/mach_host.c         compat_mach | compat_darwin
 file   compat/mach/mach_misc.c         compat_mach | compat_darwin
+file   compat/mach/mach_message.c      compat_mach | compat_darwin
 file   compat/mach/mach_namemap.c      compat_mach | compat_darwin
 file   compat/mach/mach_port.c         compat_mach | compat_darwin
 file   compat/mach/mach_syscalls.c     compat_mach | compat_darwin
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_clock.c
--- a/sys/compat/mach/mach_clock.c      Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_clock.c      Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_clock.c,v 1.1 2002/11/26 08:10:14 manu Exp $ */
+/*     $NetBSD: mach_clock.c,v 1.2 2002/11/28 21:21:32 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_clock.c,v 1.1 2002/11/26 08:10:14 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_clock.c,v 1.2 2002/11/28 21:21:32 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -104,9 +104,11 @@
 }
 
 int 
-mach_clock_get_time(p, msgh)
+mach_clock_get_time(p, msgh, maxlen, dst)
        struct proc *p;
        mach_msg_header_t *msgh;
+       size_t maxlen;
+       mach_msg_header_t *dst;
 {
        mach_clock_get_time_request_t req;
        mach_clock_get_time_reply_t rep;
@@ -129,6 +131,11 @@
        rep.rep_cur_time.tv_nsec = tv.tv_usec * 1000; 
        rep.rep_trailer.msgh_trailer_size = 8;
 
+       if (sizeof(rep) > maxlen)
+               return EMSGSIZE;
+       if (dst != NULL)
+               msgh = dst;
+
        if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
                return error;
        return 0;
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_clock.h
--- a/sys/compat/mach/mach_clock.h      Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_clock.h      Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_clock.h,v 1.1 2002/11/26 08:10:15 manu Exp $ */
+/*     $NetBSD: mach_clock.h,v 1.2 2002/11/28 21:21:32 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -68,6 +68,7 @@
        mach_msg_trailer_t rep_trailer;
 } mach_clock_get_time_reply_t;
 
-int mach_clock_get_time(struct proc *, mach_msg_header_t *);
+int mach_clock_get_time(struct proc *, mach_msg_header_t *, 
+    size_t, mach_msg_header_t *);
 
 #endif /* _MACH_CLOCK_H_ */
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_errno.c
--- a/sys/compat/mach/mach_errno.c      Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_errno.c      Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_errno.c,v 1.3 2002/11/12 06:14:39 manu Exp $ */
+/*     $NetBSD: mach_errno.c,v 1.4 2002/11/28 21:21:32 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,10 +37,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.3 2002/11/12 06:14:39 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.4 2002/11/28 21:21:32 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/systm.h>
+#include <sys/null.h>
+#include <sys/errno.h>
 
 #include <compat/mach/mach_types.h>
 #include <compat/mach/mach_message.h>
@@ -136,11 +138,13 @@
 };
 
 int
-mach_msg_error(msgh, req, rep, error)
+mach_msg_error(msgh, req, rep, error, maxlen, dst)
        mach_msg_header_t *msgh;
        mach_msg_header_t *req;
        mach_error_reply_t *rep;
        int error;
+       size_t maxlen;
+       mach_msg_header_t *dst;
 {      
        bzero(rep, sizeof(*rep));
 
@@ -152,5 +156,10 @@
        rep->rep_retval = native_to_mach_errno[error];
        rep->rep_trailer.msgh_trailer_size = 8;
 
+       if (sizeof(*rep) > maxlen)
+               return EMSGSIZE;
+       if (dst != NULL)
+               msgh = dst;
+
        return copyout(rep, msgh, sizeof(*rep));
 }
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_errno.h
--- a/sys/compat/mach/mach_errno.h      Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_errno.h      Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-       /*      $NetBSD: mach_errno.h,v 1.2 2002/11/12 05:18:31 manu Exp $ */
+       /*      $NetBSD: mach_errno.h,v 1.3 2002/11/28 21:21:32 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -99,11 +99,12 @@
        mach_msg_trailer_t rep_trailer;
 } mach_error_reply_t;
 
-#define MACH_MSG_ERROR(msgh,req,rep,error) \
+#define MACH_MSG_ERROR(msgh,req,rep,error,maxlen,dst) \
     mach_msg_error((msgh), (mach_msg_header_t *)(req), \
-    (mach_error_reply_t *)(rep), (error))
+    (mach_error_reply_t *)(rep), (error), (maxlen), \
+    (mach_msg_header_t *)(dst))
 
-int mach_msg_error __P((mach_msg_header_t *, 
-    mach_msg_header_t *, mach_error_reply_t *, int));
+int mach_msg_error(mach_msg_header_t *, mach_msg_header_t *, 
+    mach_error_reply_t *, int, size_t, mach_msg_header_t *);
 
 #endif /* _MACH_ERRNO_H_ */
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_exec.c
--- a/sys/compat/mach/mach_exec.c       Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_exec.c       Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_exec.c,v 1.11 2002/11/21 19:53:41 manu Exp $       */
+/*     $NetBSD: mach_exec.c,v 1.12 2002/11/28 21:21:32 manu Exp $       */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.11 2002/11/21 19:53:41 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_exec.c,v 1.12 2002/11/28 21:21:32 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -60,9 +60,9 @@
 extern const char * const syscallnames[];
 #endif
 #ifndef __HAVE_SYSCALL_INTERN
-void syscall __P((void));
+void syscall(void);
 #else
-void mach_syscall_intern __P((struct proc *));
+void mach_syscall_intern(struct proc *);
 #endif
 
 const struct emul emul_mach = {
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_exec.h
--- a/sys/compat/mach/mach_exec.h       Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_exec.h       Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_exec.h,v 1.4 2002/10/27 22:22:04 manu Exp $        */
+/*     $NetBSD: mach_exec.h,v 1.5 2002/11/28 21:21:32 manu Exp $        */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -39,9 +39,9 @@
 #ifndef        _MACH_EXEC_H_
 #define        _MACH_EXEC_H_
 
-int exec_mach_copyargs __P((struct proc *, struct exec_package *, 
-    struct ps_strings *, char **, void *));
-int exec_mach_probe __P((char **));
+int exec_mach_copyargs(struct proc *, struct exec_package *, 
+    struct ps_strings *, char **, void *);
+int exec_mach_probe(char **);
 extern const struct emul emul_mach;
 
 #endif /* !_MACH_EXEC_H_ */
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_host.c
--- a/sys/compat/mach/mach_host.c       Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_host.c       Thu Nov 28 21:21:32 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_host.c,v 1.12 2002/11/20 07:17:11 manu Exp $ */
+/*     $NetBSD: mach_host.c,v 1.13 2002/11/28 21:21:32 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.12 2002/11/20 07:17:11 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.13 2002/11/28 21:21:32 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -54,9 +54,11 @@
 #include <compat/mach/mach_errno.h>
 
 int 
-mach_host_info(p, msgh)
+mach_host_info(p, msgh, maxlen, dst)
        struct proc *p;
        mach_msg_header_t *msgh;
+       size_t maxlen;
+       mach_msg_header_t *dst;
 {
        mach_host_info_request_t req;
        mach_host_info_reply_t rep;
@@ -135,6 +137,11 @@
                break;
        }
 
+       if (msglen > maxlen)
+               return EMSGSIZE;
+       if (dst != NULL)
+               msgh = dst;
+
        if ((error = copyout(&rep, msgh, msglen)) != 0)
                return error;
 
@@ -143,9 +150,11 @@
 
 
 int 
-mach_host_page_size(p, msgh)
+mach_host_page_size(p, msgh, maxlen, dst)
        struct proc *p;
        mach_msg_header_t *msgh;
+       size_t maxlen;
+       mach_msg_header_t *dst;
 {
        mach_host_page_size_request_t req;
        mach_host_page_size_reply_t rep;
@@ -166,15 +175,22 @@
        rep.rep_page_size = PAGE_SIZE;
        rep.rep_trailer.msgh_trailer_size = 8;
        
+       if (sizeof(rep) > maxlen)
+               return EMSGSIZE;
+       if (dst != NULL)
+               msgh = dst;
+
        if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
                return error;
        return 0;
 }
 
 int
-mach_host_get_clock_service(p, msgh)
+mach_host_get_clock_service(p, msgh, maxlen, dst)
        struct proc *p;
        mach_msg_header_t *msgh;
+       size_t maxlen;
+       mach_msg_header_t *dst;
 {
        mach_host_get_clock_service_request_t req;
        mach_host_get_clock_service_reply_t rep;
@@ -198,6 +214,11 @@
        rep.rep_clock_serv.disposition = 0x11; /* XXX */
        rep.rep_trailer.msgh_trailer_size = 8;
 
+       if (sizeof(rep) > maxlen)
+               return EMSGSIZE;
+       if (dst != NULL)
+               msgh = dst;
+
        if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
                return error;
        return 0;
diff -r f229b02c2a0e -r a7e65f3d6569 sys/compat/mach/mach_host.h
--- a/sys/compat/mach/mach_host.h       Thu Nov 28 21:00:27 2002 +0000
+++ b/sys/compat/mach/mach_host.h       Thu Nov 28 21:21:32 2002 +0000



Home | Main Index | Thread Index | Old Index