/* Return 1 if the MLS fields in the security context structure  */
int mls_context_isvalid(struct policydb *p, struct context *c)
/* Return 1 if the MLS fields in the security context structure  */
int mls_context_isvalid(struct policydb *p, struct context *c)
{
	struct user_datum *usrdatum;
	if (!selinux_mls_enabled)
		return 1;
	if (!mls_range_isvalid(p, &c->range))
		return 0;
	if (c->role == OBJECT_R_VAL)
		return 1;
	if (!c->user || c->user > p->p_users.nprim)
		return 0;
	usrdatum = p->user_val_to_struct[c->user - 1];
	if (!mls_range_contains(usrdatum->range, c->range))
		return 0;
	return 1;
}