Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern do_posix_fadvise: check for a negative length; trun...
details: https://anonhg.NetBSD.org/src/rev/b2e3b91bcbc0
branches: trunk
changeset: 758215:b2e3b91bcbc0
user: rmind <rmind%NetBSD.org@localhost>
date: Wed Oct 27 02:58:04 2010 +0000
description:
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.
diffstat:
sys/kern/sys_descrip.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diffs (45 lines):
diff -r a1296b8cb31d -r b2e3b91bcbc0 sys/kern/sys_descrip.c
--- a/sys/kern/sys_descrip.c Tue Oct 26 22:34:33 2010 +0000
+++ b/sys/kern/sys_descrip.c Wed Oct 27 02:58:04 2010 +0000
@@ -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:
Home |
Main Index |
Thread Index |
Old Index