From owner-p4-projects@FreeBSD.ORG Mon Nov 12 16:08:01 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8AF31191; Mon, 12 Nov 2012 16:08:01 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4A52318F for ; Mon, 12 Nov 2012 16:08:01 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 15F158FC13 for ; Mon, 12 Nov 2012 16:08:01 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.5/8.14.5) with ESMTP id qACG80lG072986 for ; Mon, 12 Nov 2012 16:08:00 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.5/8.14.5/Submit) id qACG80Yl072983 for perforce@freebsd.org; Mon, 12 Nov 2012 16:08:00 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 12 Nov 2012 16:08:00 GMT Message-Id: <201211121608.qACG80Yl072983@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 219761 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Nov 2012 16:08:01 -0000 http://p4web.freebsd.org/@@219761?ac=10 Change 219761 by rwatson@rwatson_zenith_cl_cam_ac_uk on 2012/11/12 16:07:26 Do a bit more legwork so that we can try and convince ourselves that libraries linked into sandboxed code work; do this by linking in libmd. Provide a number of system call stubs depended on by the library, which mostly return ECAPMODE. Also provide an errno implementation. We will want to expand this example shortly to illustrate how capability-unaware code can copy in arguments and out return values via capabilities using utility routines, as will be required for libpng. Affected files ... .. //depot/projects/ctsrd/cheribsd/src/libexec/cheritest-helper/Makefile#5 edit .. //depot/projects/ctsrd/cheribsd/src/libexec/cheritest-helper/cheritest-helper.c#3 edit .. //depot/projects/ctsrd/cheribsd/src/libexec/cheritest-helper/malloc.c#1 add .. //depot/projects/ctsrd/cheribsd/src/libexec/cheritest-helper/stub.c#1 add Differences ... ==== //depot/projects/ctsrd/cheribsd/src/libexec/cheritest-helper/Makefile#5 (text+ko) ==== @@ -2,12 +2,26 @@ # $FreeBSD$ # PROG= cheritest-helper -SRCS= cheritest-helper.c chsbrt.S +SRCS= cheritest-helper.c \ + malloc.c \ + stub.c \ + chsbrt.S \ + memcpy.S \ + memset.S + LDFLAGS+= -Wl,--script=${.CURDIR}/sandbox.ld -nostdlib NO_MAN= #STRIP= +DPADD= ${LIBMD} +LDADD= -lmd + NO_SHARED= yes +# +# For libc files! +# +NO_WERROR= yes + FILESOWN= ${LIBOWN} FILESGRP= ${LIBGRP} FILESMODE= ${LIBMODE} @@ -24,6 +38,7 @@ cheritest-helper.dump: cheritest-helper objdump -xsSD ${.ALLSRC} > ${.TARGET} -.PATH: ${.CURDIR}/${MACHINE_ARCH} +.PATH: ${.CURDIR}/${MACHINE_ARCH} \ + ${.CURDIR}/../../lib/libc/string/${MACHINE_TARGET} .include ==== //depot/projects/ctsrd/cheribsd/src/libexec/cheritest-helper/cheritest-helper.c#3 (text+ko) ==== @@ -30,12 +30,27 @@ #include +#include + +#include + int invoke(register_t a0, register_t a1, register_t a2, register_t a3); +/* + * Sample sandboxed code. Calculate an MD5 checksum of the data arriving via + * c1, and place the checksum in c2. + * + * XXXRW: More to follow here. + */ int invoke(register_t a0 __unused, register_t a1 __unused, register_t a2 __unused, register_t a3 __unused) { + MD5_CTX md5context; + char buf[33]; + + MD5Init(&md5context); + MD5End(&md5context, buf); return (123456); }