tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: enhance sysctl kern.expose_address



On Dec 5,  8:38am, thorpej%me.com@localhost (Jason Thorpe) wrote:
-- Subject: Re: enhance sysctl kern.expose_address

| PK_KMEM should only be set if mm_open returns 0.  There's a case where
| mm_md_open can return an error and PK_KMEM is still set.

Thanks,

christos

Index: mm.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mm.c,v
retrieving revision 1.22
diff -u -p -u -r1.22 mm.c
--- mm.c	13 Oct 2016 08:56:31 -0000	1.22
+++ mm.c	5 Dec 2018 16:47:49 -0000
@@ -53,17 +53,14 @@ static void *		dev_zero_page	__read_most
 static kmutex_t		dev_mem_lock	__cacheline_aligned;
 static vaddr_t		dev_mem_addr	__read_mostly;
 
+static dev_type_open(mm_open);
 static dev_type_read(mm_readwrite);
 static dev_type_ioctl(mm_ioctl);
 static dev_type_mmap(mm_mmap);
 static dev_type_ioctl(mm_ioctl);
 
 const struct cdevsw mem_cdevsw = {
-#ifdef __HAVE_MM_MD_OPEN
-	.d_open = mm_md_open,
-#else
-	.d_open = nullopen,
-#endif
+	.d_open = mm_open,
 	.d_close = nullclose,
 	.d_read = mm_readwrite,
 	.d_write = mm_readwrite,
@@ -94,6 +91,18 @@ const struct cdevsw mem_ultrix_cdevsw = 
 };
 #endif
 
+static int
+mm_open(dev_t dev, int flag, int mode, struct lwp *l)
+{
+#ifdef __HAVE_MM_MD_OPEN
+	int error;
+	if ((error = mm_md_open(dev, flag, mode, l)) != 0)
+		return error;
+#endif
+	l->l_proc->p_flag |= PK_KMEM;
+	return 0;
+}
+
 /*
  * mm_init: initialize memory device driver.
  */


Home | Main Index | Thread Index | Old Index