+ /*
+ * NB: Cannot use MAC_CHECK macro because we need a sequence point after
+ * calling exec_spawnattr_getmacpolicyinfo() and before passing the
+ * spawnattrlen as an argument to the hook.
+ */
+ {
+ struct mac_policy_conf *mpc;
+ u_int i;
+
+ error = 0;
+ for (i = 0; i< mac_policy_list.staticmax; i++) {
+ mpc = mac_policy_list.entries[i].mpc;
+ if (mpc == NULL)
+ continue;
+
+ mpo_cred_label_update_execve_t *hook = mpc->mpc_ops->mpo_cred_label_update_execve;
+ if (hook == NULL)
+ continue;
+
+ size_t spawnattrlen = 0;
+ void *spawnattr = exec_spawnattr_getmacpolicyinfo(macextensions, mpc->mpc_name, &spawnattrlen);
+
+ error = mac_error_select(hook(cred, new, vfs_context_proc(ctx), vp, offset, scriptvp,
+ vp->v_label, scriptvnodelabel, execl, csflags, spawnattr, spawnattrlen, disjoint),
+ error);
+ }
+ if (mac_policy_list_conditional_busy() != 0) {
+ for (; i <= mac_policy_list.maxindex; i++) {
+ mpc = mac_policy_list.entries[i].mpc;
+ if (mpc == NULL)
+ continue;
+
+ mpo_cred_label_update_execve_t *hook = mpc->mpc_ops->mpo_cred_label_update_execve;
+ if (hook == NULL)
+ continue;
+
+ size_t spawnattrlen = 0;
+ void *spawnattr = exec_spawnattr_getmacpolicyinfo(macextensions, mpc->mpc_name, &spawnattrlen);
+
+ error = mac_error_select(hook(cred, new, vfs_context_proc(ctx), vp, offset, scriptvp,
+ vp->v_label, scriptvnodelabel, execl, csflags, spawnattr, spawnattrlen, disjoint),
+ error);
+ }
+ mac_policy_list_unbusy();
+ }
+ }
+ *labelupdateerror = error;