From owner-svn-src-projects@FreeBSD.ORG Wed Feb 3 22:31:52 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2DB07106566B; Wed, 3 Feb 2010 22:31:52 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1D2D68FC14; Wed, 3 Feb 2010 22:31:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o13MVqfo027595; Wed, 3 Feb 2010 22:31:52 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o13MVqMf027593; Wed, 3 Feb 2010 22:31:52 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201002032231.o13MVqMf027593@svn.freebsd.org> From: Robert Watson Date: Wed, 3 Feb 2010 22:31:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203456 - projects/capabilities8/tools/tools/syscall_timing X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2010 22:31:52 -0000 Author: rwatson Date: Wed Feb 3 22:31:51 2010 New Revision: 203456 URL: http://svn.freebsd.org/changeset/base/203456 Log: Merge c174284 from the TrustedBSD Capabilities p4 branch to capabilities8: Micro-benchmarks for chroot() and setuid(). Sponsored by: Google, Inc. Modified: projects/capabilities8/tools/tools/syscall_timing/syscall_timing.c Modified: projects/capabilities8/tools/tools/syscall_timing/syscall_timing.c ============================================================================== --- projects/capabilities8/tools/tools/syscall_timing/syscall_timing.c Wed Feb 3 22:20:57 2010 (r203455) +++ projects/capabilities8/tools/tools/syscall_timing/syscall_timing.c Wed Feb 3 22:31:51 2010 (r203456) @@ -565,6 +565,38 @@ test_pdfork_exec(int num) benchmark_stop(); } +void +test_chroot(int num) +{ + int i; + + if (chroot("/") < 0) + err(-1, "test_chroot: chroot"); + benchmark_start(); + for (i = 0; i < num; i++) { + if (chroot("/") < 0) + err(-1, "test_chroot: chroot"); + } + benchmark_stop(); +} + +void +test_setuid(int num) +{ + uid_t uid; + int i; + + uid = getuid(); + if (setuid(uid) < 0) + err(-1, "test_setuid: setuid"); + benchmark_start(); + for (i = 0; i < num; i++) { + if (setuid(uid) < 0) + err(-1, "test_setuid: setuid"); + } + benchmark_stop(); +} + /* * A bit like sandbox, in that a process is forked, IPC ping-pong is done, * but with none of the sandboxing goo. @@ -773,6 +805,8 @@ static const struct test tests[] = { { "fork_exec", test_fork_exec }, { "vfork_exec", test_vfork_exec }, { "pdfork_exec", test_pdfork_exec }, + { "chroot", test_chroot }, + { "setuid", test_setuid }, { "pingpong", test_pingpong }, { "sandbox", test_sandbox }, };