Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Reject negative offsets, to prevent panics later in...



details:   https://anonhg.NetBSD.org/src/rev/61eb575a911d
branches:  trunk
changeset: 453799:61eb575a911d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Aug 26 10:19:08 2019 +0000

description:
Reject negative offsets, to prevent panics later in genfs_getpages().

diffstat:

 sys/kern/sys_descrip.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 52eef832bf33 -r 61eb575a911d sys/kern/sys_descrip.c
--- a/sys/kern/sys_descrip.c    Mon Aug 26 10:05:34 2019 +0000
+++ b/sys/kern/sys_descrip.c    Mon Aug 26 10:19:08 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_descrip.c,v 1.33 2019/05/21 18:09:31 christos Exp $        */
+/*     $NetBSD: sys_descrip.c,v 1.34 2019/08/26 10:19:08 maxv Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.33 2019/05/21 18:09:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.34 2019/08/26 10:19:08 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -661,6 +661,9 @@
        CTASSERT(POSIX_FADV_RANDOM == UVM_ADV_RANDOM);
        CTASSERT(POSIX_FADV_SEQUENTIAL == UVM_ADV_SEQUENTIAL);
 
+       if (offset < 0) {
+               return EINVAL;
+       }
        if (len == 0) {
                endoffset = INT64_MAX;
        } else if (len > 0 && (INT64_MAX - offset) >= len) {



Home | Main Index | Thread Index | Old Index