Skip to content
Browse files

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>
  • Loading branch information...
1 parent 862096a commit f674e72ff1aad23a99c7c205473cf02c85c2ac33 @theif theif committed with davem330 Sep 27, 2012
Showing with 3 additions and 0 deletions.
  1. +3 −0 net/key/af_key.c
View
3 net/key/af_key.c
@@ -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;

0 comments on commit f674e72

Please sign in to comment.
Something went wrong with that request. Please try again.