]> git.saurik.com Git - apple/xnu.git/blobdiff - security/mac_internal.h
xnu-4570.1.46.tar.gz
[apple/xnu.git] / security / mac_internal.h
index 6e8ae3d2a803af504fc42c2b7c3ede4ec55449a5..0f034d23fdab8ae11851f55d488f3b1150d35253 100644 (file)
 #ifndef _SECURITY_MAC_INTERNAL_H_
 #define _SECURITY_MAC_INTERNAL_H_
 
+#ifndef PRIVATE
+#warning "MAC policy is not KPI, see Technical Q&A QA1574, this header will be removed in next version"
+#endif
+
 #include <string.h>
 #include <sys/param.h>
 #include <sys/queue.h>
@@ -75,7 +79,6 @@
 #include <security/mac_policy.h>
 #include <security/mac_data.h>
 #include <sys/sysctl.h>
-#include <kern/wait_queue.h>
 #include <kern/locks.h>
 #include <sys/kernel.h>
 #include <sys/lock.h>
@@ -135,47 +138,12 @@ struct mac_label_element {
 
 LIST_HEAD(mac_label_element_list_t, mac_label_element);
 
-/*
- * Journal operations
- */
-
-#define        MLJ_TYPE_PORT           1
-#define        MLJ_TYPE_TASK           2
-
-#define        MLJ_PORT_OP_INIT        0x0001
-#define        MLJ_PORT_OP_CREATE_K    0x0002
-#define        MLJ_PORT_OP_CREATE      0x0004
-#define        MLJ_PORT_OP_UPDATE      0x0008
-
-#define        MLJ_TASK_OP_INIT        0x0001
-#define        MLJ_TASK_OP_CREATE_K    0x0002
-
-struct mac_label_journal {
-       struct label *l;
-       int type;
-       int ops;
-
-       int kotype;     /* Kernel Port */
-
-       TAILQ_ENTRY(mac_label_journal) link;
-};
-TAILQ_HEAD(mac_label_journal_list_t, mac_label_journal);
-
-int    mac_label_journal_add   (struct label *, int);
-int    mac_label_journal_remove(struct label *);
-struct mac_label_journal *
-       mac_label_journal_find  (struct label *);
-int    mac_label_journal       (struct label *, int, ...);
-void   mac_label_journal_replay(void);
-
-
 /*
  * MAC Framework global variables.
  */
 
 extern struct mac_label_element_list_t mac_label_element_list;
 extern struct mac_label_element_list_t mac_static_label_element_list;
-extern struct mac_label_journal_list_t mac_label_journal_list;
 
 extern struct mac_policy_list mac_policy_list;
 
@@ -184,8 +152,6 @@ extern struct mac_policy_list mac_policy_list;
  * at all in the system.
  */
 extern unsigned int mac_device_enforce;
-extern unsigned int mac_file_enforce;
-extern unsigned int mac_iokit_enforce;
 extern unsigned int mac_pipe_enforce;
 extern unsigned int mac_posixsem_enforce;
 extern unsigned int mac_posixshm_enforce;
@@ -198,52 +164,37 @@ extern unsigned int mac_sysvshm_enforce;
 extern unsigned int mac_vm_enforce;
 extern unsigned int mac_vnode_enforce;
 
-#if CONFIG_MACF_MACH
-extern unsigned int mac_port_enforce;
-extern unsigned int mac_task_enforce;
-#endif
-
 #if CONFIG_MACF_NET
 extern unsigned int mac_label_mbufs;
 #endif
 
 extern unsigned int mac_label_vnodes;
 
-static int mac_proc_check_enforce(proc_t p, int enforce_flag);
+static bool mac_proc_check_enforce(proc_t p);
 
-static __inline__ int mac_proc_check_enforce(proc_t p, int enforce_flags)
+static __inline__ bool mac_proc_check_enforce(proc_t p)
 {
 #if CONFIG_MACF
-       return ((p->p_mac_enforce & enforce_flags) != 0);
+       // Don't apply policies to the kernel itself.
+       return (p != kernproc);
 #else
-       return 0;
-#endif
+#pragma unused(p)
+       return false;
+#endif // CONFIG_MACF
 }
 
-static int mac_context_check_enforce(vfs_context_t ctx, int enforce_flags);
-static void mac_context_set_enforce(vfs_context_t ctx, int enforce_flags);
+static bool mac_cred_check_enforce(kauth_cred_t cred);
 
-static __inline__ int mac_context_check_enforce(vfs_context_t ctx, int enforce_flags)
+static __inline__ bool mac_cred_check_enforce(kauth_cred_t cred)
 {
-       proc_t proc = vfs_context_proc(ctx);
-
-       if (proc == NULL)
-               return 0;
-
-       return (mac_proc_check_enforce(proc, enforce_flags));
-}
-
-static __inline__ void mac_context_set_enforce(vfs_context_t ctx, int enforce_flags)
-{
-       proc_t proc = vfs_context_proc(ctx);
-
-       if (proc == NULL)
-               return;
-
-       mac_proc_set_enforce(proc, enforce_flags);
+#if CONFIG_MACF
+       return (cred != proc_ucred(kernproc));
+#else
+#pragma unused(p)
+       return false;
+#endif // CONFIG_MACF
 }
 
-
 /*
  * MAC Framework infrastructure functions.
  */
@@ -267,7 +218,6 @@ int   mac_check_structmac_consistent(struct mac *mac);
 #endif
        
 int mac_cred_label_externalize(struct label *, char *e, char *out, size_t olen, int flags);
-int mac_lctx_label_externalize(struct label *, char *e, char *out, size_t olen);
 #if CONFIG_MACF_SOCKET
 int mac_socket_label_externalize(struct label *, char *e, char *out, size_t olen);
 #endif /* CONFIG_MACF_SOCKET */
@@ -276,7 +226,6 @@ int mac_pipe_label_externalize(struct label *label, char *elements,
  char *outbuf, size_t outbuflen);
 
 int mac_cred_label_internalize(struct label *label, char *string);
-int mac_lctx_label_internalize(struct label *label, char *string);
 #if CONFIG_MACF_SOCKET
 int mac_socket_label_internalize(struct label *label, char *string);
 #endif /* CONFIG_MACF_SOCKET */
@@ -449,8 +398,6 @@ struct __mac_get_pid_args;
 struct __mac_get_proc_args;
 struct __mac_set_proc_args;
 struct __mac_get_lcid_args;
-struct __mac_get_lctx_args;
-struct __mac_set_lctx_args;
 struct __mac_get_fd_args;
 struct __mac_get_file_args;
 struct __mac_get_link_args;