diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-11-27 19:45:25 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2019-11-27 19:45:25 +0000 |
commit | 5bc9a0f5fa7cdb639a1d3db8c39f2058df69f0ba (patch) | |
tree | 8441b0760b6bb10348e50f8a78dfb0dc81018a15 /lib | |
parent | 9cb8017448f2f0793f0f61244868a652834aae80 (diff) |
Document msyscall(2): ld.so can use this (once only) to tell the kernel
where libc.so's text segment is, thereby allowing invocation of system
calls from that region. An upcoming change will kill the process if a
system call is invoked from addresses not explicitly permitted.
ok guenther kettenis mortimer
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/sys/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/sys/msyscall.2 | 74 |
2 files changed, 76 insertions, 2 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 5dd7f1aeb68..34769576ced 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.157 2019/05/28 13:08:56 beck Exp $ +# $OpenBSD: Makefile.inc,v 1.158 2019/11/27 19:45:24 deraadt Exp $ # $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 @@ -184,7 +184,7 @@ MAN+= __get_tcb.2 __thrsigdivert.2 __thrsleep.2 _exit.2 accept.2 \ getthrid.2 gettimeofday.2 getuid.2 intro.2 ioctl.2 issetugid.2 \ kbind.2 kill.2 kqueue.2 ktrace.2 link.2 listen.2 lseek.2 madvise.2 \ minherit.2 mkdir.2 mkfifo.2 mknod.2 mlock.2 \ - mlockall.2 mmap.2 mount.2 mprotect.2 mquery.2 msgctl.2 \ + mlockall.2 mmap.2 mount.2 mprotect.2 mquery.2 msyscall.2 msgctl.2 \ msgget.2 msgrcv.2 msgsnd.2 msync.2 munmap.2 nanosleep.2 \ nfssvc.2 open.2 pathconf.2 pipe.2 pledge.2 poll.2 profil.2 \ ptrace.2 quotactl.2 read.2 readlink.2 reboot.2 recv.2 \ diff --git a/lib/libc/sys/msyscall.2 b/lib/libc/sys/msyscall.2 new file mode 100644 index 00000000000..51eef032baa --- /dev/null +++ b/lib/libc/sys/msyscall.2 @@ -0,0 +1,74 @@ +.\" $OpenBSD: msyscall.2,v 1.1 2019/11/27 19:45:24 deraadt Exp $ +.\" $NetBSD: mprotect.2,v 1.6 1995/10/12 15:41:08 jtc Exp $ +.\" +.\" Copyright (c) 2019 Theo de Raadt <deraadt@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.Dd $Mdocdate: November 27 2019 $ +.Dt MSYSCALL 2 +.Os +.Sh NAME +.Nm msyscall +.Nd permit syscalls from a region of pages +.Sh SYNOPSIS +.In sys/mman.h +.Ft int +.Fn msyscall "void *addr" "size_t len" +.Sh DESCRIPTION +The +.Fn msyscall +system call permits system call entry from the pages that contain +the address range +.Fa addr +through +.Fa addr +\&+ +.Fa len +\- 1 +(inclusive). +If +.Fa len +is 0, no action is taken on the page that contains +.Fa addr . +.Pp +.Nm +is currently intended for use by +.Xr ld.so 1 +only, and may be called only once to indicate the location of +the loaded +.Pa libc.so +library. +.Pp +.Sh RETURN VALUES +.Rv -std +.Sh ERRORS +.Fn msyscall +will fail if: +.Bl -tag -width Er +.It Bq Er EINVAL +The specified address range would wrap around. +.It Bq Er EPERM +Attempt to call +.Fn +after +.Xr ld.so 1 +has called it. +.El +.Sh SEE ALSO +.Xr mmap 2 +.Sh HISTORY +The +.Fn msyscall +function first appeared in +.Ox 6.7 . |