/* LSM hook implementation that authorizes deletion of labeled SAs.  */
int selinux_xfrm_state_delete(struct xfrm_state *x)
/* LSM hook implementation that authorizes deletion of labeled SAs.  */
int selinux_xfrm_state_delete(struct xfrm_state *x)
{
	const struct task_security_struct *tsec = current_security();
	struct xfrm_sec_ctx *ctx = x->security;
	int rc = 0;
	if (ctx) {
		rc = avc_has_perm(tsec->sid, ctx->ctx_sid,
				  SECCLASS_ASSOCIATION,
				  ASSOCIATION__SETCONTEXT, NULL);
		if (rc == 0)
			atomic_dec(&selinux_xfrm_refcount);
	}
	return rc;
}