From owner-svn-soc-all@FreeBSD.ORG Mon May 26 16:46:14 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3DEAEC7D for ; Mon, 26 May 2014 16:46:14 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 101822664 for ; Mon, 26 May 2014 16:46:14 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4QGkD7o015088 for ; Mon, 26 May 2014 16:46:13 GMT (envelope-from op@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.8/8.14.8/Submit) id s4QGkDVZ015078 for svn-soc-all@FreeBSD.org; Mon, 26 May 2014 16:46:13 GMT (envelope-from op@FreeBSD.org) Date: Mon, 26 May 2014 16:46:13 GMT Message-Id: <201405261646.s4QGkDVZ015078@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to op@FreeBSD.org using -f From: op@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r268654 - in soc2014/op/tests/smap-tester: kmod smap-test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 May 2014 16:46:14 -0000 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 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"); }