svn commit: r357766 - in head/sys: kern sys

Mateusz Guzik mjg at FreeBSD.org
Tue Feb 11 18:13:54 UTC 2020


Author: mjg
Date: Tue Feb 11 18:13:53 2020
New Revision: 357766
URL: https://svnweb.freebsd.org/changeset/base/357766

Log:
  capsicum: restore the cap_rights_contains symbol
  
  It is expected to be provided by libc.
  
  PR:		244033
  Reported by:	 Jan Kokemueller

Modified:
  head/sys/kern/subr_capability.c
  head/sys/sys/capsicum.h

Modified: head/sys/kern/subr_capability.c
==============================================================================
--- head/sys/kern/subr_capability.c	Tue Feb 11 18:03:45 2020	(r357765)
+++ head/sys/kern/subr_capability.c	Tue Feb 11 18:13:53 2020	(r357766)
@@ -394,3 +394,27 @@ cap_rights_remove(cap_rights_t *dst, const cap_rights_
 
 	return (dst);
 }
+
+#ifndef _KERNEL
+bool
+cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little)
+{
+	unsigned int i, n;
+
+	assert(CAPVER(big) == CAP_RIGHTS_VERSION_00);
+	assert(CAPVER(little) == CAP_RIGHTS_VERSION_00);
+	assert(CAPVER(big) == CAPVER(little));
+
+	n = CAPARSIZE(big);
+	assert(n >= CAPARSIZE_MIN && n <= CAPARSIZE_MAX);
+
+	for (i = 0; i < n; i++) {
+		if ((big->cr_rights[i] & little->cr_rights[i]) !=
+		    little->cr_rights[i]) {
+			return (false);
+		}
+	}
+
+	return (true);
+}
+#endif

Modified: head/sys/sys/capsicum.h
==============================================================================
--- head/sys/sys/capsicum.h	Tue Feb 11 18:03:45 2020	(r357765)
+++ head/sys/sys/capsicum.h	Tue Feb 11 18:13:53 2020	(r357766)
@@ -344,7 +344,7 @@ cap_rights_t *cap_rights_merge(cap_rights_t *dst, cons
 cap_rights_t *cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
 void __cap_rights_sysinit(void *arg);
 
-
+#ifdef _KERNEL
 /*
  * We only support one size to reduce branching.
  */
@@ -390,6 +390,9 @@ cap_check_inline_transient(const cap_rights_t *havep, 
 		return (1);
         return (0);
 }
+#else
+bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
+#endif
 
 __END_DECLS
 struct cap_rights_init_args {


More information about the svn-src-all mailing list