From owner-p4-projects@FreeBSD.ORG Tue Jan 26 00:49:15 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 67DDE106568D; Tue, 26 Jan 2010 00:49:15 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13F8E1065679 for ; Tue, 26 Jan 2010 00:49:15 +0000 (UTC) (envelope-from jona@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 00D478FC18 for ; Tue, 26 Jan 2010 00:49:15 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o0Q0nEOA056465 for ; Tue, 26 Jan 2010 00:49:14 GMT (envelope-from jona@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o0Q0nEGd056463 for perforce@freebsd.org; Tue, 26 Jan 2010 00:49:14 GMT (envelope-from jona@FreeBSD.org) Date: Tue, 26 Jan 2010 00:49:14 GMT Message-Id: <201001260049.o0Q0nEGd056463@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jona@FreeBSD.org using -f From: Jonathan Anderson To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 173714 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2010 00:49:15 -0000 http://p4web.freebsd.org/chv.cgi?CH=173714 Change 173714 by jona@jona-belle-freebsd8 on 2010/01/26 00:48:21 open(2) is now properly constrained (it always fails with EOPNOTSUPP), so we can allow the syscall for auditing / debugging purposes Affected files ... .. //depot/projects/trustedbsd/capabilities/src/lib/libcapability/Makefile#17 edit .. //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#26 edit .. //depot/projects/trustedbsd/capabilities/src/sys/kern/capabilities.conf#26 edit .. //depot/projects/trustedbsd/capabilities/src/sys/kern/init_sysent.c#46 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/lib/libcapability/Makefile#17 (text+ko) ==== @@ -9,7 +9,8 @@ libcapability_sandbox.c \ libcapability_sandbox_io.c \ libcapability_host.c \ - libcapability_host_io.c + libcapability_host_io.c \ + libcapability_registry.c INCS= libcapability.h ==== //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#26 (text+ko) ==== @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#25 $ + * $P4: //depot/projects/trustedbsd/capabilities/src/lib/libcapability/libcapability.h#26 $ */ #ifndef _LIBCAPABILITY_H_ @@ -53,6 +53,30 @@ }; /* + * A file descriptor "registry" + */ +struct lc_fdregistry_entry; +struct lc_fdregistry { + struct lc_fdregistry_entry *entries; /* registry entries */ + + unsigned int count; /* number of entries */ + unsigned int capacity; /* entries that we can hold */ +}; + +/* + * Registry operations + */ +struct lc_fdregistry* lc_fdregistry_new(void); +struct lc_fdregistry* lc_fdregistry_dup(const struct lc_fdregistry *orig); +void lc_fdregistry_free(struct lc_fdregistry *registry); + +int lc_fdregistry_add(const struct lc_fdregistry *reg, + const char *id, const char *name, int fd); + +int lc_fdregistry_lookup(const struct lc_fdregistry *reg, + const char *id, char **name, int *fdp); + +/* * Capability interfaces. */ int lc_limitfd(int fd, cap_rights_t rights); ==== //depot/projects/trustedbsd/capabilities/src/sys/kern/capabilities.conf#26 (text+ko) ==== @@ -38,7 +38,7 @@ ## - sys_exit(2), abort2(2) and close(2) are very important. ## - Sorted alphabetically, please keep it that way. ## -## $P4: //depot/projects/trustedbsd/capabilities/src/sys/kern/capabilities.conf#25 $ +## $P4: //depot/projects/trustedbsd/capabilities/src/sys/kern/capabilities.conf#26 $ ## ## @@ -467,6 +467,13 @@ renameat ## +## Allow entry into open(2). This system call will fail, since access to the global +## file namespace has been disallowed, but allowing entry into the syscall means +## that an audit trail will be generated (which is also very useful for debugging), +## +open + +## ## Allow poll(2), which will be scoped by capability rights. ## ## XXXRW: Perhaps we don't need the OpenBSD version? ==== //depot/projects/trustedbsd/capabilities/src/sys/kern/init_sysent.c#46 (text+ko) ==== @@ -39,7 +39,7 @@ { 0, (sy_call_t *)fork, AUE_FORK, NULL, 0, 0, SYF_CAPENABLED }, /* 2 = fork */ { AS(read_args), (sy_call_t *)read, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED }, /* 3 = read */ { AS(write_args), (sy_call_t *)write, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED }, /* 4 = write */ - { AS(open_args), (sy_call_t *)open, AUE_OPEN_RWTC, NULL, 0, 0, 0 }, /* 5 = open */ + { AS(open_args), (sy_call_t *)open, AUE_OPEN_RWTC, NULL, 0, 0, SYF_CAPENABLED }, /* 5 = open */ { AS(close_args), (sy_call_t *)close, AUE_CLOSE, NULL, 0, 0, SYF_CAPENABLED }, /* 6 = close */ { AS(wait_args), (sy_call_t *)wait4, AUE_WAIT4, NULL, 0, 0, 0 }, /* 7 = wait4 */ { compat(AS(ocreat_args),creat), AUE_CREAT, NULL, 0, 0, 0 }, /* 8 = old creat */