From 5852a7fce959c4fd04787a21bfa5bd4f2e91495f Mon Sep 17 00:00:00 2001 From: maxv Date: Fri, 1 Jul 2016 12:49:22 +0000 Subject: [PATCH] Ensure the restartable atomic sequence is in userland, for real. --- sys/kern/kern_ras.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/sys/kern/kern_ras.c b/sys/kern/kern_ras.c index 6cd5a05087fb..272fd7e065b9 100644 --- a/sys/kern/kern_ras.c +++ b/sys/kern/kern_ras.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_ras.c,v 1.36 2013/09/14 20:46:27 martin Exp $ */ +/* $NetBSD: kern_ras.c,v 1.37 2016/07/01 12:49:22 maxv Exp $ */ /*- * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.36 2013/09/14 20:46:27 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_ras.c,v 1.37 2016/07/01 12:49:22 maxv Exp $"); #include #include @@ -197,18 +197,19 @@ ras_install(void *addr, size_t len) int nras, error; proc_t *p; + if (len == 0) + return EINVAL; + endaddr = (char *)addr + len; - /* do not warn about < NULL pointer comparision */ + /* Do not warn about < NULL pointer comparison */ __WARNING_PUSH_LESS_NULL_PTR - if (addr < (void *)VM_MIN_ADDRESS || - endaddr > (void *)VM_MAXUSER_ADDRESS) - return (EINVAL); + if (addr < (void *)VM_MIN_ADDRESS || addr > (void *)VM_MAXUSER_ADDRESS) + return EINVAL; + if (endaddr < addr) + return EINVAL; __WARNING_POP_LESS_NULL_PTR - if (len <= 0) - return (EINVAL); - newrp = kmem_alloc(sizeof(*newrp), KM_SLEEP); newrp->ras_startaddr = addr; newrp->ras_endaddr = endaddr; @@ -278,7 +279,6 @@ ras_purge(void *addr, size_t len) int sys_rasctl(struct lwp *l, const struct sys_rasctl_args *uap, register_t *retval) { - #if defined(__HAVE_RAS) /* { syscallarg(void *) addr; @@ -317,11 +317,7 @@ sys_rasctl(struct lwp *l, const struct sys_rasctl_args *uap, register_t *retval) } return (error); - #else - return (EOPNOTSUPP); - #endif - }