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));
79 struct xfrm_sec_ctx *ctx = NULL;
91 ctx = kmalloc(struct_size(ctx, ctx_str, str_len + 1), gfp);
92 if (!ctx)
95 ctx->ctx_doi = XFRM_SC_DOI_LSM;
96 ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
97 ctx->ctx_len = str_len;
98 memcpy(ctx->ctx_str, &uctx[1], str_len);
99 ctx->ctx_str[str_len] = '\0';
100 rc = security_context_to_sid(ctx->ctx_str, str_len,
101 &ctx->ctx_sid, gfp);
105 rc = avc_has_perm(current_sid(), ctx->ctx_sid,
110 *ctxp = ctx;
115 kfree(ctx);
122 static void selinux_xfrm_free(struct xfrm_sec_ctx *ctx)
124 if (!ctx)
128 kfree(ctx);
134 static int selinux_xfrm_delete(struct xfrm_sec_ctx *ctx)
136 if (!ctx)
139 return avc_has_perm(current_sid(), ctx->ctx_sid,
148 int selinux_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
154 if (!ctx)
158 if (!selinux_authorizable_ctx(ctx))
161 rc = avc_has_perm(fl_secid, ctx->ctx_sid,
233 struct xfrm_sec_ctx *ctx = x->security;
236 sid_session = ctx->ctx_sid;
239 } else if (sid_session != ctx->ctx_sid) {
311 void selinux_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
313 selinux_xfrm_free(ctx);
319 int selinux_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
321 return selinux_xfrm_delete(ctx);
342 struct xfrm_sec_ctx *ctx;
357 ctx = kmalloc(struct_size(ctx, ctx_str, str_len), GFP_ATOMIC);
358 if (!ctx) {
363 ctx->ctx_doi = XFRM_SC_DOI_LSM;
364 ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
365 ctx->ctx_sid = secid;
366 ctx->ctx_len = str_len;
367 memcpy(ctx->ctx_str, ctx_str, str_len);
369 x->security = ctx;
411 struct xfrm_sec_ctx *ctx = x->security;
412 peer_sid = ctx->ctx_sid;