From owner-p4-projects@FreeBSD.ORG Sun Jun 7 09:43:57 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CC575106566C; Sun, 7 Jun 2009 09:43:56 +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 8A4611065670 for ; Sun, 7 Jun 2009 09:43:56 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 5C0D18FC12 for ; Sun, 7 Jun 2009 09:43:56 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n579huZC076268 for ; Sun, 7 Jun 2009 09:43:56 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n579hu3O076266 for perforce@freebsd.org; Sun, 7 Jun 2009 09:43:56 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 7 Jun 2009 09:43:56 GMT Message-Id: <200906070943.n579hu3O076266@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 163694 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jun 2009 09:43:57 -0000 http://perforce.freebsd.org/chv.cgi?CH=163694 Change 163694 by rwatson@rwatson_freebsd_capabilities on 2009/06/07 09:43:20 Fix reference management for capability vs. underlying file descriptor, required in the new world order of lock-free file descriptor reference acquisition. Fix the non-CAPABILITIES case to return VM_PROT_ALL for the maxprot mask, or mprotect(2) will fail in the runtime linker. Affected files ... .. //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_descrip.c#24 edit .. //depot/projects/trustedbsd/capabilities/src/sys/kern/sys_capability.c#24 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_descrip.c#24 (text+ko) ==== @@ -85,6 +85,7 @@ #include #include +#include #include @@ -2200,13 +2201,22 @@ } /* - * Hold the new file descriptor and drop the capability file - * descriptor; after this point fp refers to the new object. + * If cap_fextract() returned a different file descriptor + * than was passed in, drop the original capability and hold + * the new descriptor. fp after this point refers to the + * actual object, not the capability. */ - fhold(fp_fromcap); - fdrop(fp, td); - fp = fp_fromcap; -#endif + if (fp != fp_fromcap) { + fhold(fp_fromcap); + fdrop(fp, td); + fp = fp_fromcap; + } +#else /* !CAPABILITIES */ + KASSERT(fp->f_type != DTYPE_CAPABILITY, + ("_fget: saw capability")); + if (maxprotp != NULL) + *maxprotp = VM_PROT_ALL; +#endif /* CAPABILITIES */ if ((flags == FREAD && (fp->f_flag & FREAD) == 0) || (flags == FWRITE && (fp->f_flag & FWRITE) == 0)) { fdrop(fp, td); ==== //depot/projects/trustedbsd/capabilities/src/sys/kern/sys_capability.c#24 (text+ko) ==== @@ -50,7 +50,7 @@ #include "opt_capabilities.h" #include -__FBSDID("$P4: //depot/projects/trustedbsd/capabilities/src/sys/kern/sys_capability.c#23 $"); +__FBSDID("$P4: //depot/projects/trustedbsd/capabilities/src/sys/kern/sys_capability.c#24 $"); #include #include