diff options
| author | elad <elad@NetBSD.org> | 2008-03-24 14:16:04 +0000 |
|---|---|---|
| committer | elad <elad@NetBSD.org> | 2008-03-24 14:16:04 +0000 |
| commit | b2b4fb68be99bbf186593f9ff3914dc1059b8c2c (patch) | |
| tree | e760b854f4ef3d157a7dddf015b2c4b3b867f427 /sys/dev | |
| parent | 0b9b01afa9fab19fd0bfb6f33cf2d4c6f980fd78 (diff) | |
Introduce two missing KAUTH_GENERIC_ISSUSER check in the voodoo and machfb
mmap() code.
This and similar requests will be replaced Soon, but these two in
particular should be pulled up to netbsd-4, and to allow doing that
smoothly, we're first introducing the "issuser" version.
Discussed with and okay macallan@.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pci/machfb.c | 18 | ||||
| -rw-r--r-- | sys/dev/pci/voodoofb.c | 17 |
2 files changed, 31 insertions, 4 deletions
diff --git a/sys/dev/pci/machfb.c b/sys/dev/pci/machfb.c index 6ad43e53abe..073b215c051 100644 --- a/sys/dev/pci/machfb.c +++ b/sys/dev/pci/machfb.c @@ -1,4 +1,4 @@ -/* $NetBSD: machfb.c,v 1.50 2008/01/15 02:00:49 jmcneill Exp $ */ +/* $NetBSD: machfb.c,v 1.51 2008/03/24 14:16:04 elad Exp $ */ /* * Copyright (c) 2002 Bang Jun-Young @@ -33,7 +33,7 @@ #include <sys/cdefs.h> __KERNEL_RCSID(0, - "$NetBSD: machfb.c,v 1.50 2008/01/15 02:00:49 jmcneill Exp $"); + "$NetBSD: machfb.c,v 1.51 2008/03/24 14:16:04 elad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -41,6 +41,7 @@ __KERNEL_RCSID(0, #include <sys/device.h> #include <sys/malloc.h> #include <sys/callout.h> +#include <sys/kauth.h> #ifdef __sparc__ #include <machine/promlib.h> @@ -1666,6 +1667,19 @@ mach64_mmap(void *v, void *vs, off_t offset, int prot) return pa; } #endif + + /* + * restrict all other mappings to processes with superuser privileges + * or the kernel itself + */ + if (curlwp != NULL) { + if (kauth_authorize_generic(kauth_cred_get(), + KAUTH_GENERIC_ISSUSER, NULL) != 0) { + printf("%s: mmap() rejected.\n", sc->sc_dev.dv_xname); + return -1; + } + } + reg = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, 0x18) & 0xffffff00); if (reg != sc->sc_regphys) { #ifdef DIAGNOSTIC diff --git a/sys/dev/pci/voodoofb.c b/sys/dev/pci/voodoofb.c index a565101ef7e..516e5c184f3 100644 --- a/sys/dev/pci/voodoofb.c +++ b/sys/dev/pci/voodoofb.c @@ -1,4 +1,4 @@ -/* $NetBSD: voodoofb.c,v 1.13 2008/02/27 23:59:37 macallan Exp $ */ +/* $NetBSD: voodoofb.c,v 1.14 2008/03/24 14:16:04 elad Exp $ */ /* * Copyright (c) 2005, 2006 Michael Lorenz @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: voodoofb.c,v 1.13 2008/02/27 23:59:37 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: voodoofb.c,v 1.14 2008/03/24 14:16:04 elad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: voodoofb.c,v 1.13 2008/02/27 23:59:37 macallan Exp $ #include <sys/device.h> #include <sys/malloc.h> #include <sys/callout.h> +#include <sys/kauth.h> #include <uvm/uvm_extern.h> @@ -1004,6 +1005,18 @@ voodoofb_mmap(void *v, void *vs, off_t offset, int prot) return pa; } + /* + * restrict all other mappings to processes with superuser privileges + * or the kernel itself + */ + if (curlwp != NULL) { + if (kauth_authorize_generic(kauth_cred_get(), + KAUTH_GENERIC_ISSUSER, NULL) != 0) { + printf("%s: mmap() rejected.\n", sc->sc_dev.dv_xname); + return -1; + } + } + if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) { pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, BUS_SPACE_MAP_LINEAR); |
