diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-09-27 18:21:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-10-01 17:15:06 -0400 |
commit | f674e72ff1aad23a99c7c205473cf02c85c2ac33 (patch) | |
tree | 032274dd7d42c5feeb17fe8b944ce9709001e339 /net/key | |
parent | 862096a8bbf8f992f6d0a1a8786ffd3fc7437e48 (diff) |
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>
Diffstat (limited to 'net/key')
-rw-r--r-- | net/key/af_key.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c index 2ca7d7f6861c..08897a3c7ec7 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -1923,6 +1923,9 @@ parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol) | |||
1923 | int len = pol->sadb_x_policy_len*8 - sizeof(struct sadb_x_policy); | 1923 | int len = pol->sadb_x_policy_len*8 - sizeof(struct sadb_x_policy); |
1924 | struct sadb_x_ipsecrequest *rq = (void*)(pol+1); | 1924 | struct sadb_x_ipsecrequest *rq = (void*)(pol+1); |
1925 | 1925 | ||
1926 | if (pol->sadb_x_policy_len * 8 < sizeof(struct sadb_x_policy)) | ||
1927 | return -EINVAL; | ||
1928 | |||
1926 | while (len >= sizeof(struct sadb_x_ipsecrequest)) { | 1929 | while (len >= sizeof(struct sadb_x_ipsecrequest)) { |
1927 | if ((err = parse_ipsecrequest(xp, rq)) < 0) | 1930 | if ((err = parse_ipsecrequest(xp, rq)) < 0) |
1928 | return err; | 1931 | return err; |