Skip to contentSkip to conversation

net: core: sock: fix information leak to userland

PATCH In review Vasiliy Kulikov 2 participants 3 messages Oct 30, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: core: sock: fix information leak to userland

"Address" variable might be not fully initialized in sock->ops->get_name(). The only current implementation is get_name(), it leaves some padding fields of sockaddr_tipc uninitialized. It leads to leaking of contents of kernel stack memory.

---
Compile tested.

 net/core/sock.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/core/sock.c +1 -0
index 3eed542..759dd81 100644
@@ -930,6 +930,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 	{
 		char address[128];
 
+		memset(&address, 0, sizeof(address));
 		if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
 			return -ENOTCONN;
 		if (lv < len)
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 17 lines · Vasiliy Kulikov

"Address" variable might be not fully initialized in sock->ops->get_name(). The only current implementation is get_name(), it leaves some padding fields of sockaddr_tipc uninitialized. It leads to leaking of contents of kernel stack memory.

---
Compile tested.

 net/core/sock.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/core/sock.c +0 -0
index 3eed542..759dd81 100644

net/core/sock.c int sock_getsockopt(struct socket *sock, int level, int optname, · line 936

Quoted 7 lines
net/core/sock.c +1 -0
@@ -930,6 +930,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 	{
 		char address[128];
 
+		memset(&address, 0, sizeof(address));
 		if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
 			return -ENOTCONN;
 		if (lv < len)

???

Please fix the real bug.

#2 lore raw
Quoted 21 lines · Eric Dumazet
Quoted 20 lines · Vasiliy Kulikov

"Address" variable might be not fully initialized in sock->ops->get_name(). The only current implementation is get_name(), it leaves some padding fields of sockaddr_tipc uninitialized. It leads to leaking of contents of kernel stack memory.

---
Compile tested.

 net/core/sock.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/core/sock.c +0 -0
index 3eed542..759dd81 100644
@@ -930,6 +930,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 	{
 		char address[128];
 
Quoted 8 lines

net/core/sock.c int sock_getsockopt(struct socket *sock, int level, int optname, · line 936

Quoted 4 lines
net/core/sock.c +1 -0
+		memset(&address, 0, sizeof(address));
 		if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
 			return -ENOTCONN;
 		if (lv < len)

???

Please fix the real bug.

What if somebody want to create his own implementation of getname()? IMO it's much safer to introduce memset() here and relax getname()'s responsibilities. Quite many drivers "forget" to initialize outputs structures. E.g. new net_device's private field is kzalloc'ed to simplify driver's code.

Signature · 5 lines
Vasiliy
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html