Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34397
b: refs/heads/master
c: 0d68162
h: refs/heads/master
i:
  34395: 81f66bc
v: v3
  • Loading branch information
Serge Hallyn authored and David S. Miller committed Sep 22, 2006
1 parent 90169e3 commit 4d88672
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e0d1caa7b0d5f02e4f34aa09c695d04251310c6c
refs/heads/master: 0d681623d30c6565e8b62889f3aa3f4d4662c3e8
43 changes: 28 additions & 15 deletions trunk/net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,25 +911,38 @@ static int copy_to_user_tmpl(struct xfrm_policy *xp, struct sk_buff *skb)
return -1;
}

static int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *skb)
static int copy_sec_ctx(struct xfrm_sec_ctx *s, struct sk_buff *skb)
{
if (xp->security) {
int ctx_size = sizeof(struct xfrm_sec_ctx) +
xp->security->ctx_len;
struct rtattr *rt = __RTA_PUT(skb, XFRMA_SEC_CTX, ctx_size);
struct xfrm_user_sec_ctx *uctx = RTA_DATA(rt);
int ctx_size = sizeof(struct xfrm_sec_ctx) + s->ctx_len;
struct rtattr *rt = __RTA_PUT(skb, XFRMA_SEC_CTX, ctx_size);
struct xfrm_user_sec_ctx *uctx = RTA_DATA(rt);

uctx->exttype = XFRMA_SEC_CTX;
uctx->len = ctx_size;
uctx->ctx_doi = s->ctx_doi;
uctx->ctx_alg = s->ctx_alg;
uctx->ctx_len = s->ctx_len;
memcpy(uctx + 1, s->ctx_str, s->ctx_len);
return 0;

uctx->exttype = XFRMA_SEC_CTX;
uctx->len = ctx_size;
uctx->ctx_doi = xp->security->ctx_doi;
uctx->ctx_alg = xp->security->ctx_alg;
uctx->ctx_len = xp->security->ctx_len;
memcpy(uctx + 1, xp->security->ctx_str, xp->security->ctx_len);
rtattr_failure:
return -1;
}

static inline int copy_to_user_state_sec_ctx(struct xfrm_state *x, struct sk_buff *skb)
{
if (x->security) {
return copy_sec_ctx(x->security, skb);
}
return 0;
}

rtattr_failure:
return -1;
static inline int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *skb)
{
if (xp->security) {
return copy_sec_ctx(xp->security, skb);
}
return 0;
}

static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr)
Expand Down Expand Up @@ -1710,7 +1723,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,

if (copy_to_user_tmpl(xp, skb) < 0)
goto nlmsg_failure;
if (copy_to_user_sec_ctx(xp, skb))
if (copy_to_user_state_sec_ctx(x, skb))
goto nlmsg_failure;

nlh->nlmsg_len = skb->tail - b;
Expand Down

0 comments on commit 4d88672

Please sign in to comment.