Lines Matching refs:ctx
55 static inline int selinux_authorizable_ctx(struct xfrm_sec_ctx *ctx)
57 return (ctx &&
58 (ctx->ctx_doi == XFRM_SC_DOI_LSM) &&
59 (ctx->ctx_alg == XFRM_SC_ALG_SELINUX));
80 struct xfrm_sec_ctx *ctx = NULL;
92 ctx = kmalloc(struct_size(ctx, ctx_str, str_len + 1), gfp);
93 if (!ctx)
96 ctx->ctx_doi = XFRM_SC_DOI_LSM;
97 ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
98 ctx->ctx_len = str_len;
99 memcpy(ctx->ctx_str, &uctx[1], str_len);
100 ctx->ctx_str[str_len] = '\0';
101 rc = security_context_to_sid(ctx->ctx_str, str_len,
102 &ctx->ctx_sid, gfp);
106 rc = avc_has_perm(tsec->sid, ctx->ctx_sid,
111 *ctxp = ctx;
116 kfree(ctx);
123 static void selinux_xfrm_free(struct xfrm_sec_ctx *ctx)
125 if (!ctx)
129 kfree(ctx);
135 static int selinux_xfrm_delete(struct xfrm_sec_ctx *ctx)
139 if (!ctx)
142 return avc_has_perm(tsec->sid, ctx->ctx_sid,
151 int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
157 if (!ctx)
161 if (!selinux_authorizable_ctx(ctx))
164 rc = avc_has_perm(fl_secid, ctx->ctx_sid,
236 struct xfrm_sec_ctx *ctx = x->security;
239 sid_session = ctx->ctx_sid;
242 } else if (sid_session != ctx->ctx_sid) {
314 void selinux_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
316 selinux_xfrm_free(ctx);
322 int selinux_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
324 return selinux_xfrm_delete(ctx);
345 struct xfrm_sec_ctx *ctx;
360 ctx = kmalloc(struct_size(ctx, ctx_str, str_len), GFP_ATOMIC);
361 if (!ctx) {
366 ctx->ctx_doi = XFRM_SC_DOI_LSM;
367 ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
368 ctx->ctx_sid = secid;
369 ctx->ctx_len = str_len;
370 memcpy(ctx->ctx_str, ctx_str, str_len);
372 x->security = ctx;
414 struct xfrm_sec_ctx *ctx = x->security;
415 peer_sid = ctx->ctx_sid;