Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src Pull up following revision(s) (requested by martin in tic...
details: https://anonhg.NetBSD.org/src/rev/c2b5b2f2a877
branches: netbsd-6
changeset: 774182:c2b5b2f2a877
user: riz <riz%NetBSD.org@localhost>
date: Mon Jun 11 21:25:02 2012 +0000
description:
Pull up following revision(s) (requested by martin in ticket #301):
sys/uvm/uvm_vnode.c: revision 1.98
tests/lib/libc/sys/t_mmap.c: revision 1.3
tests/lib/libc/sys/t_mmap.c: revision 1.4
tests/lib/libc/sys/t_mmap.c: revision 1.5
tests/lib/libc/sys/t_mmap.c: revision 1.6
Only use generic readahead on VREG vnodes, the space used to store the
context is not valid on other types.
Prevents the crash reported in PR kern/38889, but does not fix the
mmap of block devices, more work is needed (no size on VBLK vnodes).
Do not skip the block device mmap test, as it does not crash
the kernel any more. Mark it as expected failure instead.
mmap_block:
do not use a hardcoded block device list, but query the kernel for attached
disks instead, then try to mmap the raw partition.
Use atf_tc_skip().
A test case for serious PR kern/38889: crash on open/mmap/close of block
device. The test case is skipped for the time being as it replicates the
panic described in the PR (tested on NetBSD/amd64 6.0 BETA).
diffstat:
sys/uvm/uvm_vnode.c | 7 +++--
tests/lib/libc/sys/t_mmap.c | 54 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 56 insertions(+), 5 deletions(-)
diffs (120 lines):
diff -r 0c76036e220f -r c2b5b2f2a877 sys/uvm/uvm_vnode.c
--- a/sys/uvm/uvm_vnode.c Mon Jun 11 20:57:52 2012 +0000
+++ b/sys/uvm/uvm_vnode.c Mon Jun 11 21:25:02 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_vnode.c,v 1.97 2011/09/06 16:41:55 matt Exp $ */
+/* $NetBSD: uvm_vnode.c,v 1.97.8.1 2012/06/11 21:25:02 riz Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.97 2011/09/06 16:41:55 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.97.8.1 2012/06/11 21:25:02 riz Exp $");
#include "opt_uvmhist.h"
@@ -170,7 +170,8 @@
UVMHIST_LOG(ubchist, "vp %p off 0x%x", vp, (int)offset, 0,0);
- if ((access_type & VM_PROT_WRITE) == 0 && (flags & PGO_LOCKED) == 0) {
+ if (vp->v_type == VREG && (access_type & VM_PROT_WRITE) == 0
+ && (flags & PGO_LOCKED) == 0) {
vn_ra_allocctx(vp);
uvm_ra_request(vp->v_ractx, advice, uobj, offset,
*npagesp << PAGE_SHIFT);
diff -r 0c76036e220f -r c2b5b2f2a877 tests/lib/libc/sys/t_mmap.c
--- a/tests/lib/libc/sys/t_mmap.c Mon Jun 11 20:57:52 2012 +0000
+++ b/tests/lib/libc/sys/t_mmap.c Mon Jun 11 21:25:02 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.2 2011/07/14 11:08:45 jruoho Exp $ */
+/* $NetBSD: t_mmap.c,v 1.2.4.1 2012/06/11 21:25:02 riz Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mmap.c,v 1.2 2011/07/14 11:08:45 jruoho Exp $");
+__RCSID("$NetBSD: t_mmap.c,v 1.2.4.1 2012/06/11 21:25:02 riz Exp $");
#include <sys/param.h>
#include <sys/mman.h>
@@ -67,9 +67,12 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <paths.h>
+#include <machine/disklabel.h>
static long page = 0;
static char path[] = "mmap";
@@ -152,6 +155,52 @@
_exit(signo);
}
+ATF_TC(mmap_block);
+ATF_TC_HEAD(mmap_block, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test mmap(2) with a block device");
+ atf_tc_set_md_var(tc, "require.user", "root");
+}
+
+ATF_TC_BODY(mmap_block, tc)
+{
+ static const int mib[] = { CTL_HW, HW_DISKNAMES };
+ static const unsigned int miblen = __arraycount(mib);
+ char *map, *dk, *drives, dev[PATH_MAX];
+ size_t len;
+ int fd = -1;
+
+ atf_tc_expect_signal(SIGSEGV, "mmap of block devices does not work "
+ "(PR kern/38889)");
+
+ ATF_REQUIRE(sysctl(mib, miblen, NULL, &len, NULL, 0) == 0);
+ drives = malloc(len);
+ ATF_REQUIRE(drives != NULL);
+ ATF_REQUIRE(sysctl(mib, miblen, drives, &len, NULL, 0) == 0);
+ for (dk = strtok(drives, " "); dk != NULL; dk = strtok(NULL, " ")) {
+ sprintf(dev, _PATH_DEV "%s%c", dk, 'a'+RAW_PART);
+ fprintf(stderr, "trying: %s\n", dev);
+
+ if ((fd = open(dev, O_RDONLY)) >= 0) {
+ (void)fprintf(stderr, "using %s\n", dev);
+ break;
+ }
+ }
+ free(drives);
+
+ if (fd < 0)
+ atf_tc_skip("failed to find suitable block device");
+
+ map = mmap(NULL, 4096, PROT_READ, MAP_FILE, fd, 0);
+ ATF_REQUIRE(map != MAP_FAILED);
+
+ (void)fprintf(stderr, "first byte %x\n", *map);
+ ATF_REQUIRE(close(fd) == 0);
+ (void)fprintf(stderr, "first byte %x\n", *map);
+
+ ATF_REQUIRE(munmap(map, 4096) == 0);
+}
+
ATF_TC(mmap_err);
ATF_TC_HEAD(mmap_err, tc)
{
@@ -444,6 +493,7 @@
page = sysconf(_SC_PAGESIZE);
ATF_REQUIRE(page >= 0);
+ ATF_TP_ADD_TC(tp, mmap_block);
ATF_TP_ADD_TC(tp, mmap_err);
ATF_TP_ADD_TC(tp, mmap_loan);
ATF_TP_ADD_TC(tp, mmap_prot_1);
Home |
Main Index |
Thread Index |
Old Index