Re: [rfc] /dev/devstat permissions patch

From: John Baldwin <jhb_at_freebsd.org>
Date: Thu, 20 Mar 2014 10:05:29 -0400
On Tuesday, March 18, 2014 3:29:32 pm Maksim Yevmenkin wrote:
> hello,
> 
> would anyone object to the following patch?

I think this is fine.

While you are at it, can you test this patch to remove D_NEEDGIANT?

Index: subr_devstat.c
===================================================================
--- subr_devstat.c	(revision 263302)
+++ subr_devstat.c	(working copy)
_at__at_ -460,7 +460,6 _at__at_ 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",
 };
_at__at_ -482,13 +481,16 _at__at_ devstat_mmap(struct cdev *dev, vm_ooffset_t offset
 
 	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);
 }
 

-- 
John Baldwin
Received on Thu Mar 20 2014 - 13:22:11 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:47 UTC