From b9a1f8e1dbe086ed6bd0b75102247c992c85b467 Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Fri, 7 Aug 2009 00:00:05 +0100 Subject: [PATCH] kern_memio - fix check for zerodev to fix memory mappings * Change iszerodev() to check against a saaved cdev_t returned by the make_dev creating /dev/zero instead of relying on some major/minor magic. * This fixes a problem when running mono, which caused a segfault on memset(). Reported-By: Hasso Tepper Reported-By: Matthew Dillon --- sys/kern/kern_memio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_memio.c b/sys/kern/kern_memio.c index 7f8bb4736a..7ea25aa91d 100644 --- a/sys/kern/kern_memio.c +++ b/sys/kern/kern_memio.c @@ -90,6 +90,7 @@ static struct dev_ops mem_ops = { static int rand_bolt; static caddr_t zbuf; +static cdev_t zerodev = NULL; MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors"); static int mem_ioctl (cdev_t, u_long, caddr_t, int, struct ucred *); @@ -548,8 +549,7 @@ mmpoll(struct dev_poll_args *ap) int iszerodev(cdev_t dev) { - return ((major(dev) == mem_ops.head.maj) - && minor(dev) == 12); + return (zerodev != NULL); } static void @@ -565,7 +565,7 @@ mem_drvinit(void *unused) make_dev(&mem_ops, 2, UID_ROOT, GID_WHEEL, 0666, "null"); make_dev(&mem_ops, 3, UID_ROOT, GID_WHEEL, 0644, "random"); make_dev(&mem_ops, 4, UID_ROOT, GID_WHEEL, 0644, "urandom"); - make_dev(&mem_ops, 12, UID_ROOT, GID_WHEEL, 0666, "zero"); + zerodev = make_dev(&mem_ops, 12, UID_ROOT, GID_WHEEL, 0666, "zero"); make_dev(&mem_ops, 14, UID_ROOT, GID_WHEEL, 0600, "io"); } -- 2.11.4.GIT