From b646225a13e0d7209740c94964d83528117730c9 Mon Sep 17 00:00:00 2001 From: Maksim Yevmenkin Date: Mon, 24 Mar 2014 18:13:41 +0000 Subject: [PATCH] change defaule permissions on /dev/devstat. while i'm here remove D_NEEDGIANT flag Submitted by: jhb Reviewed by: jhb, scottl, rwatson, delphij, phk MFC after: 1 week --- sys/kern/subr_devstat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index 3d2492f52ac5..cb69669a1ae4 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -460,7 +460,6 @@ static d_mmap_t devstat_mmap; static struct cdevsw devstat_cdevsw = { .d_version = D_VERSION, - .d_flags = D_NEEDGIANT, .d_mmap = devstat_mmap, .d_name = "devstat", }; @@ -482,13 +481,16 @@ devstat_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, if (nprot != VM_PROT_READ) return (-1); + mtx_lock(&devstat_mutex); TAILQ_FOREACH(spp, &pagelist, list) { if (offset == 0) { *paddr = vtophys(spp->stat); + mtx_unlock(&devstat_mutex); return (0); } offset -= PAGE_SIZE; } + mtx_unlock(&devstat_mutex); return (-1); } @@ -503,7 +505,7 @@ devstat_alloc(void) mtx_assert(&devstat_mutex, MA_NOTOWNED); if (!once) { make_dev_credf(MAKEDEV_ETERNAL | MAKEDEV_CHECKNAME, - &devstat_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0400, + &devstat_cdevsw, 0, NULL, UID_ROOT, GID_WHEEL, 0444, DEVSTAT_DEVICE_NAME); once = 1; }