Netdev List
 help / color / mirror / Atom feed
* [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

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