Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323092
b: refs/heads/master
c: ecd7918
h: refs/heads/master
v: v3
  • Loading branch information
Mathias Krause authored and David S. Miller committed Sep 20, 2012
1 parent fce2211 commit 30d82a0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 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: 1f86840f897717f86d523a13e99a447e6a5d2fa5
refs/heads/master: ecd7918745234e423dd87fcc0c077da557909720
2 changes: 2 additions & 0 deletions trunk/include/linux/xfrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct xfrm_replay_state {
__u32 bitmap;
};

#define XFRMA_REPLAY_ESN_MAX 4096

struct xfrm_replay_state_esn {
unsigned int bmp_len;
__u32 oseq;
Expand Down
31 changes: 25 additions & 6 deletions trunk/net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,21 @@ static inline int verify_replay(struct xfrm_usersa_info *p,
struct nlattr **attrs)
{
struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL];
struct xfrm_replay_state_esn *rs;

if ((p->flags & XFRM_STATE_ESN) && !rt)
return -EINVAL;
if (p->flags & XFRM_STATE_ESN) {
if (!rt)
return -EINVAL;

rs = nla_data(rt);

if (rs->bmp_len > XFRMA_REPLAY_ESN_MAX / sizeof(rs->bmp[0]) / 8)
return -EINVAL;

if (nla_len(rt) < xfrm_replay_state_esn_len(rs) &&
nla_len(rt) != sizeof(*rs))
return -EINVAL;
}

if (!rt)
return 0;
Expand Down Expand Up @@ -370,14 +382,15 @@ static inline int xfrm_replay_verify_len(struct xfrm_replay_state_esn *replay_es
struct nlattr *rp)
{
struct xfrm_replay_state_esn *up;
int ulen;

if (!replay_esn || !rp)
return 0;

up = nla_data(rp);
ulen = xfrm_replay_state_esn_len(up);

if (xfrm_replay_state_esn_len(replay_esn) !=
xfrm_replay_state_esn_len(up))
if (nla_len(rp) < ulen || xfrm_replay_state_esn_len(replay_esn) != ulen)
return -EINVAL;

return 0;
Expand All @@ -388,22 +401,28 @@ static int xfrm_alloc_replay_state_esn(struct xfrm_replay_state_esn **replay_esn
struct nlattr *rta)
{
struct xfrm_replay_state_esn *p, *pp, *up;
int klen, ulen;

if (!rta)
return 0;

up = nla_data(rta);
klen = xfrm_replay_state_esn_len(up);
ulen = nla_len(rta) >= klen ? klen : sizeof(*up);

p = kmemdup(up, xfrm_replay_state_esn_len(up), GFP_KERNEL);
p = kzalloc(klen, GFP_KERNEL);
if (!p)
return -ENOMEM;

pp = kmemdup(up, xfrm_replay_state_esn_len(up), GFP_KERNEL);
pp = kzalloc(klen, GFP_KERNEL);
if (!pp) {
kfree(p);
return -ENOMEM;
}

memcpy(p, up, ulen);
memcpy(pp, up, ulen);

*replay_esn = p;
*preplay_esn = pp;

Expand Down

0 comments on commit 30d82a0

Please sign in to comment.