Skip to content

Commit

Permalink
net/key/af_key.c: add range checks on ->sadb_x_policy_len
Browse files Browse the repository at this point in the history
Because sizeof() is size_t then if "len" is negative, it counts as a
large positive value.

The call tree looks like:
pfkey_sendmsg()
-> pfkey_process()
   -> pfkey_spdadd()
      -> parse_ipsecrequests()

Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Dan Carpenter authored and davem330 committed Oct 1, 2012
1 parent 862096a commit f674e72
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/key/af_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,9 @@ parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol)
int len = pol->sadb_x_policy_len*8 - sizeof(struct sadb_x_policy);
struct sadb_x_ipsecrequest *rq = (void*)(pol+1);

if (pol->sadb_x_policy_len * 8 < sizeof(struct sadb_x_policy))
return -EINVAL;

while (len >= sizeof(struct sadb_x_ipsecrequest)) {
if ((err = parse_ipsecrequest(xp, rq)) < 0)
return err;
Expand Down

0 comments on commit f674e72

Please sign in to comment.