* 2. Emulating a reasonable SO_PEERSEC across machines
* 3. Testing addition of sk_policy's with security context via setsockopt
*/
+#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
goto out;
/*
- * Does the subject have permission to set security context?
+ * Does the subject have permission to set security or permission to
+ * do the relabel?
+ * Must be permitted to relabel from default socket type (process type)
+ * to specified context
*/
rc = avc_has_perm(tsec->sid, ctx->ctx_sid,
SECCLASS_ASSOCIATION,
kfree(ctx);
}
-/*
- * LSM hook implementation that authorizes deletion of labeled policies.
- */
-int selinux_xfrm_policy_delete(struct xfrm_policy *xp)
-{
- struct task_security_struct *tsec = current->security;
- struct xfrm_sec_ctx *ctx = xp->security;
- int rc = 0;
-
- if (ctx)
- rc = avc_has_perm(tsec->sid, ctx->ctx_sid,
- SECCLASS_ASSOCIATION,
- ASSOCIATION__SETCONTEXT, NULL);
-
- return rc;
-}
-
/*
* LSM hook implementation that allocs and transfers sec_ctx spec to
* xfrm_state.
return SECSID_NULL;
}
- /*
- * LSM hook implementation that authorizes deletion of labeled SAs.
- */
-int selinux_xfrm_state_delete(struct xfrm_state *x)
-{
- 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);
-
- return rc;
-}
-
/*
* LSM hook that controls access to unlabelled packets. If
* a xfrm_state is authorizable (defined by macro) then it was
struct xfrm_state *x = dst_test->xfrm;
if (x && selinux_authorizable_xfrm(x))
- goto out;
+ goto accept;
}
}
rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION,
ASSOCIATION__SENDTO, NULL);
-out:
- return rc;
+ if (rc)
+ goto drop;
+
+accept:
+ return NF_ACCEPT;
+
+drop:
+ return NF_DROP;
}