Skip to content

Commit

Permalink
selinux: cleanup selinux_xfrm_decode_session()
Browse files Browse the repository at this point in the history
Some basic simplification.

Signed-off-by: Paul Moore <pmoore@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
  • Loading branch information
Paul Moore authored and Eric Paris committed Jul 25, 2013
1 parent 4baabee commit e219369
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions security/selinux/xfrm.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,34 +215,35 @@ int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
*/
int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall)
{
u32 sid_session = SECSID_NULL;
struct sec_path *sp;

*sid = SECSID_NULL;

if (skb == NULL)
return 0;
goto out;

sp = skb->sp;
if (sp) {
int i, sid_set = 0;
int i;

for (i = sp->len-1; i >= 0; i--) {
for (i = sp->len - 1; i >= 0; i--) {
struct xfrm_state *x = sp->xvec[i];
if (selinux_authorizable_xfrm(x)) {
struct xfrm_sec_ctx *ctx = x->security;

if (!sid_set) {
*sid = ctx->ctx_sid;
sid_set = 1;

if (sid_session == SECSID_NULL) {
sid_session = ctx->ctx_sid;
if (!ckall)
break;
} else if (*sid != ctx->ctx_sid)
goto out;
} else if (sid_session != ctx->ctx_sid) {
*sid = SECSID_NULL;
return -EINVAL;
}
}
}
}

out:
*sid = sid_session;
return 0;
}

Expand Down

0 comments on commit e219369

Please sign in to comment.