34 #include <linux/kernel.h>
37 #include <linux/types.h>
38 #include <linux/netfilter.h>
39 #include <linux/netfilter_ipv4.h>
40 #include <linux/netfilter_ipv6.h>
41 #include <linux/slab.h>
43 #include <linux/tcp.h>
71 static inline int selinux_authorizable_xfrm(
struct xfrm_state *
x)
73 return selinux_authorizable_ctx(x->
security);
87 if (!selinux_authorizable_ctx(ctx))
99 rc = avc_has_perm(fl_secid, sel_sid, SECCLASS_ASSOCIATION,
100 ASSOCIATION__POLMATCH,
132 if (!selinux_authorizable_xfrm(x))
138 if (fl->flowi_secid != state_sid)
141 rc = avc_has_perm(fl->flowi_secid, state_sid, SECCLASS_ASSOCIATION,
173 for (i = sp->
len-1; i >= 0; i--) {
175 if (selinux_authorizable_xfrm(x)) {
184 }
else if (*sid != ctx->
ctx_sid)
197 static int selinux_xfrm_sec_ctx_alloc(
struct xfrm_sec_ctx **ctxp,
218 *ctxp = ctx =
kmalloc(
sizeof(*ctx) +
244 SECCLASS_ASSOCIATION,
245 ASSOCIATION__SETCONTEXT,
NULL);
256 *ctxp = ctx =
kmalloc(
sizeof(*ctx) +
294 err = selinux_xfrm_sec_ctx_alloc(ctxp, uctx, 0);
317 memcpy(new_ctx, old_ctx,
sizeof(*new_ctx));
342 SECCLASS_ASSOCIATION,
343 ASSOCIATION__SETCONTEXT,
NULL);
362 err = selinux_xfrm_sec_ctx_alloc(&x->
security, uctx, secid);
388 SECCLASS_ASSOCIATION,
389 ASSOCIATION__SETCONTEXT,
NULL);
409 u32 sel_sid = SECINITSID_UNLABELED;
414 for (i = 0; i < sp->
len; i++) {
417 if (x && selinux_authorizable_xfrm(x)) {
432 rc = avc_has_perm(isec_sid, sel_sid, SECCLASS_ASSOCIATION,
433 ASSOCIATION__RECVFROM, ad);
456 for (dst_test = dst; dst_test !=
NULL;
457 dst_test = dst_test->
child) {
460 if (x && selinux_authorizable_xfrm(x))
486 rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION,
487 ASSOCIATION__SENDTO, ad);