diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-01-07 17:20:49 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-01-07 17:20:49 +0000 |
commit | cd5ebec1be2b2a34afa54608db531e67f6194c8c (patch) | |
tree | 5bde3663f17d524005521fb3162b8e571fec413e | |
parent | e321ca862ddde2834d4e557e7c13f40fd6ed383f (diff) |
add minherit() system call
-rw-r--r-- | lib/libc/sys/Makefile.inc | 3 | ||||
-rw-r--r-- | lib/libc/sys/madvise.2 | 1 | ||||
-rw-r--r-- | lib/libc/sys/mincore.2 | 1 | ||||
-rw-r--r-- | lib/libc/sys/minherit.2 | 65 | ||||
-rw-r--r-- | lib/libc/sys/mlock.2 | 1 | ||||
-rw-r--r-- | lib/libc/sys/msync.2 | 1 | ||||
-rw-r--r-- | sys/kern/init_sysent.c | 38 | ||||
-rw-r--r-- | sys/kern/syscalls.c | 19 | ||||
-rw-r--r-- | sys/kern/syscalls.master | 20 | ||||
-rw-r--r-- | sys/sys/syscall.h | 3 | ||||
-rw-r--r-- | sys/sys/syscallargs.h | 7 | ||||
-rw-r--r-- | sys/vm/vm_extern.h | 1 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 44 |
13 files changed, 202 insertions, 2 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 4e911f4dfa0..fa4fdcb1276 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -88,7 +88,8 @@ MAN+= accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 chflags.2 \ getgid.2 getgroups.2 getitimer.2 getlogin.2 getpeername.2 getpgrp.2 \ getpid.2 getpriority.2 getrlimit.2 getrusage.2 getsockname.2 \ getsockopt.2 gettimeofday.2 getuid.2 intro.2 ioctl.2 kill.2 link.2 \ - listen.2 lseek.2 mkdir.2 mkfifo.2 mknod.2 madvise.2 mincore.2 mlock.2 \ + listen.2 lseek.2 mkdir.2 mkfifo.2 mknod.2 madvise.2 mincore.2 \ + minherit.2 mlock.2 \ mmap.2 mount.2 mprotect.2 msync.2 munmap.2 nfssvc.2 open.2 pathconf.2 \ pipe.2 profil.2 ptrace.2 quotactl.2 read.2 readlink.2 reboot.2 recv.2 \ rename.2 revoke.2 rmdir.2 select.2 send.2 setgroups.2 setpgid.2 \ diff --git a/lib/libc/sys/madvise.2 b/lib/libc/sys/madvise.2 index 649083d7517..d852ef58556 100644 --- a/lib/libc/sys/madvise.2 +++ b/lib/libc/sys/madvise.2 @@ -62,6 +62,7 @@ The known behaviors are given in .Ed .Sh SEE ALSO .Xr mincore 2 , +.Xr minherit 2 , .Xr mprotect 2 , .Xr msync 2 , .Xr munmap 2 diff --git a/lib/libc/sys/mincore.2 b/lib/libc/sys/mincore.2 index f8aa4bc0058..6d4afa6f887 100644 --- a/lib/libc/sys/mincore.2 +++ b/lib/libc/sys/mincore.2 @@ -56,6 +56,7 @@ in the character array with a value of 1 meaning that the page is in-core. .Sh SEE ALSO .Xr madvise 2 , +.Xr minherit 2 , .Xr mlock 2 , .Xr mprotect 2 , .Xr msync 2 , diff --git a/lib/libc/sys/minherit.2 b/lib/libc/sys/minherit.2 new file mode 100644 index 00000000000..aca7ec15614 --- /dev/null +++ b/lib/libc/sys/minherit.2 @@ -0,0 +1,65 @@ +.\" $NetBSD: mprotect.2,v 1.6 1995/10/12 15:41:08 jtc Exp $ +.\" +.\" Copyright (c) 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" 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 University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University 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 REGENTS 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 REGENTS 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. +.\" +.\" @(#)mprotect.2 8.1 (Berkeley) 6/9/93 +.\" +.Dd June 9, 1993 +.Dt MPROTECT 2 +.Os +.Sh NAME +.Nm minherit +.Nd control the inheritance of pages +.Sh SYNOPSIS +.Fd #include <sys/types.h> +.Fd #include <sys/mman.h> +.Ft int +.Fn minherit "caddr_t addr" "size_t len" "int inherit" +.Sh DESCRIPTION +The +.Fn minherit +system call +changes the specified pages to have the inheritance characteristic +.Fa inherit . +Not all implementations will guarantee that the inheritance characteristic +can be set on a page basis; +the granularity of changes may be as large as an entire region. +.Sh SEE ALSO +.Xr madvise 2 , +.Xr mincore 2 , +.Xr mprotect 2 , +.Xr msync 2 , +.Xr munmap 2 +.Sh HISTORY +The +.Fn mprotect +function first appeared in 4.4BSD. diff --git a/lib/libc/sys/mlock.2 b/lib/libc/sys/mlock.2 index 135232bb1fc..be33648c592 100644 --- a/lib/libc/sys/mlock.2 +++ b/lib/libc/sys/mlock.2 @@ -135,6 +135,7 @@ Some portion of the indicated address range is not locked. .Sh "SEE ALSO" .Xr fork 2 , .Xr mincore 2 , +.Xr minherit 2 , .Xr mmap 2 , .Xr munmap 2 , .Xr setrlimit 2 , diff --git a/lib/libc/sys/msync.2 b/lib/libc/sys/msync.2 index 7feb4369ccd..f616ad88a97 100644 --- a/lib/libc/sys/msync.2 +++ b/lib/libc/sys/msync.2 @@ -86,6 +86,7 @@ parameter was negative. An I/O error occured while writing to the file system. .Sh SEE ALSO .Xr madvise 2 , +.Xr minherit 2 , .Xr munmap 2 , .Xr mprotect 2 , .Xr mincore 2 diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index 6f69d159598..51c3c1ac731 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -598,5 +598,43 @@ struct sysent sysent[] = { { 0, 0, sys_nosys }, /* 231 = unimplemented shmget */ #endif + { 0, 0, + sys_nosys }, /* 232 = unimplemented */ + { 0, 0, + sys_nosys }, /* 233 = unimplemented */ + { 0, 0, + sys_nosys }, /* 234 = unimplemented */ + { 0, 0, + sys_nosys }, /* 235 = unimplemented */ + { 0, 0, + sys_nosys }, /* 236 = unimplemented */ + { 0, 0, + sys_nosys }, /* 237 = unimplemented */ + { 0, 0, + sys_nosys }, /* 238 = unimplemented */ + { 0, 0, + sys_nosys }, /* 239 = unimplemented */ + { 0, 0, + sys_nosys }, /* 240 = unimplemented */ + { 0, 0, + sys_nosys }, /* 241 = unimplemented */ + { 0, 0, + sys_nosys }, /* 242 = unimplemented */ + { 0, 0, + sys_nosys }, /* 243 = unimplemented */ + { 0, 0, + sys_nosys }, /* 244 = unimplemented */ + { 0, 0, + sys_nosys }, /* 245 = unimplemented */ + { 0, 0, + sys_nosys }, /* 246 = unimplemented */ + { 0, 0, + sys_nosys }, /* 247 = unimplemented */ + { 0, 0, + sys_nosys }, /* 248 = unimplemented */ + { 0, 0, + sys_nosys }, /* 249 = unimplemented */ + { 3, s(struct sys_minherit_args), + sys_minherit }, /* 250 = minherit */ }; diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index 94545251337..71887e40837 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -307,4 +307,23 @@ char *syscallnames[] = { "#230 (unimplemented shmdt)", /* 230 = unimplemented shmdt */ "#231 (unimplemented shmget)", /* 231 = unimplemented shmget */ #endif + "#232 (unimplemented)", /* 232 = unimplemented */ + "#233 (unimplemented)", /* 233 = unimplemented */ + "#234 (unimplemented)", /* 234 = unimplemented */ + "#235 (unimplemented)", /* 235 = unimplemented */ + "#236 (unimplemented)", /* 236 = unimplemented */ + "#237 (unimplemented)", /* 237 = unimplemented */ + "#238 (unimplemented)", /* 238 = unimplemented */ + "#239 (unimplemented)", /* 239 = unimplemented */ + "#240 (unimplemented)", /* 240 = unimplemented */ + "#241 (unimplemented)", /* 241 = unimplemented */ + "#242 (unimplemented)", /* 242 = unimplemented */ + "#243 (unimplemented)", /* 243 = unimplemented */ + "#244 (unimplemented)", /* 244 = unimplemented */ + "#245 (unimplemented)", /* 245 = unimplemented */ + "#246 (unimplemented)", /* 246 = unimplemented */ + "#247 (unimplemented)", /* 247 = unimplemented */ + "#248 (unimplemented)", /* 248 = unimplemented */ + "#249 (unimplemented)", /* 249 = unimplemented */ + "minherit", /* 250 = minherit */ }; diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 8f38f55b831..45827ce247c 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -425,3 +425,23 @@ 230 UNIMPL shmdt 231 UNIMPL shmget #endif +232 UNIMPL +233 UNIMPL +234 UNIMPL +235 UNIMPL +236 UNIMPL +237 UNIMPL +238 UNIMPL +239 UNIMPL +240 UNIMPL +241 UNIMPL +242 UNIMPL +243 UNIMPL +244 UNIMPL +245 UNIMPL +246 UNIMPL +247 UNIMPL +248 UNIMPL +249 UNIMPL +250 STD { int sys_minherit(caddr_t addr, size_t len, \ + int inherit); } diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 21de6918d6a..1b32a84e389 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -203,4 +203,5 @@ #define SYS_shmctl 229 #define SYS_shmdt 230 #define SYS_shmget 231 -#define SYS_MAXSYSCALL 232 +#define SYS_minherit 250 +#define SYS_MAXSYSCALL 251 diff --git a/sys/sys/syscallargs.h b/sys/sys/syscallargs.h index d0ecc433697..dc2b7684047 100644 --- a/sys/sys/syscallargs.h +++ b/sys/sys/syscallargs.h @@ -940,6 +940,12 @@ struct sys_shmget_args { syscallarg(int) shmflg; }; +struct sys_minherit_args { + syscallarg(caddr_t) addr; + syscallarg(size_t) len; + syscallarg(int) inherit; +}; + /* * System call prototypes. */ @@ -1179,3 +1185,4 @@ int sys_shmdt __P((struct proc *, void *, register_t *)); int sys_shmget __P((struct proc *, void *, register_t *)); #else #endif +int sys_minherit __P((struct proc *, void *, register_t *)); diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index cca6f755a64..614a501d8c5 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -53,6 +53,7 @@ int compat_43_getpagesize __P((struct proc *p, void *, int *)); int madvise __P((struct proc *, void *, int *)); int mincore __P((struct proc *, void *, int *)); int mprotect __P((struct proc *, void *, int *)); +int minherit __P((struct proc *, void *, int *)); int msync __P((struct proc *, void *, int *)); int munmap __P((struct proc *, void *, int *)); int obreak __P((struct proc *, void *, int *)); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 016dbc9565e..2e6ef423185 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -538,6 +538,50 @@ sys_mprotect(p, v, retval) return (EINVAL); } +int +sys_minherit(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + struct sys_minherit_args /* { + syscallarg(caddr_t) addr; + syscallarg(int) len; + syscallarg(int) inherit; + } */ *uap = v; + vm_offset_t addr; + vm_size_t size, pageoff; + register vm_inherit_t inherit; + + addr = (vm_offset_t)SCARG(uap, addr); + size = (vm_size_t)SCARG(uap, len); + inherit = SCARG(uap, inherit); +#ifdef DEBUG + if (mmapdebug & MDB_FOLLOW) + printf("minherit(%d): addr %x len %x inherit %d\n", p->p_pid, + addr, size, inherit); +#endif + /* + * Align the address to a page boundary, + * and adjust the size accordingly. + */ + pageoff = (addr & PAGE_MASK); + addr -= pageoff; + size += pageoff; + size = (vm_size_t) round_page(size); + if ((int)size < 0) + return(EINVAL); + + switch (vm_map_inherit(&p->p_vmspace->vm_map, addr, addr+size, + inherit)) { + case KERN_SUCCESS: + return (0); + case KERN_PROTECTION_FAILURE: + return (EACCES); + } + return (EINVAL); +} + /* ARGSUSED */ int sys_madvise(p, v, retval) |