* [IPSEC] Fixed alg_key_len usage in attach_one_algo
@ 2005-05-19 2:03 Herbert Xu
2005-05-19 2:15 ` [IPSEC] Verify key payload in verify_one_algo Herbert Xu
2005-05-19 19:40 ` [IPSEC] Fixed alg_key_len usage in attach_one_algo David S. Miller
0 siblings, 2 replies; 5+ messages in thread
From: Herbert Xu @ 2005-05-19 2:03 UTC (permalink / raw)
To: David S. Miller, netdev
[-- Attachment #1: Type: text/plain, Size: 550 bytes --]
Hi Dave:
This bug was discovered by a Linux box running in a remote corner
of Australia :)
The variable alg_key_len is in bits and not bytes. The function
attach_one_algo is currently using it as if it were in bytes.
This causes it to read memory which may not be there.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[-- Attachment #2: xfrm-user-1 --]
[-- Type: text/plain, Size: 649 bytes --]
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -162,6 +162,7 @@ static int attach_one_algo(struct xfrm_a
struct rtattr *rta = u_arg;
struct xfrm_algo *p, *ualg;
struct xfrm_algo_desc *algo;
+ int len;
if (!rta)
return 0;
@@ -173,11 +174,12 @@ static int attach_one_algo(struct xfrm_a
return -ENOSYS;
*props = algo->desc.sadb_alg_id;
- p = kmalloc(sizeof(*ualg) + ualg->alg_key_len, GFP_KERNEL);
+ len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8;
+ p = kmalloc(len, GFP_KERNEL);
if (!p)
return -ENOMEM;
- memcpy(p, ualg, sizeof(*ualg) + ualg->alg_key_len);
+ memcpy(p, ualg, len);
*algpp = p;
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread* [IPSEC] Verify key payload in verify_one_algo
2005-05-19 2:03 [IPSEC] Fixed alg_key_len usage in attach_one_algo Herbert Xu
@ 2005-05-19 2:15 ` Herbert Xu
2005-05-19 19:40 ` David S. Miller
2005-05-19 19:40 ` [IPSEC] Fixed alg_key_len usage in attach_one_algo David S. Miller
1 sibling, 1 reply; 5+ messages in thread
From: Herbert Xu @ 2005-05-19 2:15 UTC (permalink / raw)
To: David S. Miller, netdev
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
Hi Dave:
We need to verify that the payload contains enough data so that
attach_one_algo can copy alg_key_len bits from the payload.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[-- Attachment #2: xfrm-user-2 --]
[-- Type: text/plain, Size: 533 bytes --]
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -34,14 +34,21 @@ static int verify_one_alg(struct rtattr
{
struct rtattr *rt = xfrma[type - 1];
struct xfrm_algo *algp;
+ int len;
if (!rt)
return 0;
- if ((rt->rta_len - sizeof(*rt)) < sizeof(*algp))
+ len = (rt->rta_len - sizeof(*rt)) - sizeof(*algp);
+ if (len < 0)
return -EINVAL;
algp = RTA_DATA(rt);
+
+ len -= (algp->alg_key_len + 7U) / 8;
+ if (len < 0)
+ return -EINVAL;
+
switch (type) {
case XFRMA_ALG_AUTH:
if (!algp->alg_key_len &&
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [IPSEC] Verify key payload in verify_one_algo
2005-05-19 2:15 ` [IPSEC] Verify key payload in verify_one_algo Herbert Xu
@ 2005-05-19 19:40 ` David S. Miller
2005-05-19 21:34 ` Herbert Xu
0 siblings, 1 reply; 5+ messages in thread
From: David S. Miller @ 2005-05-19 19:40 UTC (permalink / raw)
To: herbert; +Cc: netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 19 May 2005 12:15:05 +1000
> We need to verify that the payload contains enough data so that
> attach_one_algo can copy alg_key_len bits from the payload.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Also applied, thanks again.
I gather from these two patches that once you found the
first problem you went around auditing alg_key_len usage
and these were the only two bugs you spotted. Right?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [IPSEC] Fixed alg_key_len usage in attach_one_algo
2005-05-19 2:03 [IPSEC] Fixed alg_key_len usage in attach_one_algo Herbert Xu
2005-05-19 2:15 ` [IPSEC] Verify key payload in verify_one_algo Herbert Xu
@ 2005-05-19 19:40 ` David S. Miller
1 sibling, 0 replies; 5+ messages in thread
From: David S. Miller @ 2005-05-19 19:40 UTC (permalink / raw)
To: herbert; +Cc: netdev
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu, 19 May 2005 12:03:02 +1000
> This bug was discovered by a Linux box running in a remote corner
> of Australia :)
Hehe :-)
> The variable alg_key_len is in bits and not bytes. The function
> attach_one_algo is currently using it as if it were in bytes.
> This causes it to read memory which may not be there.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Applied, thanks Herbert.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-05-19 21:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-19 2:03 [IPSEC] Fixed alg_key_len usage in attach_one_algo Herbert Xu
2005-05-19 2:15 ` [IPSEC] Verify key payload in verify_one_algo Herbert Xu
2005-05-19 19:40 ` David S. Miller
2005-05-19 21:34 ` Herbert Xu
2005-05-19 19:40 ` [IPSEC] Fixed alg_key_len usage in attach_one_algo David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox