diff mbox

[net-2.6] can: Fix raw_getname() leak

Message ID 4A7BC938.8010504@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Aug. 7, 2009, 6:27 a.m. UTC
raw_getname() can leak 10 bytes of kernel memory to user

(two bytes hole between can_family and can_ifindex,
8 bytes at the end of sockaddr_can structure)

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Oliver Hartkopp Aug. 7, 2009, 6:31 a.m. UTC | #1
Eric Dumazet wrote:
> raw_getname() can leak 10 bytes of kernel memory to user
> 
> (two bytes hole between can_family and can_ifindex,
> 8 bytes at the end of sockaddr_can structure)
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Acked-by: Oliver Hartkopp <oliver@hartkopp.net>

Thanks Eric!

> ---
> diff --git a/net/can/raw.c b/net/can/raw.c
> index f4cc445..db3152d 100644
> --- a/net/can/raw.c
> +++ b/net/can/raw.c
> @@ -401,6 +401,7 @@ static int raw_getname(struct socket *sock, struct sockaddr *uaddr,
>  	if (peer)
>  		return -EOPNOTSUPP;
>  
> +	memset(addr, 0, sizeof(*addr));
>  	addr->can_family  = AF_CAN;
>  	addr->can_ifindex = ro->ifindex;
>  

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Aug. 10, 2009, 4:52 a.m. UTC | #2
From: Oliver Hartkopp <oliver@hartkopp.net>
Date: Fri, 07 Aug 2009 08:31:59 +0200

> Eric Dumazet wrote:
>> raw_getname() can leak 10 bytes of kernel memory to user
>> 
>> (two bytes hole between can_family and can_ifindex,
>> 8 bytes at the end of sockaddr_can structure)
>> 
>> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
> 
> Acked-by: Oliver Hartkopp <oliver@hartkopp.net>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/can/raw.c b/net/can/raw.c
index f4cc445..db3152d 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -401,6 +401,7 @@  static int raw_getname(struct socket *sock, struct sockaddr *uaddr,
 	if (peer)
 		return -EOPNOTSUPP;
 
+	memset(addr, 0, sizeof(*addr));
 	addr->can_family  = AF_CAN;
 	addr->can_ifindex = ro->ifindex;