1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

mincore() is a relic from the past, exposing physical machine information

about shared resources which no program should see.  only a few pieces of
software use it, generally poorly thought out.  they are being fixed, so
mincore() can be deleted.
ok guenther tedu jca sthen, others
This commit is contained in:
deraadt 2019-01-11 18:46:30 +00:00
parent cf52cfbce1
commit 54e4f6b9a1
20 changed files with 30 additions and 167 deletions

View File

@ -129,7 +129,6 @@ _thread_sys_listen
_thread_sys_lseek
_thread_sys_lstat
_thread_sys_madvise
_thread_sys_mincore
_thread_sys_minherit
_thread_sys_mkdir
_thread_sys_mkdirat
@ -325,7 +324,6 @@ listen
lseek
lstat
madvise
mincore
minherit
mkdir
mkdirat

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mman.h,v 1.3 2016/05/07 19:05:22 guenther Exp $ */
/* $OpenBSD: mman.h,v 1.4 2019/01/11 18:46:30 deraadt Exp $ */
/*
* Copyright (c) 2015 Philip Guenther <guenther@openbsd.org>
*
@ -21,7 +21,6 @@
#include_next <sys/mman.h>
PROTO_NORMAL(madvise);
PROTO_NORMAL(mincore);
PROTO_NORMAL(minherit);
PROTO_NORMAL(mlock);
PROTO_NORMAL(mlockall);

View File

@ -1,4 +1,4 @@
major=93
major=94
minor=0
# note: If changes were made to include/thread_private.h or if system
# calls were added/changed then librthread/shlib_version also be updated.

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.inc,v 1.155 2018/07/13 09:25:22 beck Exp $
# $OpenBSD: Makefile.inc,v 1.156 2019/01/11 18:46:30 deraadt Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
@ -56,7 +56,7 @@ ASM= __semctl.o __syscall.o __thrsigdivert.o \
getrlimit.o getrusage.o getsid.o getsockname.o \
getsockopt.o gettimeofday.o ioctl.o \
kevent.o kill.o kqueue.o ktrace.o lchown.o \
link.o linkat.o listen.o lstat.o madvise.o mincore.o \
link.o linkat.o listen.o lstat.o madvise.o \
minherit.o mkdir.o mkdirat.o mkfifo.o mkfifoat.o \
mknod.o mknodat.o mlock.o mlockall.o mount.o mprotect.o \
msgctl.o msgget.o munlock.o munlockall.o munmap.o \
@ -183,7 +183,7 @@ MAN+= __get_tcb.2 __thrsigdivert.2 __thrsleep.2 _exit.2 accept.2 \
getrtable.2 getrusage.2 getsid.2 getsockname.2 getsockopt.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 \
mincore.2 minherit.2 mkdir.2 mkfifo.2 mknod.2 mlock.2 \
minherit.2 mkdir.2 mkfifo.2 mknod.2 mlock.2 \
mlockall.2 mmap.2 mount.2 mprotect.2 mquery.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 \

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: madvise.2,v 1.19 2014/07/10 13:42:53 guenther Exp $
.\" $OpenBSD: madvise.2,v 1.20 2019/01/11 18:46:30 deraadt Exp $
.\" $NetBSD: madvise.2,v 1.7 1995/12/27 21:17:02 jtc Exp $
.\"
.\" Copyright (c) 1991, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: July 10 2014 $
.Dd $Mdocdate: January 11 2019 $
.Dt MADVISE 2
.Os
.Sh NAME
@ -89,7 +89,6 @@ If successful, the
function will return zero.
Otherwise an error number will be returned to indicate the error.
.Sh SEE ALSO
.Xr mincore 2 ,
.Xr minherit 2 ,
.Xr mprotect 2 ,
.Xr msync 2 ,

View File

@ -1,66 +0,0 @@
.\" $OpenBSD: mincore.2,v 1.11 2014/07/02 22:22:35 matthew Exp $
.\" $NetBSD: mincore.2,v 1.7 1995/10/12 15:41:05 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. 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.
.\"
.\" @(#)mincore.2 8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: July 2 2014 $
.Dt MINCORE 2
.Os
.Sh NAME
.Nm mincore
.Nd determine residency of memory pages
.Sh SYNOPSIS
.In sys/mman.h
.Ft int
.Fn mincore "void *addr" "size_t len" "char *vec"
.Sh DESCRIPTION
The
.Fn mincore
system call
allows a process to obtain information about whether pages are
core resident.
Here the current core residency of the pages is returned
in the character array
.Fa vec ,
with a value of 1 meaning that the page is in-core.
.Sh RETURN VALUES
.Rv -std
.Sh SEE ALSO
.Xr madvise 2 ,
.Xr minherit 2 ,
.Xr mlock 2 ,
.Xr mprotect 2 ,
.Xr msync 2 ,
.Xr munmap 2
.Sh HISTORY
The
.Fn mincore
function first appeared in
.Bx 4.4 .

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: minherit.2,v 1.15 2014/07/02 22:22:35 matthew Exp $
.\" $OpenBSD: minherit.2,v 1.16 2019/01/11 18:46:30 deraadt Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" @(#)minherit.2 8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: July 2 2014 $
.Dd $Mdocdate: January 11 2019 $
.Dt MINHERIT 2
.Os
.Sh NAME
@ -86,7 +86,6 @@ argument is invalid.
.El
.Sh SEE ALSO
.Xr madvise 2 ,
.Xr mincore 2 ,
.Xr mprotect 2 ,
.Xr msync 2 ,
.Xr munmap 2

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: mlock.2,v 1.19 2014/11/15 14:41:02 bentley Exp $
.\" $OpenBSD: mlock.2,v 1.20 2019/01/11 18:46:30 deraadt Exp $
.\" $NetBSD: mlock.2,v 1.3 1995/06/24 10:42:03 cgd Exp $
.\"
.\" Copyright (c) 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)mlock.2 8.2 (Berkeley) 12/11/93
.\"
.Dd $Mdocdate: November 15 2014 $
.Dd $Mdocdate: January 11 2019 $
.Dt MLOCK 2
.Os
.Sh NAME
@ -130,7 +130,6 @@ Some portion of the indicated address range is not locked.
.El
.Sh SEE ALSO
.Xr fork 2 ,
.Xr mincore 2 ,
.Xr minherit 2 ,
.Xr mlockall 2 ,
.Xr mmap 2 ,

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: mlockall.2,v 1.9 2014/12/14 07:42:50 schwarze Exp $
.\" $OpenBSD: mlockall.2,v 1.10 2019/01/11 18:46:30 deraadt Exp $
.\" $NetBSD: mlockall.2,v 1.6 2000/06/26 17:00:02 kleink Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: December 14 2014 $
.Dd $Mdocdate: January 11 2019 $
.Dt MLOCKALL 2
.Os
.Sh NAME
@ -97,7 +97,6 @@ The calling process does not have the appropriate privileges to perform
the requested operation.
.El
.Sh SEE ALSO
.Xr mincore 2 ,
.Xr mlock 2 ,
.Xr mmap 2 ,
.Xr munmap 2 ,

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: mmap.2,v 1.59 2018/02/11 07:30:59 jmc Exp $
.\" $OpenBSD: mmap.2,v 1.60 2019/01/11 18:46:30 deraadt Exp $
.\" $NetBSD: mmap.2,v 1.5 1995/06/24 10:48:59 cgd Exp $
.\"
.\" Copyright (c) 1991, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)mmap.2 8.1 (Berkeley) 6/4/93
.\"
.Dd $Mdocdate: February 11 2018 $
.Dd $Mdocdate: January 11 2019 $
.Dt MMAP 2
.Os
.Sh NAME
@ -297,7 +297,6 @@ for more information).
.El
.Sh SEE ALSO
.Xr madvise 2 ,
.Xr mincore 2 ,
.Xr mlock 2 ,
.Xr mprotect 2 ,
.Xr mquery 2 ,

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: mprotect.2,v 1.23 2018/01/12 04:36:44 deraadt Exp $
.\" $OpenBSD: mprotect.2,v 1.24 2019/01/11 18:46:30 deraadt Exp $
.\" $NetBSD: mprotect.2,v 1.6 1995/10/12 15:41:08 jtc Exp $
.\"
.\" Copyright (c) 1991, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)mprotect.2 8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: January 12 2018 $
.Dd $Mdocdate: January 11 2019 $
.Dt MPROTECT 2
.Os
.Sh NAME
@ -114,7 +114,6 @@ argument is invalid or the specified address range would wrap around.
.El
.Sh SEE ALSO
.Xr madvise 2 ,
.Xr mincore 2 ,
.Xr msync 2 ,
.Xr munmap 2
.Sh STANDARDS

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: msync.2,v 1.25 2015/10/29 12:03:46 tedu Exp $
.\" $OpenBSD: msync.2,v 1.26 2019/01/11 18:46:30 deraadt Exp $
.\" $NetBSD: msync.2,v 1.8 1995/10/12 15:41:09 jtc Exp $
.\"
.\" Copyright (c) 1991, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)msync.2 8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: October 29 2015 $
.Dd $Mdocdate: January 11 2019 $
.Dt MSYNC 2
.Os
.Sh NAME
@ -97,7 +97,6 @@ An I/O error occurred while writing.
.El
.Sh SEE ALSO
.Xr madvise 2 ,
.Xr mincore 2 ,
.Xr minherit 2 ,
.Xr mprotect 2 ,
.Xr munmap 2

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: munmap.2,v 1.17 2016/04/09 04:04:09 guenther Exp $
.\" $OpenBSD: munmap.2,v 1.18 2019/01/11 18:46:30 deraadt Exp $
.\" $NetBSD: munmap.2,v 1.5 1995/02/27 12:35:03 cgd Exp $
.\"
.\" Copyright (c) 1991, 1993
@ -30,7 +30,7 @@
.\"
.\" @(#)munmap.2 8.2 (Berkeley) 4/15/94
.\"
.Dd $Mdocdate: April 9 2016 $
.Dd $Mdocdate: January 11 2019 $
.Dt MUNMAP 2
.Os
.Sh NAME
@ -65,7 +65,6 @@ valid address space.
.El
.Sh SEE ALSO
.Xr madvise 2 ,
.Xr mincore 2 ,
.Xr mlock 2 ,
.Xr mlockall 2 ,
.Xr mmap 2 ,

View File

@ -1,2 +1,2 @@
major=25
minor=1
major=26
minor=0

View File

@ -1,4 +1,4 @@
; $OpenBSD: syscalls.master,v 1.188 2018/07/30 19:09:51 mpi Exp $
; $OpenBSD: syscalls.master,v 1.189 2019/01/11 18:46:30 deraadt Exp $
; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -179,8 +179,7 @@
const struct timeval *tptr); }
77 STD { int sys_futimes(int fd, \
const struct timeval *tptr); }
78 STD { int sys_mincore(void *addr, size_t len, \
char *vec); }
78 UNIMPL mincore
79 STD NOLOCK { int sys_getgroups(int gidsetsize, \
gid_t *gidset); }
80 STD { int sys_setgroups(int gidsetsize, \

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mman.h,v 1.32 2018/02/11 05:11:50 deraadt Exp $ */
/* $OpenBSD: mman.h,v 1.33 2019/01/11 18:46:30 deraadt Exp $ */
/* $NetBSD: mman.h,v 1.11 1995/03/26 20:24:23 jtc Exp $ */
/*-
@ -152,7 +152,6 @@ int mlockall(int);
int munlockall(void);
#if __BSD_VISIBLE
int madvise(void *, size_t, int);
int mincore(void *, size_t, char *);
int minherit(void *, size_t, int);
void * mquery(void *, size_t, int, int, int, off_t);
#endif

View File

@ -1,4 +1,4 @@
/* $OpenBSD: syscall.h,v 1.198 2018/07/30 19:10:50 mpi Exp $ */
/* $OpenBSD: syscall.h,v 1.199 2019/01/11 18:46:30 deraadt Exp $ */
/*
* System call numbers.
@ -237,9 +237,6 @@
/* syscall: "futimes" ret: "int" args: "int" "const struct timeval *" */
#define SYS_futimes 77
/* syscall: "mincore" ret: "int" args: "void *" "size_t" "char *" */
#define SYS_mincore 78
/* syscall: "getgroups" ret: "int" args: "int" "gid_t *" */
#define SYS_getgroups 79

View File

@ -1,4 +1,4 @@
/* $OpenBSD: syscallargs.h,v 1.201 2018/07/30 19:10:50 mpi Exp $ */
/* $OpenBSD: syscallargs.h,v 1.202 2019/01/11 18:46:30 deraadt Exp $ */
/*
* System call argument lists.
@ -370,12 +370,6 @@ struct sys_futimes_args {
syscallarg(const struct timeval *) tptr;
};
struct sys_mincore_args {
syscallarg(void *) addr;
syscallarg(size_t) len;
syscallarg(char *) vec;
};
struct sys_getgroups_args {
syscallarg(int) gidsetsize;
syscallarg(gid_t *) gidset;
@ -1189,7 +1183,6 @@ int sys_mprotect(struct proc *, void *, register_t *);
int sys_madvise(struct proc *, void *, register_t *);
int sys_utimes(struct proc *, void *, register_t *);
int sys_futimes(struct proc *, void *, register_t *);
int sys_mincore(struct proc *, void *, register_t *);
int sys_getgroups(struct proc *, void *, register_t *);
int sys_setgroups(struct proc *, void *, register_t *);
int sys_getpgrp(struct proc *, void *, register_t *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_mmap.c,v 1.152 2019/01/10 21:55:26 tedu Exp $ */
/* $OpenBSD: uvm_mmap.c,v 1.153 2019/01/11 18:46:30 deraadt Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */
/*
@ -168,53 +168,6 @@ sys_mquery(struct proc *p, void *v, register_t *retval)
return (error);
}
/*
* sys_mincore: determine if pages are in core or not.
*/
/* ARGSUSED */
int
sys_mincore(struct proc *p, void *v, register_t *retval)
{
struct sys_mincore_args /* {
syscallarg(void *) addr;
syscallarg(size_t) len;
syscallarg(char *) vec;
} */ *uap = v;
char *pgs;
vaddr_t start, end;
vsize_t len, npgs;
int error = 0;
start = (vaddr_t)SCARG(uap, addr);
len = SCARG(uap, len);
if (start & PAGE_MASK)
return (EINVAL);
len = round_page(len);
end = start + len;
if (end <= start)
return (EINVAL);
npgs = len >> PAGE_SHIFT;
/*
* < art> Anyone trying to mincore more than 4GB of address space is
* clearly insane.
*/
if (npgs >= (0xffffffff >> PAGE_SHIFT))
return (E2BIG);
pgs = mallocarray(npgs, sizeof(*pgs), M_TEMP, M_WAITOK | M_CANFAIL);
if (pgs == NULL)
return (ENOMEM);
/*
* Lie. After all, the answer may change at anytime.
*/
memset(pgs, 1, npgs * sizeof(*pgs));
error = copyout(pgs, SCARG(uap, vec), npgs * sizeof(char));
free(pgs, M_TEMP, npgs * sizeof(*pgs));
return (error);
}
int uvm_wxabort;
/*

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kdump.c,v 1.136 2018/12/12 17:55:28 tedu Exp $ */
/* $OpenBSD: kdump.c,v 1.137 2019/01/11 18:46:30 deraadt Exp $ */
/*-
* Copyright (c) 1988, 1993
@ -732,7 +732,6 @@ static const formatter scargs[][8] = {
[SYS_utimes] = { Ppath, Pptr },
[SYS_futimes] = { Pfd, Pptr },
[SYS_kbind] = { Pptr, Psize, Phexlonglong },
[SYS_mincore] = { Pptr, Pbigsize, Pptr },
[SYS_getgroups] = { Pcount, Pptr },
[SYS_setgroups] = { Pcount, Pptr },
[SYS_setpgid] = { Ppid_t, Ppid_t },