]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/sys/spawn_internal.h
xnu-3248.50.21.tar.gz
[apple/xnu.git] / bsd / sys / spawn_internal.h
index 7054f6bb966cacb9aed4adf69fbbbd22850cbc9d..e86e6c2fdd7c8582a54f39da1b321717c8daf4cc 100644 (file)
 #define        _SYS_SPAWN_INTERNAL_H_
 
 #include <sys/_types.h>                /* __offsetof(), __darwin_size_t */
+#include <sys/param.h>
 #include <sys/syslimits.h>     /* PATH_MAX */
 #include <sys/spawn.h>
 #include <mach/machine.h>
 #include <mach/port.h>
 #include <mach/exception_types.h>
+#include <mach/coalition.h>    /* COALITION_NUM_TYPES */
 
 /*
  * Allowable posix_spawn() port action types
@@ -117,6 +119,44 @@ typedef struct _posix_spawn_mac_policy_extensions {
 
 #define PS_MAC_EXTENSIONS_INIT_COUNT   2
 
+/*
+ * Coalition posix spawn attributes
+ */
+struct _posix_spawn_coalition_info {
+       struct {
+               uint64_t psci_id;
+               uint32_t psci_role;
+               uint32_t psci_reserved1;
+               uint64_t psci_reserved2;
+       } psci_info[COALITION_NUM_TYPES];
+};
+
+/*
+ * Persona attributes
+ */
+struct _posix_spawn_persona_info {
+       uid_t    pspi_id;       /* persona ID (unix UID) */
+       uint32_t pspi_flags;    /* spawn persona flags */
+       uid_t    pspi_uid;      /* alternate posix/unix UID  */
+       gid_t    pspi_gid;      /* alternate posix/unix GID */
+       uint32_t pspi_ngroups;  /* alternate advisory groups */
+       gid_t    pspi_groups[NGROUPS];
+       uid_t    pspi_gmuid;    /* group membership UID */
+};
+
+#define POSIX_SPAWN_PERSONA_FLAGS_NONE     0x0
+#define POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE 0x1
+#define POSIX_SPAWN_PERSONA_FLAGS_VERIFY   0x2
+
+#define POSIX_SPAWN_PERSONA_ALL_FLAGS \
+       (POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE \
+        | POSIX_SPAWN_PERSONA_FLAGS_VERIFY \
+       )
+
+#define POSIX_SPAWN_PERSONA_UID           0x00010000
+#define POSIX_SPAWN_PERSONA_GID           0x00020000
+#define POSIX_SPAWN_PERSONA_GROUPS        0x00040000
+
 
 /*
  * A posix_spawnattr structure contains all of the attribute elements that
@@ -124,6 +164,7 @@ typedef struct _posix_spawn_mac_policy_extensions {
  * presence of a bit in the flags field.  All fields are initialized to the
  * appropriate default values by posix_spawnattr_init().
  */
+
 typedef struct _posix_spawnattr {
        short           psa_flags;              /* spawn attribute flags */
        short           flags_padding;  /* get the flags to be int aligned */
@@ -135,15 +176,16 @@ typedef struct _posix_spawnattr {
        int             psa_apptype;            /* app type and process spec behav */
        uint64_t        psa_cpumonitor_percent; /* CPU usage monitor percentage */
        uint64_t        psa_cpumonitor_interval; /* CPU usage monitor interval, in seconds */
-       uint64_t        psa_coalitionid;        /* coalition to spawn into */
+       uint64_t        psa_reserved;
 
-       short       psa_jetsam_flags; /* jetsam flags */
-       short           short_padding;  /* Padding for alignment issues */
-       int         psa_priority;   /* jetsam relative importance */
-       int         psa_high_water_mark; /* jetsam resident page count limit */
-       int             int_padding;    /* Padding for alignment issues */
+       short       psa_jetsam_flags;           /* jetsam flags */
+       short           short_padding;          /* Padding for alignment issues */
+       int         psa_priority;               /* jetsam relative importance */
+       int         psa_memlimit_active;        /* jetsam memory limit (in MB) when process is active */
+       int         psa_memlimit_inactive;      /* jetsam memory limit (in MB) when process is inactive */
 
        uint64_t        psa_qos_clamp;          /* QoS Clamp to set on the new process */
+       uint64_t        psa_darwin_role;           /* PRIO_DARWIN_ROLE to set on the new process */
 
        /*
         * NOTE: Extensions array pointers must stay at the end so that
@@ -152,16 +194,25 @@ typedef struct _posix_spawnattr {
         */
         _posix_spawn_port_actions_t    psa_ports; /* special/exception ports */
        _posix_spawn_mac_policy_extensions_t psa_mac_extensions; /* MAC policy-specific extensions. */
+       struct _posix_spawn_coalition_info *psa_coalition_info;  /* coalition info */
+       struct _posix_spawn_persona_info   *psa_persona_info;    /* spawn new process into given persona */
 } *_posix_spawnattr_t;
 
 /*
- * Jetsam flags
+ * Jetsam flags  eg: psa_jetsam_flags
  */
 #define        POSIX_SPAWN_JETSAM_SET                      0x8000
 
-#define        POSIX_SPAWN_JETSAM_USE_EFFECTIVE_PRIORITY   0x1
-#define        POSIX_SPAWN_JETSAM_HIWATER_BACKGROUND       0x2
-#define        POSIX_SPAWN_JETSAM_MEMLIMIT_FATAL           0x4
+#define        POSIX_SPAWN_JETSAM_USE_EFFECTIVE_PRIORITY       0x01
+#define        POSIX_SPAWN_JETSAM_HIWATER_BACKGROUND           0x02
+#define        POSIX_SPAWN_JETSAM_MEMLIMIT_FATAL               0x04  /* to be deprecated */
+
+/*
+ * Additional flags available for use with
+ * the posix_spawnattr_setjetsam_ext() call
+ */
+#define        POSIX_SPAWN_JETSAM_MEMLIMIT_ACTIVE_FATAL        0x04  /* if set, limit is fatal when the process is active   */
+#define        POSIX_SPAWN_JETSAM_MEMLIMIT_INACTIVE_FATAL      0x08  /* if set, limit is fatal when the process is inactive */
 
 /*
  * Deprecated posix_spawn psa_flags values
@@ -215,6 +266,10 @@ typedef struct _posix_spawnattr {
 #define POSIX_SPAWN_PROC_CLAMP_MAINTENANCE          0x00000003
 #define POSIX_SPAWN_PROC_CLAMP_LAST                 0x00000004
 
+/* Setting to indicate no change to darwin role */
+#define POSIX_SPAWN_DARWIN_ROLE_NONE                0x00000000
+/* Other possible values are specified by PRIO_DARWIN_ROLE in sys/resource.h */
+
 /*
  * Allowable posix_spawn() file actions
  */
@@ -308,7 +363,11 @@ struct _posix_spawn_args_desc {
        _posix_spawn_mac_policy_extensions_t
                                mac_extensions; /* pointer to policy-specific
                                                 * attributes */
+       __darwin_size_t coal_info_size;
+       struct _posix_spawn_coalition_info *coal_info;  /* pointer to coalition info */
 
+       __darwin_size_t persona_info_size;
+       struct _posix_spawn_persona_info   *persona_info;
 };
 
 #ifdef KERNEL
@@ -328,6 +387,10 @@ struct user32__posix_spawn_args_desc {
        uint32_t                port_actions;   /* pointer to block */
        uint32_t        mac_extensions_size;
        uint32_t        mac_extensions;
+       uint32_t        coal_info_size;
+       uint32_t        coal_info;
+       uint32_t        persona_info_size;
+       uint32_t        persona_info;
 };
 
 struct user__posix_spawn_args_desc {
@@ -339,6 +402,10 @@ struct user__posix_spawn_args_desc {
        user_addr_t             port_actions;   /* pointer to block */
        user_size_t     mac_extensions_size;    /* size of MAC-specific attrs. */
        user_addr_t     mac_extensions;         /* pointer to block */
+       user_size_t     coal_info_size;
+       user_addr_t     coal_info;
+       user_size_t     persona_info_size;
+       user_addr_t     persona_info;
 };