From cab41a8b8a1905c73284740495acce915f648c70 Mon Sep 17 00:00:00 2001 From: yamt Date: Tue, 31 Jan 2006 14:02:55 +0000 Subject: [PATCH] linux_sys_mremap: validate flags. --- sys/compat/linux/common/linux_misc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c index 31b837076b33..c3dd292e0bf2 100644 --- a/sys/compat/linux/common/linux_misc.c +++ b/sys/compat/linux/common/linux_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.148 2006/01/21 13:34:15 yamt Exp $ */ +/* $NetBSD: linux_misc.c,v 1.149 2006/01/31 14:02:55 yamt Exp $ */ /*- * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.148 2006/01/21 13:34:15 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.149 2006/01/31 14:02:55 yamt Exp $"); #include #include @@ -624,7 +624,15 @@ linux_sys_mremap(l, v, retval) oldva = (vaddr_t)SCARG(uap, old_address); oldsize = round_page(SCARG(uap, old_size)); newsize = round_page(SCARG(uap, new_size)); + if ((flags & ~(LINUX_MREMAP_FIXED|LINUX_MREMAP_MAYMOVE)) != 0) { + error = EINVAL; + goto done; + } if ((flags & LINUX_MREMAP_FIXED) != 0) { + if ((flags & LINUX_MREMAP_MAYMOVE) == 0) { + error = EINVAL; + goto done; + } #if 0 /* notyet */ newva = SCARG(uap, new_address); uvmflags = UVM_MREMAP_FIXED;