socsvn commit: r268654 - in soc2014/op/tests/smap-tester: kmod smap-test

op at FreeBSD.org op at FreeBSD.org
Mon May 26 16:46:14 UTC 2014


Author: op
Date: Mon May 26 16:46:12 2014
New Revision: 268654
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=268654

Log:
  added simple test case: print out the user-space buffer address
  
  Signed-off-by: Oliver Pinter <oliver.pntr at gmail.com>
  
  

Modified:
  soc2014/op/tests/smap-tester/kmod/smap-tester-vuln-kld.c
  soc2014/op/tests/smap-tester/smap-test/smap-test.c

Modified: soc2014/op/tests/smap-tester/kmod/smap-tester-vuln-kld.c
==============================================================================
--- soc2014/op/tests/smap-tester/kmod/smap-tester-vuln-kld.c	Mon May 26 15:54:31 2014	(r268653)
+++ soc2014/op/tests/smap-tester/kmod/smap-tester-vuln-kld.c	Mon May 26 16:46:12 2014	(r268654)
@@ -70,6 +70,47 @@
     "L", "user-space address");
 
 
+static int
+sysctl_debug_smap_test0(SYSCTL_HANDLER_ARGS)
+{
+	int error=0;
+	long val;
+
+	if(!allow_tests) {
+		printf("{-} tests are disabled\n");
+		uprintf("\n{-} tests are disabled\n");
+		return (ENOSYS);
+	}
+
+	error = sysctl_handle_long(oidp, &val, 0, req);
+	if (error != 0 || req->newptr == NULL) {
+		return (error);
+	}
+
+	switch (val) {
+	case	0:
+		break;
+	case	1:
+		printf("{#}derefable user-space memory region from kernel\n");
+		uprintf("\n{#}derefable user-space memory region from kernel\n");
+
+		uprintf("{-} %p\n", us_addr);
+		val = 0;
+		break;
+	default:
+		val = 0;
+		return (EINVAL);
+		break;
+	}
+
+	return (error);
+}
+
+SYSCTL_PROC(_debug_smap, OID_AUTO, test0,
+    CTLTYPE_LONG | CTLFLAG_RW | CTLFLAG_ANYBODY,
+    0, 0, sysctl_debug_smap_test0,
+    "L", "print out the userspace buffer address");
+
 
 static int
 smap_tester_vuln_kld_loader(struct module *m __unused, int what, void *arg __unused)

Modified: soc2014/op/tests/smap-tester/smap-test/smap-test.c
==============================================================================
--- soc2014/op/tests/smap-tester/smap-test/smap-test.c	Mon May 26 15:54:31 2014	(r268653)
+++ soc2014/op/tests/smap-tester/smap-test/smap-test.c	Mon May 26 16:46:12 2014	(r268654)
@@ -18,6 +18,7 @@
 	test_prepare();
 	test_allow();
 
+	test_0();
 
 	test_destroy();
 
@@ -40,7 +41,7 @@
 	}
 
 	/* take the user-space address */
-	us_addr = (long)(void *)us_buf;
+	us_addr = (void *)us_buf;
 	printf("[+] debug.smap.us_addr = %p\n", us_addr);
 
 	/* read the old sysctl value */
@@ -94,5 +95,20 @@
 		printf("[-] sysctl error - unable to set test agreement\n");
 		exit(4);
 	}
-	printf("[+] debug.smap.agreement_string = %s\n", s);
+	printf("[+] debug.smap.agreement_string = %s\n\n", s);
+}
+
+
+void
+test_0(void)
+{
+	long val=1;
+	int error;
+
+	sysctlbyname("debug.smap.test0", NULL, 0, &val, sizeof(val));
+	if (error != 0) {
+		printf("[-] sysctl error - unable to set test0\n");
+		exit(5);
+	}
+	printf("[+] debug.smap.test0 done\n");
 }


More information about the svn-soc-all mailing list