Browse Source

net/key/af_key.c: add range checks on ->sadb_x_policy_len

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 <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
imx_3.10.17_1.0.0_ga
Dan Carpenter 8 years ago
committed by David S. Miller
parent
commit
f674e72ff1
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      net/key/af_key.c

+ 3
- 0
net/key/af_key.c View File

@ -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;


Loading…
Cancel
Save