Replace curlwp->l_cred with kauth_cred_get(). Mailing list reference: http://mail-index.netbsd.org/tech-kern/2009/05/05/msg005038.htmldiff -r1.63 -r1.64 src/sys/arch/macppc/dev/ofb.c
(elad)
--- src/sys/arch/macppc/dev/ofb.c 2007/11/26 19:58:29 1.63
+++ src/sys/arch/macppc/dev/ofb.c 2009/05/06 18:41:54 1.64
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ofb.c,v 1.63 2007/11/26 19:58:29 garbled Exp $ */ | 1 | /* $NetBSD: ofb.c,v 1.64 2009/05/06 18:41:54 elad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | 4 | * Copyright (c) 1995, 1996 Carnegie-Mellon University. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Author: Chris G. Demetriou | 7 | * Author: Chris G. Demetriou | |
8 | * | 8 | * | |
9 | * Permission to use, copy, modify and distribute this software and | 9 | * Permission to use, copy, modify and distribute this software and | |
10 | * its documentation is hereby granted, provided that both the copyright | 10 | * its documentation is hereby granted, provided that both the copyright | |
11 | * notice and this permission notice appear in all copies of the | 11 | * notice and this permission notice appear in all copies of the | |
12 | * software, derivative works or modified versions, and any portions | 12 | * software, derivative works or modified versions, and any portions | |
13 | * thereof, and that both notices appear in supporting documentation. | 13 | * thereof, and that both notices appear in supporting documentation. | |
14 | * | 14 | * | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * | 18 | * | |
19 | * Carnegie Mellon requests users of this software to return to | 19 | * Carnegie Mellon requests users of this software to return to | |
20 | * | 20 | * | |
21 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | 21 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
22 | * School of Computer Science | 22 | * School of Computer Science | |
23 | * Carnegie Mellon University | 23 | * Carnegie Mellon University | |
24 | * Pittsburgh PA 15213-3890 | 24 | * Pittsburgh PA 15213-3890 | |
25 | * | 25 | * | |
26 | * any improvements or extensions that they make and grant Carnegie the | 26 | * any improvements or extensions that they make and grant Carnegie the | |
27 | * rights to redistribute these changes. | 27 | * rights to redistribute these changes. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include <sys/cdefs.h> | 30 | #include <sys/cdefs.h> | |
31 | __KERNEL_RCSID(0, "$NetBSD: ofb.c,v 1.63 2007/11/26 19:58:29 garbled Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: ofb.c,v 1.64 2009/05/06 18:41:54 elad Exp $"); | |
32 | 32 | |||
33 | #include <sys/param.h> | 33 | #include <sys/param.h> | |
34 | #include <sys/buf.h> | 34 | #include <sys/buf.h> | |
35 | #include <sys/conf.h> | 35 | #include <sys/conf.h> | |
36 | #include <sys/device.h> | 36 | #include <sys/device.h> | |
37 | #include <sys/ioctl.h> | 37 | #include <sys/ioctl.h> | |
38 | #include <sys/kernel.h> | 38 | #include <sys/kernel.h> | |
39 | #include <sys/malloc.h> | 39 | #include <sys/malloc.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/kauth.h> | 41 | #include <sys/kauth.h> | |
42 | #include <sys/lwp.h> | 42 | #include <sys/lwp.h> | |
43 | 43 | |||
44 | #include <uvm/uvm_extern.h> | 44 | #include <uvm/uvm_extern.h> | |
@@ -309,52 +309,48 @@ ofb_ioctl(void *v, void *vs, u_long cmd, | @@ -309,52 +309,48 @@ ofb_ioctl(void *v, void *vs, u_long cmd, | |||
309 | return (pci_devioctl(sc->sc_pc, sc->sc_pcitag, | 309 | return (pci_devioctl(sc->sc_pc, sc->sc_pcitag, | |
310 | cmd, data, flag, l)); | 310 | cmd, data, flag, l)); | |
311 | } | 311 | } | |
312 | return EPASSTHROUGH; | 312 | return EPASSTHROUGH; | |
313 | } | 313 | } | |
314 | 314 | |||
315 | static paddr_t | 315 | static paddr_t | |
316 | ofb_mmap(void *v, void *vs, off_t offset, int prot) | 316 | ofb_mmap(void *v, void *vs, off_t offset, int prot) | |
317 | { | 317 | { | |
318 | struct vcons_data *vd = v; | 318 | struct vcons_data *vd = v; | |
319 | struct ofb_softc *sc = vd->cookie; | 319 | struct ofb_softc *sc = vd->cookie; | |
320 | struct rasops_info *ri; | 320 | struct rasops_info *ri; | |
321 | u_int32_t *ap = sc->sc_addrs; | 321 | u_int32_t *ap = sc->sc_addrs; | |
322 | struct lwp *me; | |||
323 | int i; | 322 | int i; | |
324 | 323 | |||
325 | if (vd->active == NULL) { | 324 | if (vd->active == NULL) { | |
326 | printf("%s: no active screen.\n", sc->sc_dev.dv_xname); | 325 | printf("%s: no active screen.\n", sc->sc_dev.dv_xname); | |
327 | return -1; | 326 | return -1; | |
328 | } | 327 | } | |
329 | 328 | |||
330 | ri = &vd->active->scr_ri; | 329 | ri = &vd->active->scr_ri; | |
331 | 330 | |||
332 | /* framebuffer at offset 0 */ | 331 | /* framebuffer at offset 0 */ | |
333 | if ((offset >= 0) && (offset < sc->sc_fbsize)) | 332 | if ((offset >= 0) && (offset < sc->sc_fbsize)) | |
334 | return bus_space_mmap(sc->sc_memt, sc->sc_fbaddr, offset, prot, | 333 | return bus_space_mmap(sc->sc_memt, sc->sc_fbaddr, offset, prot, | |
335 | BUS_SPACE_MAP_LINEAR); | 334 | BUS_SPACE_MAP_LINEAR); | |
336 | 335 | |||
337 | /* | 336 | /* | |
338 | * restrict all other mappings to processes with superuser privileges | 337 | * restrict all other mappings to processes with superuser privileges | |
339 | * or the kernel itself | 338 | * or the kernel itself | |
340 | */ | 339 | */ | |
341 | me = curlwp; | 340 | if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER, | |
342 | if (me != NULL) { | 341 | NULL) != 0) { | |
343 | if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER, | 342 | printf("%s: mmap() rejected.\n", sc->sc_dev.dv_xname); | |
344 | NULL) != 0) { | 343 | return -1; | |
345 | printf("%s: mmap() rejected.\n", sc->sc_dev.dv_xname); | |||
346 | return -1; | |||
347 | } | |||
348 | } | 344 | } | |
349 | 345 | |||
350 | /* let them mmap() 0xa0000 - 0xbffff if it's not covered above */ | 346 | /* let them mmap() 0xa0000 - 0xbffff if it's not covered above */ | |
351 | #ifdef OFB_FAKE_VGA_FB | 347 | #ifdef OFB_FAKE_VGA_FB | |
352 | if (offset >=0xa0000 && offset < 0xbffff) | 348 | if (offset >=0xa0000 && offset < 0xbffff) | |
353 | return sc->sc_fbaddr + offset - 0xa0000; | 349 | return sc->sc_fbaddr + offset - 0xa0000; | |
354 | #endif | 350 | #endif | |
355 | 351 | |||
356 | /* allow to map our IO space */ | 352 | /* allow to map our IO space */ | |
357 | if ((offset >= 0xf2000000) && (offset < 0xf2800000)) { | 353 | if ((offset >= 0xf2000000) && (offset < 0xf2800000)) { | |
358 | return bus_space_mmap(sc->sc_iot, offset-0xf2000000, 0, prot, | 354 | return bus_space_mmap(sc->sc_iot, offset-0xf2000000, 0, prot, | |
359 | BUS_SPACE_MAP_LINEAR); | 355 | BUS_SPACE_MAP_LINEAR); | |
360 | } | 356 | } |
--- src/sys/dev/pci/chipsfb.c 2009/05/06 10:34:32 1.17
+++ src/sys/dev/pci/chipsfb.c 2009/05/06 18:41:54 1.18
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: chipsfb.c,v 1.17 2009/05/06 10:34:32 cegger Exp $ */ | 1 | /* $NetBSD: chipsfb.c,v 1.18 2009/05/06 18:41:54 elad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2006 Michael Lorenz | 4 | * Copyright (c) 2006 Michael Lorenz | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | /* | 28 | /* | |
29 | * A console driver for Chips & Technologies 65550 graphics controllers | 29 | * A console driver for Chips & Technologies 65550 graphics controllers | |
30 | * tested on macppc only so far | 30 | * tested on macppc only so far | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: chipsfb.c,v 1.17 2009/05/06 10:34:32 cegger Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: chipsfb.c,v 1.18 2009/05/06 18:41:54 elad Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/kernel.h> | 38 | #include <sys/kernel.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/malloc.h> | 40 | #include <sys/malloc.h> | |
41 | #include <sys/callout.h> | 41 | #include <sys/callout.h> | |
42 | #include <sys/lwp.h> | 42 | #include <sys/lwp.h> | |
43 | #include <sys/kauth.h> | 43 | #include <sys/kauth.h> | |
44 | 44 | |||
45 | #include <uvm/uvm_extern.h> | 45 | #include <uvm/uvm_extern.h> | |
46 | 46 | |||
47 | #include <dev/videomode/videomode.h> | 47 | #include <dev/videomode/videomode.h> | |
@@ -855,47 +855,43 @@ chipsfb_ioctl(void *v, void *vs, u_long | @@ -855,47 +855,43 @@ chipsfb_ioctl(void *v, void *vs, u_long | |||
855 | } | 855 | } | |
856 | } | 856 | } | |
857 | } | 857 | } | |
858 | return 0; | 858 | return 0; | |
859 | } | 859 | } | |
860 | return EPASSTHROUGH; | 860 | return EPASSTHROUGH; | |
861 | } | 861 | } | |
862 | 862 | |||
863 | static paddr_t | 863 | static paddr_t | |
864 | chipsfb_mmap(void *v, void *vs, off_t offset, int prot) | 864 | chipsfb_mmap(void *v, void *vs, off_t offset, int prot) | |
865 | { | 865 | { | |
866 | struct vcons_data *vd = v; | 866 | struct vcons_data *vd = v; | |
867 | struct chipsfb_softc *sc = vd->cookie; | 867 | struct chipsfb_softc *sc = vd->cookie; | |
868 | struct lwp *me; | |||
869 | paddr_t pa; | 868 | paddr_t pa; | |
870 | 869 | |||
871 | /* 'regular' framebuffer mmap()ing */ | 870 | /* 'regular' framebuffer mmap()ing */ | |
872 | if (offset < sc->memsize) { | 871 | if (offset < sc->memsize) { | |
873 | pa = bus_space_mmap(sc->sc_fbt, offset, 0, prot, | 872 | pa = bus_space_mmap(sc->sc_fbt, offset, 0, prot, | |
874 | BUS_SPACE_MAP_LINEAR); | 873 | BUS_SPACE_MAP_LINEAR); | |
875 | return pa; | 874 | return pa; | |
876 | } | 875 | } | |
877 | 876 | |||
878 | /* | 877 | /* | |
879 | * restrict all other mappings to processes with superuser privileges | 878 | * restrict all other mappings to processes with superuser privileges | |
880 | * or the kernel itself | 879 | * or the kernel itself | |
881 | */ | 880 | */ | |
882 | me = curlwp; | 881 | if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER, | |
883 | if (me != NULL) { | 882 | NULL) != 0) { | |
884 | if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER, | 883 | aprint_normal_dev(&sc->sc_dev, "mmap() rejected.\n"); | |
885 | NULL) != 0) { | 884 | return -1; | |
886 | aprint_normal_dev(&sc->sc_dev, "mmap() rejected.\n"); | |||
887 | return -1; | |||
888 | } | |||
889 | } | 885 | } | |
890 | 886 | |||
891 | if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) { | 887 | if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) { | |
892 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | 888 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | |
893 | BUS_SPACE_MAP_LINEAR); | 889 | BUS_SPACE_MAP_LINEAR); | |
894 | return pa; | 890 | return pa; | |
895 | } | 891 | } | |
896 | 892 | |||
897 | #ifdef PCI_MAGIC_IO_RANGE | 893 | #ifdef PCI_MAGIC_IO_RANGE | |
898 | /* allow mapping of IO space */ | 894 | /* allow mapping of IO space */ | |
899 | if ((offset >= PCI_MAGIC_IO_RANGE) && | 895 | if ((offset >= PCI_MAGIC_IO_RANGE) && | |
900 | (offset < PCI_MAGIC_IO_RANGE + 0x10000)) { | 896 | (offset < PCI_MAGIC_IO_RANGE + 0x10000)) { | |
901 | pa = bus_space_mmap(sc->sc_iot, offset - PCI_MAGIC_IO_RANGE, | 897 | pa = bus_space_mmap(sc->sc_iot, offset - PCI_MAGIC_IO_RANGE, |
--- src/sys/dev/pci/genfb_pci.c 2009/05/06 10:34:32 1.18
+++ src/sys/dev/pci/genfb_pci.c 2009/05/06 18:41:54 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: genfb_pci.c,v 1.18 2009/05/06 10:34:32 cegger Exp $ */ | 1 | /* $NetBSD: genfb_pci.c,v 1.19 2009/05/06 18:41:54 elad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2007 Michael Lorenz | 4 | * Copyright (c) 2007 Michael Lorenz | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | 26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: genfb_pci.c,v 1.18 2009/05/06 10:34:32 cegger Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: genfb_pci.c,v 1.19 2009/05/06 18:41:54 elad Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/systm.h> | 33 | #include <sys/systm.h> | |
34 | #include <sys/kernel.h> | 34 | #include <sys/kernel.h> | |
35 | #include <sys/device.h> | 35 | #include <sys/device.h> | |
36 | #include <sys/proc.h> | 36 | #include <sys/proc.h> | |
37 | #include <sys/mutex.h> | 37 | #include <sys/mutex.h> | |
38 | #include <sys/ioctl.h> | 38 | #include <sys/ioctl.h> | |
39 | #include <sys/kernel.h> | 39 | #include <sys/kernel.h> | |
40 | #include <sys/systm.h> | 40 | #include <sys/systm.h> | |
41 | #include <sys/kauth.h> | 41 | #include <sys/kauth.h> | |
42 | 42 | |||
43 | #include <dev/pci/pcidevs.h> | 43 | #include <dev/pci/pcidevs.h> | |
@@ -212,58 +212,54 @@ pci_genfb_ioctl(void *v, void *vs, u_lon | @@ -212,58 +212,54 @@ pci_genfb_ioctl(void *v, void *vs, u_lon | |||
212 | } | 212 | } | |
213 | } | 213 | } | |
214 | return 0; | 214 | return 0; | |
215 | } | 215 | } | |
216 | 216 | |||
217 | return EPASSTHROUGH; | 217 | return EPASSTHROUGH; | |
218 | } | 218 | } | |
219 | 219 | |||
220 | static paddr_t | 220 | static paddr_t | |
221 | pci_genfb_mmap(void *v, void *vs, off_t offset, int prot) | 221 | pci_genfb_mmap(void *v, void *vs, off_t offset, int prot) | |
222 | { | 222 | { | |
223 | struct pci_genfb_softc *sc = v; | 223 | struct pci_genfb_softc *sc = v; | |
224 | struct range *r; | 224 | struct range *r; | |
225 | struct lwp *me; | |||
226 | int i; | 225 | int i; | |
227 | 226 | |||
228 | if (offset == 0) | 227 | if (offset == 0) | |
229 | sc->sc_want_wsfb = 1; | 228 | sc->sc_want_wsfb = 1; | |
230 | 229 | |||
231 | /* | 230 | /* | |
232 | * regular fb mapping at 0 | 231 | * regular fb mapping at 0 | |
233 | * since some Sun firmware likes to put PCI resources low enough | 232 | * since some Sun firmware likes to put PCI resources low enough | |
234 | * to collide with the wsfb mapping we only allow it after asking | 233 | * to collide with the wsfb mapping we only allow it after asking | |
235 | * for offset 0 | 234 | * for offset 0 | |
236 | */ | 235 | */ | |
237 | DPRINTF("%s: %08x limit %08x\n", __func__, (uint32_t)offset, | 236 | DPRINTF("%s: %08x limit %08x\n", __func__, (uint32_t)offset, | |
238 | (uint32_t)sc->sc_gen.sc_fbsize); | 237 | (uint32_t)sc->sc_gen.sc_fbsize); | |
239 | if ((offset >= 0) && (offset < sc->sc_gen.sc_fbsize) && | 238 | if ((offset >= 0) && (offset < sc->sc_gen.sc_fbsize) && | |
240 | (sc->sc_want_wsfb == 1)) { | 239 | (sc->sc_want_wsfb == 1)) { | |
241 | 240 | |||
242 | return bus_space_mmap(sc->sc_memt, sc->sc_gen.sc_fboffset, | 241 | return bus_space_mmap(sc->sc_memt, sc->sc_gen.sc_fboffset, | |
243 | offset, prot, BUS_SPACE_MAP_LINEAR); | 242 | offset, prot, BUS_SPACE_MAP_LINEAR); | |
244 | } | 243 | } | |
245 | 244 | |||
246 | /* | 245 | /* | |
247 | * restrict all other mappings to processes with superuser privileges | 246 | * restrict all other mappings to processes with superuser privileges | |
248 | * or the kernel itself | 247 | * or the kernel itself | |
249 | */ | 248 | */ | |
250 | me = curlwp; | 249 | if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER, | |
251 | if (me != NULL) { | 250 | NULL) != 0) { | |
252 | if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER, | 251 | aprint_normal_dev(&sc->sc_gen.sc_dev, "mmap() rejected.\n"); | |
253 | NULL) != 0) { | 252 | return -1; | |
254 | aprint_normal_dev(&sc->sc_gen.sc_dev, "mmap() rejected.\n"); | |||
255 | return -1; | |||
256 | } | |||
257 | } | 253 | } | |
258 | 254 | |||
259 | #ifdef WSFB_FAKE_VGA_FB | 255 | #ifdef WSFB_FAKE_VGA_FB | |
260 | if ((offset >= 0xa0000) && (offset < 0xbffff)) { | 256 | if ((offset >= 0xa0000) && (offset < 0xbffff)) { | |
261 | 257 | |||
262 | return bus_space_mmap(sc->sc_memt, sc->sc_gen.sc_fboffset, | 258 | return bus_space_mmap(sc->sc_memt, sc->sc_gen.sc_fboffset, | |
263 | offset - 0xa0000, prot, BUS_SPACE_MAP_LINEAR); | 259 | offset - 0xa0000, prot, BUS_SPACE_MAP_LINEAR); | |
264 | } | 260 | } | |
265 | #endif | 261 | #endif | |
266 | 262 | |||
267 | /* | 263 | /* | |
268 | * XXX this should be generalized, let's just | 264 | * XXX this should be generalized, let's just | |
269 | * #define PCI_IOAREA_PADDR | 265 | * #define PCI_IOAREA_PADDR |
--- src/sys/dev/pci/voodoofb.c 2008/07/09 15:04:21 1.18
+++ src/sys/dev/pci/voodoofb.c 2009/05/06 18:41:54 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: voodoofb.c,v 1.18 2008/07/09 15:04:21 joerg Exp $ */ | 1 | /* $NetBSD: voodoofb.c,v 1.19 2009/05/06 18:41:54 elad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2005, 2006 Michael Lorenz | 4 | * Copyright (c) 2005, 2006 Michael Lorenz | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | /* | 28 | /* | |
29 | * A console driver for 3Dfx Voodoo3 graphics boards | 29 | * A console driver for 3Dfx Voodoo3 graphics boards | |
30 | * Thanks to Andreas Drewke (andreas_dr@gmx.de) for his Voodoo3 driver for BeOS | 30 | * Thanks to Andreas Drewke (andreas_dr@gmx.de) for his Voodoo3 driver for BeOS | |
31 | * which I used as reference / documentation | 31 | * which I used as reference / documentation | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: voodoofb.c,v 1.18 2008/07/09 15:04:21 joerg Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: voodoofb.c,v 1.19 2009/05/06 18:41:54 elad Exp $"); | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/kernel.h> | 39 | #include <sys/kernel.h> | |
40 | #include <sys/device.h> | 40 | #include <sys/device.h> | |
41 | #include <sys/malloc.h> | 41 | #include <sys/malloc.h> | |
42 | #include <sys/callout.h> | 42 | #include <sys/callout.h> | |
43 | #include <sys/kauth.h> | 43 | #include <sys/kauth.h> | |
44 | 44 | |||
45 | #include <uvm/uvm_extern.h> | 45 | #include <uvm/uvm_extern.h> | |
46 | 46 | |||
47 | #if defined(macppc) || defined (sparc64) || defined(ofppc) | 47 | #if defined(macppc) || defined (sparc64) || defined(ofppc) | |
48 | #define HAVE_OPENFIRMWARE | 48 | #define HAVE_OPENFIRMWARE | |
@@ -992,32 +992,30 @@ voodoofb_mmap(void *v, void *vs, off_t o | @@ -992,32 +992,30 @@ voodoofb_mmap(void *v, void *vs, off_t o | |||
992 | paddr_t pa; | 992 | paddr_t pa; | |
993 | 993 | |||
994 | /* 'regular' framebuffer mmap()ing */ | 994 | /* 'regular' framebuffer mmap()ing */ | |
995 | if (offset < sc->sc_fbsize) { | 995 | if (offset < sc->sc_fbsize) { | |
996 | pa = bus_space_mmap(sc->sc_fbt, offset, 0, prot, | 996 | pa = bus_space_mmap(sc->sc_fbt, offset, 0, prot, | |
997 | BUS_SPACE_MAP_LINEAR); | 997 | BUS_SPACE_MAP_LINEAR); | |
998 | return pa; | 998 | return pa; | |
999 | } | 999 | } | |
1000 | 1000 | |||
1001 | /* | 1001 | /* | |
1002 | * restrict all other mappings to processes with superuser privileges | 1002 | * restrict all other mappings to processes with superuser privileges | |
1003 | * or the kernel itself | 1003 | * or the kernel itself | |
1004 | */ | 1004 | */ | |
1005 | if (curlwp != NULL) { | 1005 | if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER, | |
1006 | if (kauth_authorize_generic(kauth_cred_get(), | 1006 | NULL) != 0) { | |
1007 | KAUTH_GENERIC_ISSUSER, NULL) != 0) { | 1007 | aprint_error_dev(sc->sc_dev, "mmap() rejected.\n"); | |
1008 | aprint_error_dev(sc->sc_dev, "mmap() rejected.\n"); | 1008 | return -1; | |
1009 | return -1; | |||
1010 | } | |||
1011 | } | 1009 | } | |
1012 | 1010 | |||
1013 | if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) { | 1011 | if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) { | |
1014 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | 1012 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | |
1015 | BUS_SPACE_MAP_LINEAR); | 1013 | BUS_SPACE_MAP_LINEAR); | |
1016 | return pa; | 1014 | return pa; | |
1017 | } | 1015 | } | |
1018 | 1016 | |||
1019 | if ((offset >= sc->sc_regs) && (offset < (sc->sc_regs + | 1017 | if ((offset >= sc->sc_regs) && (offset < (sc->sc_regs + | |
1020 | sc->sc_regsize))) { | 1018 | sc->sc_regsize))) { | |
1021 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | 1019 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | |
1022 | BUS_SPACE_MAP_LINEAR); | 1020 | BUS_SPACE_MAP_LINEAR); | |
1023 | return pa; | 1021 | return pa; |
--- src/sys/dev/pci/machfb.c 2009/01/03 03:43:22 1.56
+++ src/sys/dev/pci/machfb.c 2009/05/06 18:41:54 1.57
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: machfb.c,v 1.56 2009/01/03 03:43:22 yamt Exp $ */ | 1 | /* $NetBSD: machfb.c,v 1.57 2009/05/06 18:41:54 elad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002 Bang Jun-Young | 4 | * Copyright (c) 2002 Bang Jun-Young | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -23,27 +23,27 @@ | @@ -23,27 +23,27 @@ | |||
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | /* | 30 | /* | |
31 | * Some code is derived from ATI Rage Pro and Derivatives Programmer's Guide. | 31 | * Some code is derived from ATI Rage Pro and Derivatives Programmer's Guide. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, | 35 | __KERNEL_RCSID(0, | |
36 | "$NetBSD: machfb.c,v 1.56 2009/01/03 03:43:22 yamt Exp $"); | 36 | "$NetBSD: machfb.c,v 1.57 2009/05/06 18:41:54 elad Exp $"); | |
37 | 37 | |||
38 | #include <sys/param.h> | 38 | #include <sys/param.h> | |
39 | #include <sys/systm.h> | 39 | #include <sys/systm.h> | |
40 | #include <sys/kernel.h> | 40 | #include <sys/kernel.h> | |
41 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
42 | #include <sys/malloc.h> | 42 | #include <sys/malloc.h> | |
43 | #include <sys/callout.h> | 43 | #include <sys/callout.h> | |
44 | #include <sys/kauth.h> | 44 | #include <sys/kauth.h> | |
45 | 45 | |||
46 | #ifdef __sparc__ | 46 | #ifdef __sparc__ | |
47 | #include <machine/promlib.h> | 47 | #include <machine/promlib.h> | |
48 | #endif | 48 | #endif | |
49 | 49 | |||
@@ -1663,32 +1663,30 @@ mach64_mmap(void *v, void *vs, off_t off | @@ -1663,32 +1663,30 @@ mach64_mmap(void *v, void *vs, off_t off | |||
1663 | * Other 64bit architectures might run into similar problems. | 1663 | * Other 64bit architectures might run into similar problems. | |
1664 | */ | 1664 | */ | |
1665 | if (offset<sc->sc_apersize) { | 1665 | if (offset<sc->sc_apersize) { | |
1666 | pa = bus_space_mmap(sc->sc_memt, sc->sc_aperbase, offset, | 1666 | pa = bus_space_mmap(sc->sc_memt, sc->sc_aperbase, offset, | |
1667 | prot, BUS_SPACE_MAP_LINEAR); | 1667 | prot, BUS_SPACE_MAP_LINEAR); | |
1668 | return pa; | 1668 | return pa; | |
1669 | } | 1669 | } | |
1670 | #endif | 1670 | #endif | |
1671 | 1671 | |||
1672 | /* | 1672 | /* | |
1673 | * restrict all other mappings to processes with superuser privileges | 1673 | * restrict all other mappings to processes with superuser privileges | |
1674 | * or the kernel itself | 1674 | * or the kernel itself | |
1675 | */ | 1675 | */ | |
1676 | if (curlwp != NULL) { | 1676 | if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER, | |
1677 | if (kauth_authorize_generic(kauth_cred_get(), | 1677 | NULL) != 0) { | |
1678 | KAUTH_GENERIC_ISSUSER, NULL) != 0) { | 1678 | printf("%s: mmap() rejected.\n", device_xname(&sc->sc_dev)); | |
1679 | printf("%s: mmap() rejected.\n", device_xname(&sc->sc_dev)); | 1679 | return -1; | |
1680 | return -1; | |||
1681 | } | |||
1682 | } | 1680 | } | |
1683 | 1681 | |||
1684 | reg = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, 0x18) & 0xffffff00); | 1682 | reg = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, 0x18) & 0xffffff00); | |
1685 | if (reg != sc->sc_regphys) { | 1683 | if (reg != sc->sc_regphys) { | |
1686 | #ifdef DIAGNOSTIC | 1684 | #ifdef DIAGNOSTIC | |
1687 | printf("%s: BAR 0x18 changed! (%x %x)\n", | 1685 | printf("%s: BAR 0x18 changed! (%x %x)\n", | |
1688 | device_xname(&sc->sc_dev), (uint32_t)sc->sc_regphys, | 1686 | device_xname(&sc->sc_dev), (uint32_t)sc->sc_regphys, | |
1689 | (uint32_t)reg); | 1687 | (uint32_t)reg); | |
1690 | #endif | 1688 | #endif | |
1691 | sc->sc_regphys = reg; | 1689 | sc->sc_regphys = reg; | |
1692 | } | 1690 | } | |
1693 | 1691 | |||
1694 | reg = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, 0x10) & 0xffffff00); | 1692 | reg = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, 0x10) & 0xffffff00); |
--- src/sys/dev/pci/r128fb.c 2009/01/03 03:43:22 1.7
+++ src/sys/dev/pci/r128fb.c 2009/05/06 18:41:54 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: r128fb.c,v 1.7 2009/01/03 03:43:22 yamt Exp $ */ | 1 | /* $NetBSD: r128fb.c,v 1.8 2009/05/06 18:41:54 elad Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2007 Michael Lorenz | 4 | * Copyright (c) 2007 Michael Lorenz | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | /* | 28 | /* | |
29 | * A console driver for ATI Rage 128 graphics controllers | 29 | * A console driver for ATI Rage 128 graphics controllers | |
30 | * tested on macppc only so far | 30 | * tested on macppc only so far | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.7 2009/01/03 03:43:22 yamt Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: r128fb.c,v 1.8 2009/05/06 18:41:54 elad Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/kernel.h> | 38 | #include <sys/kernel.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/malloc.h> | 40 | #include <sys/malloc.h> | |
41 | #include <sys/lwp.h> | 41 | #include <sys/lwp.h> | |
42 | #include <sys/kauth.h> | 42 | #include <sys/kauth.h> | |
43 | 43 | |||
44 | #include <uvm/uvm_extern.h> | 44 | #include <uvm/uvm_extern.h> | |
45 | 45 | |||
46 | #include <dev/videomode/videomode.h> | 46 | #include <dev/videomode/videomode.h> | |
47 | 47 | |||
@@ -363,48 +363,44 @@ r128fb_ioctl(void *v, void *vs, u_long c | @@ -363,48 +363,44 @@ r128fb_ioctl(void *v, void *vs, u_long c | |||
363 | } | 363 | } | |
364 | } | 364 | } | |
365 | } | 365 | } | |
366 | return 0; | 366 | return 0; | |
367 | } | 367 | } | |
368 | return EPASSTHROUGH; | 368 | return EPASSTHROUGH; | |
369 | } | 369 | } | |
370 | 370 | |||
371 | static paddr_t | 371 | static paddr_t | |
372 | r128fb_mmap(void *v, void *vs, off_t offset, int prot) | 372 | r128fb_mmap(void *v, void *vs, off_t offset, int prot) | |
373 | { | 373 | { | |
374 | struct vcons_data *vd = v; | 374 | struct vcons_data *vd = v; | |
375 | struct r128fb_softc *sc = vd->cookie; | 375 | struct r128fb_softc *sc = vd->cookie; | |
376 | struct lwp *me; | |||
377 | paddr_t pa; | 376 | paddr_t pa; | |
378 | 377 | |||
379 | /* 'regular' framebuffer mmap()ing */ | 378 | /* 'regular' framebuffer mmap()ing */ | |
380 | if (offset < sc->sc_fbsize) { | 379 | if (offset < sc->sc_fbsize) { | |
381 | pa = bus_space_mmap(sc->sc_memt, sc->sc_fb + offset, 0, prot, | 380 | pa = bus_space_mmap(sc->sc_memt, sc->sc_fb + offset, 0, prot, | |
382 | BUS_SPACE_MAP_LINEAR); | 381 | BUS_SPACE_MAP_LINEAR); | |
383 | return pa; | 382 | return pa; | |
384 | } | 383 | } | |
385 | 384 | |||
386 | /* | 385 | /* | |
387 | * restrict all other mappings to processes with superuser privileges | 386 | * restrict all other mappings to processes with superuser privileges | |
388 | * or the kernel itself | 387 | * or the kernel itself | |
389 | */ | 388 | */ | |
390 | me = curlwp; | 389 | if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER, | |
391 | if (me != NULL) { | 390 | NULL) != 0) { | |
392 | if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER, | 391 | aprint_normal("%s: mmap() rejected.\n", | |
393 | NULL) != 0) { | 392 | device_xname(sc->sc_dev)); | |
394 | aprint_normal("%s: mmap() rejected.\n", | 393 | return -1; | |
395 | device_xname(sc->sc_dev)); | |||
396 | return -1; | |||
397 | } | |||
398 | } | 394 | } | |
399 | 395 | |||
400 | if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) { | 396 | if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) { | |
401 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | 397 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | |
402 | BUS_SPACE_MAP_LINEAR); | 398 | BUS_SPACE_MAP_LINEAR); | |
403 | return pa; | 399 | return pa; | |
404 | } | 400 | } | |
405 | 401 | |||
406 | if ((offset >= sc->sc_reg) && | 402 | if ((offset >= sc->sc_reg) && | |
407 | (offset < (sc->sc_reg + sc->sc_regsize))) { | 403 | (offset < (sc->sc_reg + sc->sc_regsize))) { | |
408 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | 404 | pa = bus_space_mmap(sc->sc_memt, offset, 0, prot, | |
409 | BUS_SPACE_MAP_LINEAR); | 405 | BUS_SPACE_MAP_LINEAR); | |
410 | return pa; | 406 | return pa; |
--- src/sys/dev/pci/radeonfb.c 2009/05/06 10:34:33 1.31
+++ src/sys/dev/pci/radeonfb.c 2009/05/06 18:41:54 1.32
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: radeonfb.c,v 1.31 2009/05/06 10:34:33 cegger Exp $ */ | 1 | /* $NetBSD: radeonfb.c,v 1.32 2009/05/06 18:41:54 elad Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 Itronix Inc. | 4 | * Copyright (c) 2006 Itronix Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Garrett D'Amore for Itronix Inc. | 7 | * Written by Garrett D'Amore for Itronix Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -60,27 +60,27 @@ | @@ -60,27 +60,27 @@ | |||
60 | * portions of the Software. | 60 | * portions of the Software. | |
61 | * | 61 | * | |
62 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 62 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
63 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 63 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
64 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | 64 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
65 | * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR | 65 | * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR | |
66 | * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | 66 | * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
67 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 67 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
68 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 68 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
69 | * DEALINGS IN THE SOFTWARE. | 69 | * DEALINGS IN THE SOFTWARE. | |
70 | */ | 70 | */ | |
71 | 71 | |||
72 | #include <sys/cdefs.h> | 72 | #include <sys/cdefs.h> | |
73 | __KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.31 2009/05/06 10:34:33 cegger Exp $"); | 73 | __KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.32 2009/05/06 18:41:54 elad Exp $"); | |
74 | 74 | |||
75 | #define RADEONFB_DEFAULT_DEPTH 32 | 75 | #define RADEONFB_DEFAULT_DEPTH 32 | |
76 | 76 | |||
77 | #include <sys/param.h> | 77 | #include <sys/param.h> | |
78 | #include <sys/systm.h> | 78 | #include <sys/systm.h> | |
79 | #include <sys/device.h> | 79 | #include <sys/device.h> | |
80 | #include <sys/malloc.h> | 80 | #include <sys/malloc.h> | |
81 | #include <sys/bus.h> | 81 | #include <sys/bus.h> | |
82 | #include <sys/kernel.h> | 82 | #include <sys/kernel.h> | |
83 | #include <sys/lwp.h> | 83 | #include <sys/lwp.h> | |
84 | #include <sys/kauth.h> | 84 | #include <sys/kauth.h> | |
85 | 85 | |||
86 | #include <dev/wscons/wsdisplayvar.h> | 86 | #include <dev/wscons/wsdisplayvar.h> | |
@@ -1051,57 +1051,51 @@ radeonfb_ioctl(void *v, void *vs, | @@ -1051,57 +1051,51 @@ radeonfb_ioctl(void *v, void *vs, | |||
1051 | return (pci_devioctl(sc->sc_pc, sc->sc_pt, cmd, d, flag, l)); | 1051 | return (pci_devioctl(sc->sc_pc, sc->sc_pt, cmd, d, flag, l)); | |
1052 | 1052 | |||
1053 | default: | 1053 | default: | |
1054 | return EPASSTHROUGH; | 1054 | return EPASSTHROUGH; | |
1055 | } | 1055 | } | |
1056 | } | 1056 | } | |
1057 | 1057 | |||
1058 | paddr_t | 1058 | paddr_t | |
1059 | radeonfb_mmap(void *v, void *vs, off_t offset, int prot) | 1059 | radeonfb_mmap(void *v, void *vs, off_t offset, int prot) | |
1060 | { | 1060 | { | |
1061 | struct vcons_data *vd; | 1061 | struct vcons_data *vd; | |
1062 | struct radeonfb_display *dp; | 1062 | struct radeonfb_display *dp; | |
1063 | struct radeonfb_softc *sc; | 1063 | struct radeonfb_softc *sc; | |
1064 | #ifdef RADEONFB_MMAP_BARS | |||
1065 | struct lwp *me; | |||
1066 | #endif | |||
1067 | paddr_t pa; | 1064 | paddr_t pa; | |
1068 | 1065 | |||
1069 | vd = (struct vcons_data *)v; | 1066 | vd = (struct vcons_data *)v; | |
1070 | dp = (struct radeonfb_display *)vd->cookie; | 1067 | dp = (struct radeonfb_display *)vd->cookie; | |
1071 | sc = dp->rd_softc; | 1068 | sc = dp->rd_softc; | |
1072 | 1069 | |||
1073 | /* XXX: note that we don't allow mapping of registers right now */ | 1070 | /* XXX: note that we don't allow mapping of registers right now */ | |
1074 | /* XXX: this means that the XFree86 radeon driver won't work */ | 1071 | /* XXX: this means that the XFree86 radeon driver won't work */ | |
1075 | 1072 | |||
1076 | if ((offset >= 0) && (offset < (dp->rd_virty * dp->rd_stride))) { | 1073 | if ((offset >= 0) && (offset < (dp->rd_virty * dp->rd_stride))) { | |
1077 | pa = bus_space_mmap(sc->sc_memt, | 1074 | pa = bus_space_mmap(sc->sc_memt, | |
1078 | sc->sc_memaddr + dp->rd_offset + offset, 0, | 1075 | sc->sc_memaddr + dp->rd_offset + offset, 0, | |
1079 | prot, BUS_SPACE_MAP_LINEAR); | 1076 | prot, BUS_SPACE_MAP_LINEAR); | |
1080 | return pa; | 1077 | return pa; | |
1081 | } | 1078 | } | |
1082 | 1079 | |||
1083 | #ifdef RADEONFB_MMAP_BARS | 1080 | #ifdef RADEONFB_MMAP_BARS | |
1084 | /* | 1081 | /* | |
1085 | * restrict all other mappings to processes with superuser privileges | 1082 | * restrict all other mappings to processes with superuser privileges | |
1086 | * or the kernel itself | 1083 | * or the kernel itself | |
1087 | */ | 1084 | */ | |
1088 | me = curlwp; | 1085 | if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER, | |
1089 | if (me != NULL) { | 1086 | NULL) != 0) { | |
1090 | if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER, | 1087 | aprint_error_dev(&sc->sc_dev, "mmap() rejected.\n"); | |
1091 | NULL) != 0) { | 1088 | return -1; | |
1092 | aprint_error_dev(&sc->sc_dev, "mmap() rejected.\n"); | |||
1093 | return -1; | |||
1094 | } | |||
1095 | } | 1089 | } | |
1096 | 1090 | |||
1097 | if ((offset >= sc->sc_regaddr) && | 1091 | if ((offset >= sc->sc_regaddr) && | |
1098 | (offset < sc->sc_regaddr + sc->sc_regsz)) { | 1092 | (offset < sc->sc_regaddr + sc->sc_regsz)) { | |
1099 | return bus_space_mmap(sc->sc_regt, offset, 0, prot, | 1093 | return bus_space_mmap(sc->sc_regt, offset, 0, prot, | |
1100 | BUS_SPACE_MAP_LINEAR); | 1094 | BUS_SPACE_MAP_LINEAR); | |
1101 | } | 1095 | } | |
1102 | 1096 | |||
1103 | if ((offset >= sc->sc_memaddr) && | 1097 | if ((offset >= sc->sc_memaddr) && | |
1104 | (offset < sc->sc_memaddr + sc->sc_memsz)) { | 1098 | (offset < sc->sc_memaddr + sc->sc_memsz)) { | |
1105 | return bus_space_mmap(sc->sc_memt, offset, 0, prot, | 1099 | return bus_space_mmap(sc->sc_memt, offset, 0, prot, | |
1106 | BUS_SPACE_MAP_LINEAR); | 1100 | BUS_SPACE_MAP_LINEAR); | |
1107 | } | 1101 | } |