Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/linux/common Don't allow non-page-aligned offsets...



details:   https://anonhg.NetBSD.org/src/rev/b57eff05994d
branches:  trunk
changeset: 540498:b57eff05994d
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Dec 16 19:37:03 2002 +0000

description:
Don't allow non-page-aligned offsets! So dumb. From Jason Ish, thanks.

diffstat:

 sys/compat/linux/common/linux_misc.c    |  10 ++++++----
 sys/compat/linux/common/linux_oldmmap.c |   7 +++++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diffs (60 lines):

diff -r 63f8fe26cb6c -r b57eff05994d sys/compat/linux/common/linux_misc.c
--- a/sys/compat/linux/common/linux_misc.c      Mon Dec 16 19:33:50 2002 +0000
+++ b/sys/compat/linux/common/linux_misc.c      Mon Dec 16 19:37:03 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_misc.c,v 1.114 2002/11/25 02:11:23 thorpej Exp $ */
+/*     $NetBSD: linux_misc.c,v 1.115 2002/12/16 19:37:03 christos Exp $        */
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.114 2002/11/25 02:11:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.115 2002/12/16 19:37:03 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -444,9 +444,11 @@
                syscallarg(linux_off_t) offset;
        } */ *uap = v;
        struct sys_mmap_args cma;
-       int flags, fl = SCARG(uap, flags);
+       int flags = 0, fl = SCARG(uap, flags);
        
-       flags = 0;
+       if (SCARG(uap, offset) & PAGE_MASK)
+               return EINVAL;
+
        flags |= cvtto_bsd_mask(fl, LINUX_MAP_SHARED, MAP_SHARED);
        flags |= cvtto_bsd_mask(fl, LINUX_MAP_PRIVATE, MAP_PRIVATE);
        flags |= cvtto_bsd_mask(fl, LINUX_MAP_FIXED, MAP_FIXED);
diff -r 63f8fe26cb6c -r b57eff05994d sys/compat/linux/common/linux_oldmmap.c
--- a/sys/compat/linux/common/linux_oldmmap.c   Mon Dec 16 19:33:50 2002 +0000
+++ b/sys/compat/linux/common/linux_oldmmap.c   Mon Dec 16 19:37:03 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_oldmmap.c,v 1.58 2002/03/29 20:49:40 christos Exp $      */
+/*     $NetBSD: linux_oldmmap.c,v 1.59 2002/12/16 19:37:03 christos Exp $      */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_oldmmap.c,v 1.58 2002/03/29 20:49:40 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_oldmmap.c,v 1.59 2002/12/16 19:37:03 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -83,6 +83,9 @@
        if ((error = copyin(SCARG(uap, lmp), &lmap, sizeof lmap)))
                return error;
 
+       if (lmap.lm_pos & PAGE_MASK)
+               return EINVAL;
+
        SCARG(&nlmap,addr) = (unsigned long)lmap.lm_addr;
        SCARG(&nlmap,len) = lmap.lm_len;
        SCARG(&nlmap,prot) = lmap.lm_prot;



Home | Main Index | Thread Index | Old Index