1dad0f566SMike Pritchard.\" $NetBSD: access.9,v 1.1 1996/06/16 10:38:35 pk Exp $ 2dad0f566SMike Pritchard.\" 3dad0f566SMike Pritchard.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 4dad0f566SMike Pritchard.\" All rights reserved. 5dad0f566SMike Pritchard.\" 6dad0f566SMike Pritchard.\" This code is derived from software contributed to The NetBSD Foundation 7dad0f566SMike Pritchard.\" by Paul Kranenburg. 8dad0f566SMike Pritchard.\" 9dad0f566SMike Pritchard.\" Redistribution and use in source and binary forms, with or without 10dad0f566SMike Pritchard.\" modification, are permitted provided that the following conditions 11dad0f566SMike Pritchard.\" are met: 12dad0f566SMike Pritchard.\" 1. Redistributions of source code must retain the above copyright 13dad0f566SMike Pritchard.\" notice, this list of conditions and the following disclaimer. 14dad0f566SMike Pritchard.\" 2. Redistributions in binary form must reproduce the above copyright 15dad0f566SMike Pritchard.\" notice, this list of conditions and the following disclaimer in the 16dad0f566SMike Pritchard.\" documentation and/or other materials provided with the distribution. 17dad0f566SMike Pritchard.\" 3. All advertising materials mentioning features or use of this software 18dad0f566SMike Pritchard.\" must display the following acknowledgement: 19dad0f566SMike Pritchard.\" This product includes software developed by the NetBSD 20dad0f566SMike Pritchard.\" Foundation, Inc. and its contributors. 21dad0f566SMike Pritchard.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22dad0f566SMike Pritchard.\" contributors may be used to endorse or promote products derived 23dad0f566SMike Pritchard.\" from this software without specific prior written permission. 24dad0f566SMike Pritchard.\" 25dad0f566SMike Pritchard.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26dad0f566SMike Pritchard.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27dad0f566SMike Pritchard.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28dad0f566SMike Pritchard.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 29dad0f566SMike Pritchard.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30dad0f566SMike Pritchard.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31dad0f566SMike Pritchard.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32dad0f566SMike Pritchard.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33dad0f566SMike Pritchard.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34dad0f566SMike Pritchard.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35dad0f566SMike Pritchard.\" POSSIBILITY OF SUCH DAMAGE. 36dad0f566SMike Pritchard.\" 377f3dea24SPeter Wemm.\" $FreeBSD$ 385bf6ab83SNik Clayton.\" 39dad0f566SMike Pritchard.Dd June 16, 1996 401e133bd4SMike Pritchard.Dt KERNACC 9 41dad0f566SMike Pritchard.Os FreeBSD 42dad0f566SMike Pritchard.Sh NAME 43dad0f566SMike Pritchard.Nm kernacc , 44dad0f566SMike Pritchard.Nm useracc 45dad0f566SMike Pritchard.Nd check memory regions for accessibility 46dad0f566SMike Pritchard.Sh SYNOPSIS 472e14815bSBruce Evans.Fd #include <sys/types.h> 482e14815bSBruce Evans.Fd #include <vm/vm.h> 492e14815bSBruce Evans.Fd #include <vm/vm_extern.h> 50dad0f566SMike Pritchard.Ft int 51dad0f566SMike Pritchard.Fn kernacc "caddr_t addr" "int len" "int rw" 52dad0f566SMike Pritchard.Ft int 53dad0f566SMike Pritchard.Fn useracc "caddr_t addr" "int len" "int rw" 54dad0f566SMike Pritchard.Sh DESCRIPTION 55dad0f566SMike PritchardThe 56dad0f566SMike Pritchard.Fn kernacc 57dad0f566SMike Pritchardand 58dad0f566SMike Pritchard.Fn useracc 59dad0f566SMike Pritchardfunctions check whether operations of the type specified in 60dad0f566SMike Pritchard.Fa rw 61dad0f566SMike Pritchardare permitted in the range of virtual addresses given by 62dad0f566SMike Pritchard.Fa addr 63dad0f566SMike Pritchardand 64dad0f566SMike Pritchard.Fa len . 65dad0f566SMike PritchardThe possible values of 66dad0f566SMike Pritchard.Fa rw 6702c58685SPoul-Henning Kampare any bitwise combination of 6802c58685SPoul-Henning Kamp.Dv VM_PROT_READ , 6902c58685SPoul-Henning Kamp.Dv VM_PROT_WRITE 70dad0f566SMike Pritchardand 7102c58685SPoul-Henning Kamp.Dv VM_PROT_EXECUTE . 72dad0f566SMike Pritchard.Fn kernacc 73dad0f566SMike Pritchardchecks addresses in the kernel address space, while 74dad0f566SMike Pritchard.Fn useracc 75dad0f566SMike Pritchardconsiders 76dad0f566SMike Pritchard.Fa addr 77dad0f566SMike Pritchardto represent an user space address. The process context to use for this 78dad0f566SMike Pritchardoperation is taken from the global variable 79dad0f566SMike Pritchard.Va curproc . 80dad0f566SMike Pritchard.Pp 81dad0f566SMike Pritchard.Sh RETURN VALUES 8202c58685SPoul-Henning KampBoth functions return boolean true if the type of access specified 8302c58685SPoul-Henning Kampby 84dad0f566SMike Pritchard.Fa rw 8502c58685SPoul-Henning Kampis permitted. Otherwise boolean false is returned. 86dad0f566SMike Pritchard.Pp 87dad0f566SMike Pritchard.Sh BUGS 8802c58685SPoul-Henning KampThe process pointer should be passed in as an argument to 8902c58685SPoul-Henning Kamp.Fn useracc . 90