diff options
author | julian <julian@FreeBSD.org> | 1999-04-05 19:38:30 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1999-04-05 19:38:30 +0000 |
commit | 0ed09d2ad576c0a64797f8ca9bebd32873f770ae (patch) | |
tree | 6de1ee6b7f198b11b20d471fbc1a36de8329d82e /sys/miscfs | |
parent | 9ac433dd352fdfe7f3038aa0e1a4333686bc07fc (diff) | |
download | FreeBSD-src-0ed09d2ad576c0a64797f8ca9bebd32873f770ae.zip FreeBSD-src-0ed09d2ad576c0a64797f8ca9bebd32873f770ae.tar.gz |
Catch a case spotted by Tor where files mmapped could leave garbage in the
unallocated parts of the last page when the file ended on a frag
but not a page boundary.
Delimitted by tags PRE_MATT_MMAP_EOF and POST_MATT_MMAP_EOF,
in files alpha/alpha/pmap.c i386/i386/pmap.c nfs/nfs_bio.c vm/pmap.h
vm/vm_page.c vm/vm_page.h vm/vnode_pager.c miscfs/specfs/spec_vnops.c
ufs/ufs/ufs_readwrite.c kern/vfs_bio.c
Submitted by: Matt Dillon <dillon@freebsd.org>
Reviewed by: Alan Cox <alc@freebsd.org>
Diffstat (limited to 'sys/miscfs')
-rw-r--r-- | sys/miscfs/specfs/spec_vnops.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index 3f29d9362..7f76209 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95 - * $Id: spec_vnops.c,v 1.80 1999/01/27 22:42:07 dillon Exp $ + * $Id: spec_vnops.c,v 1.81 1999/02/25 05:22:30 dillon Exp $ */ #include <sys/param.h> @@ -866,8 +866,12 @@ spec_getpages(ap) m->valid = VM_PAGE_BITS_ALL; m->dirty = 0; } else if (toff < nread) { - int nvalid = ((nread + DEV_BSIZE - 1) - toff) & ~(DEV_BSIZE - 1); - vm_page_set_validclean(m, 0, nvalid); + /* + * Since this is a VM request, we have to supply the + * unaligned offset to allow vm_page_set_validclean() + * to zero sub-DEV_BSIZE'd portions of the page. + */ + vm_page_set_validclean(m, 0, nread - toff); } else { m->valid = 0; m->dirty = 0; @@ -894,6 +898,12 @@ spec_getpages(ap) } } else if (m->valid) { gotreqpage = 1; + /* + * Since this is a VM request, we need to make the + * entire page presentable by zeroing invalid sections. + */ + if (m->valid != VM_PAGE_BITS_ALL) + vm_page_zero_invalid(m, FALSE); } } if (!gotreqpage) { |