Module Name: src Committed By: rmind Date: Wed Oct 27 02:58:05 UTC 2010
Modified Files: src/sys/kern: sys_descrip.c Log Message: do_posix_fadvise: check for a negative length; truncate the offset and round the end-offset, not vice-versa. Thanks to jakllsch@ for debug info. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/kern/sys_descrip.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_descrip.c diff -u src/sys/kern/sys_descrip.c:1.17 src/sys/kern/sys_descrip.c:1.18 --- src/sys/kern/sys_descrip.c:1.17 Wed Oct 28 18:24:44 2009 +++ src/sys/kern/sys_descrip.c Wed Oct 27 02:58:04 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_descrip.c,v 1.17 2009/10/28 18:24:44 njoly Exp $ */ +/* $NetBSD: sys_descrip.c,v 1.18 2010/10/27 02:58:04 rmind 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.17 2009/10/28 18:24:44 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.18 2010/10/27 02:58:04 rmind Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -622,13 +622,14 @@ vnode_t *vp; off_t endoffset; int error; + CTASSERT(POSIX_FADV_NORMAL == UVM_ADV_NORMAL); CTASSERT(POSIX_FADV_RANDOM == UVM_ADV_RANDOM); CTASSERT(POSIX_FADV_SEQUENTIAL == UVM_ADV_SEQUENTIAL); if (len == 0) { endoffset = INT64_MAX; - } else if (INT64_MAX - offset >= len) { + } else if (len > 0 && (INT64_MAX - offset) >= len) { endoffset = offset + len; } else { return EINVAL; @@ -680,8 +681,8 @@ case POSIX_FADV_DONTNEED: vp = fp->f_data; mutex_enter(&vp->v_interlock); - error = VOP_PUTPAGES(vp, round_page(offset), - trunc_page(endoffset), PGO_DEACTIVATE | PGO_CLEANIT); + error = VOP_PUTPAGES(vp, trunc_page(offset), + round_page(endoffset), PGO_DEACTIVATE | PGO_CLEANIT); break; case POSIX_FADV_NOREUSE: