Module Name:    src
Committed By:   christos
Date:           Sat Jan 14 20:51:13 UTC 2017

Modified Files:
        src/tests/lib/libc/sys: t_mincore.c

Log Message:
Pr/51866: Ngie Cooper: fix leak and release limit on memory to prevent
false positives with mlock/mmap


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/sys/t_mincore.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/t_mincore.c
diff -u src/tests/lib/libc/sys/t_mincore.c:1.9 src/tests/lib/libc/sys/t_mincore.c:1.10
--- src/tests/lib/libc/sys/t_mincore.c:1.9	Tue Jan 10 17:36:29 2017
+++ src/tests/lib/libc/sys/t_mincore.c	Sat Jan 14 15:51:13 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $ */
+/* $NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $");
+__RCSID("$NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $");
 
 #include <sys/mman.h>
 #include <sys/stat.h>
@@ -139,6 +139,7 @@ ATF_TC_WITH_CLEANUP(mincore_resid);
 ATF_TC_HEAD(mincore_resid, tc)
 {
 	atf_tc_set_md_var(tc, "descr", "Test page residency with mincore(2)");
+	atf_tc_set_md_var(tc, "require.user", "root");
 }
 
 ATF_TC_BODY(mincore_resid, tc)
@@ -150,6 +151,11 @@ ATF_TC_BODY(mincore_resid, tc)
 	struct rlimit rlim;
 
 	ATF_REQUIRE(getrlimit(RLIMIT_MEMLOCK, &rlim) == 0);
+	/*
+	 * Bump the mlock limit to unlimited so the rest of the testcase
+	 * passes instead of failing on the mlock call.
+	 */
+	rlim.rlim_max = RLIM_INFINITY;
 	rlim.rlim_cur = rlim.rlim_max;
 	ATF_REQUIRE(setrlimit(RLIMIT_MEMLOCK, &rlim) == 0);
 
@@ -250,6 +256,7 @@ ATF_TC_BODY(mincore_resid, tc)
 	(void)munmap(addr2, npgs * page);
 	(void)munmap(addr3, npgs * page);
 	(void)unlink(path);
+	free(buf);
 }
 
 ATF_TC_CLEANUP(mincore_resid, tc)

Reply via email to