/* Returns 0 if current can wait for p, error code otherwise  */
static int smack_task_wait(struct task_struct *p)
/* Returns 0 if current can wait for p, error code otherwise  */
static int smack_task_wait(struct task_struct *p)
{
	struct smk_audit_info ad;
	char *sp = current_security();
	char *tsp = task_security(p);
	int rc;
	rc = smk_access(sp, tsp, MAY_WRITE, NULL);
	if (rc == 0)
		goto out_log;
	if (capable(CAP_MAC_OVERRIDE) || has_capability(p, CAP_MAC_OVERRIDE))
		rc = 0;
 out_log:
	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_TASK);
	smk_ad_setfield_u_tsk(&ad, p);
	smack_log(sp, tsp, MAY_WRITE, rc, &ad);
	return rc;
}