xfrm_user: fix info leak in copy_to_user_auth()
authorMathias Krause <minipli@googlemail.com>
Wed, 19 Sep 2012 11:33:38 +0000 (11:33 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Sep 2012 22:08:39 +0000 (18:08 -0400)
copy_to_user_auth() fails to initialize the remainder of alg_name and
therefore discloses up to 54 bytes of heap memory via netlink to
userland.

Use strncpy() instead of strcpy() to fill the trailing bytes of alg_name
with null bytes.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/xfrm/xfrm_user.c

index d12b62547ad072778e11fb934f0dae719f156f2b..40dd50d6c4cc31efec38b9525f88056269df9a4a 100644 (file)
@@ -742,7 +742,7 @@ static int copy_to_user_auth(struct xfrm_algo_auth *auth, struct sk_buff *skb)
                return -EMSGSIZE;
 
        algo = nla_data(nla);
-       strcpy(algo->alg_name, auth->alg_name);
+       strncpy(algo->alg_name, auth->alg_name, sizeof(algo->alg_name));
        memcpy(algo->alg_key, auth->alg_key, (auth->alg_key_len + 7) / 8);
        algo->alg_key_len = auth->alg_key_len;
 
This page took 0.026749 seconds and 5 git commands to generate.