Date: Sun, 7 Jun 2009 09:43:56 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 163694 for review Message-ID: <200906070943.n579hu3O076266@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <security/audit/audit.h> #include <vm/uma.h> +#include <vm/vm.h> #include <ddb/ddb.h> @@ -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 <sys/cdefs.h> -__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 <sys/param.h> #include <sys/capability.h>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906070943.n579hu3O076266>