tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
curlwp usage in some devices
Hey,
Please take a look at the attached diff. It removes curlwp->l_cred usage
in favor of kauth_cred_get(). I didn't commit as I'm not sure whether
removing the "curlwp == NULL" checks is okay or not -- can curlwp be
NULL?
Thanks,
-e.
Index: dev/pci/chipsfb.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/pci/chipsfb.c,v
retrieving revision 1.15
diff -u -p -r1.15 chipsfb.c
--- dev/pci/chipsfb.c 8 May 2008 01:43:17 -0000 1.15
+++ dev/pci/chipsfb.c 26 Dec 2008 07:26:30 -0000
@@ -865,7 +865,6 @@ chipsfb_mmap(void *v, void *vs, off_t of
{
struct vcons_data *vd = v;
struct chipsfb_softc *sc = vd->cookie;
- struct lwp *me;
paddr_t pa;
/* 'regular' framebuffer mmap()ing */
@@ -879,13 +878,10 @@ chipsfb_mmap(void *v, void *vs, off_t of
* restrict all other mappings to processes with superuser privileges
* or the kernel itself
*/
- me = curlwp;
- if (me != NULL) {
- if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER,
- NULL) != 0) {
- aprint_normal_dev(&sc->sc_dev, "mmap() rejected.\n");
- return -1;
- }
+ if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
+ NULL) != 0) {
+ aprint_normal_dev(&sc->sc_dev, "mmap() rejected.\n");
+ return -1;
}
if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) {
Index: dev/pci/genfb_pci.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/pci/genfb_pci.c,v
retrieving revision 1.16
diff -u -p -r1.16 genfb_pci.c
--- dev/pci/genfb_pci.c 23 Feb 2009 23:45:56 -0000 1.16
+++ dev/pci/genfb_pci.c 6 Apr 2009 07:36:23 -0000
@@ -222,7 +222,6 @@ pci_genfb_mmap(void *v, void *vs, off_t
{
struct pci_genfb_softc *sc = v;
struct range *r;
- struct lwp *me;
int i;
if (offset == 0)
@@ -247,13 +246,10 @@ pci_genfb_mmap(void *v, void *vs, off_t
* restrict all other mappings to processes with superuser privileges
* or the kernel itself
*/
- me = curlwp;
- if (me != NULL) {
- if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER,
- NULL) != 0) {
- aprint_normal_dev(&sc->sc_gen.sc_dev, "mmap()
rejected.\n");
- return -1;
- }
+ if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
+ NULL) != 0) {
+ aprint_normal_dev(&sc->sc_gen.sc_dev, "mmap() rejected.\n");
+ return -1;
}
#ifdef WSFB_FAKE_VGA_FB
Index: dev/pci/machfb.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/pci/machfb.c,v
retrieving revision 1.56
diff -u -p -r1.56 machfb.c
--- dev/pci/machfb.c 3 Jan 2009 03:43:22 -0000 1.56
+++ dev/pci/machfb.c 6 Apr 2009 07:36:27 -0000
@@ -1673,12 +1673,10 @@ mach64_mmap(void *v, void *vs, off_t off
* 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",
device_xname(&sc->sc_dev));
- return -1;
- }
+ if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
+ NULL) != 0) {
+ printf("%s: mmap() rejected.\n", device_xname(&sc->sc_dev));
+ return -1;
}
reg = (pci_conf_read(sc->sc_pc, sc->sc_pcitag, 0x18) & 0xffffff00);
Index: dev/pci/r128fb.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/pci/r128fb.c,v
retrieving revision 1.7
diff -u -p -r1.7 r128fb.c
--- dev/pci/r128fb.c 3 Jan 2009 03:43:22 -0000 1.7
+++ dev/pci/r128fb.c 6 Apr 2009 07:36:29 -0000
@@ -373,7 +373,6 @@ r128fb_mmap(void *v, void *vs, off_t off
{
struct vcons_data *vd = v;
struct r128fb_softc *sc = vd->cookie;
- struct lwp *me;
paddr_t pa;
/* 'regular' framebuffer mmap()ing */
@@ -387,14 +386,11 @@ r128fb_mmap(void *v, void *vs, off_t off
* restrict all other mappings to processes with superuser privileges
* or the kernel itself
*/
- me = curlwp;
- if (me != NULL) {
- if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER,
- NULL) != 0) {
- aprint_normal("%s: mmap() rejected.\n",
- device_xname(sc->sc_dev));
- return -1;
- }
+ if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
+ NULL) != 0) {
+ aprint_normal("%s: mmap() rejected.\n",
+ device_xname(sc->sc_dev));
+ return -1;
}
if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) {
Index: dev/pci/voodoofb.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/pci/voodoofb.c,v
retrieving revision 1.18
diff -u -p -r1.18 voodoofb.c
--- dev/pci/voodoofb.c 9 Jul 2008 15:04:21 -0000 1.18
+++ dev/pci/voodoofb.c 26 Dec 2008 07:28:57 -0000
@@ -1002,12 +1002,10 @@ voodoofb_mmap(void *v, void *vs, off_t o
* 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) {
- aprint_error_dev(sc->sc_dev, "mmap() rejected.\n");
- return -1;
- }
+ if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
+ NULL) != 0) {
+ aprint_error_dev(sc->sc_dev, "mmap() rejected.\n");
+ return -1;
}
if ((offset >= sc->sc_fb) && (offset < (sc->sc_fb + sc->sc_fbsize))) {
Index: arch/macppc/dev/ofb.c
===================================================================
RCS file: /usr/cvs/src/sys/arch/macppc/dev/ofb.c,v
retrieving revision 1.63
diff -u -p -r1.63 ofb.c
--- arch/macppc/dev/ofb.c 26 Nov 2007 19:58:29 -0000 1.63
+++ arch/macppc/dev/ofb.c 26 Dec 2008 07:29:36 -0000
@@ -319,7 +319,6 @@ ofb_mmap(void *v, void *vs, off_t offset
struct ofb_softc *sc = vd->cookie;
struct rasops_info *ri;
u_int32_t *ap = sc->sc_addrs;
- struct lwp *me;
int i;
if (vd->active == NULL) {
@@ -338,13 +337,10 @@ ofb_mmap(void *v, void *vs, off_t offset
* restrict all other mappings to processes with superuser privileges
* or the kernel itself
*/
- me = curlwp;
- if (me != NULL) {
- if (kauth_authorize_generic(me->l_cred, KAUTH_GENERIC_ISSUSER,
- NULL) != 0) {
- printf("%s: mmap() rejected.\n", sc->sc_dev.dv_xname);
- return -1;
- }
+ if (kauth_authorize_generic(kauth_cred_get(), KAUTH_GENERIC_ISSUSER,
+ NULL) != 0) {
+ printf("%s: mmap() rejected.\n", sc->sc_dev.dv_xname);
+ return -1;
}
/* let them mmap() 0xa0000 - 0xbffff if it's not covered above */
Home |
Main Index |
Thread Index |
Old Index