net: core: sock: fix information leak to userland
Subsystems (4)
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
@@ -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
Quoted 17 lines · Vasiliy Kulikov
"Address" variable might be not fully initialized in
sock->ops->get_name(). The only current implementation isget_name(), it leaves some padding fields ofsockaddr_tipcuninitialized. It leads to leaking of contents of kernel stack memory.Signed-off-by Vasiliy Kulikov <[email protected]>---
Compile tested.net/core/sock.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)net/core/sock.c +0
-0
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.
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 isget_name(), it leaves some padding fields ofsockaddr_tipcuninitialized. It leads to leaking of contents of kernel stack memory.Signed-off-by Vasiliy Kulikov <[email protected]>---
Compile tested.net/core/sock.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)net/core/sock.c +0
-0@@ -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