Skip to contentSkip to conversation

NET: llc, zero sockaddr_llc struct

PATCH Superseded Jiri Slaby 3 participants 5 messages Aug 22, 2009 – Aug 24, 2009

Subsystems (3)
lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 NET: llc, zero sockaddr_llc struct

sllc_arphrd member of sockaddr_llc might not be set. Zero sllc before copying it to the above layers.

Cc Arnaldo Carvalho de Melo <[email protected]>
---
 net/llc/af_llc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/llc/af_llc.c +1 -1
index 9208cf5..22629fc 100644
@@ -909,7 +909,7 @@ release:
 static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
 			  int *uaddrlen, int peer)
 {
-	struct sockaddr_llc sllc;
+	struct sockaddr_llc sllc = {};
 	struct sock *sk = sock->sk;
 	struct llc_sock *llc = llc_sk(sk);
 	int rc = 0;
Signature · 1 line
1.6.3.3
maintainer
#1 lore raw

From: Jiri Slaby <[email protected]>
Date: Sat, 22 Aug 2009 20:58:55 +0200

Quoted 5 lines

sllc_arphrd member of sockaddr_llc might not be set. Zero sllc before copying it to the above layers.

Cc Arnaldo Carvalho de Melo <[email protected]>

I know it seems arbitrary, but could you please memset() on the structure instead of using an empty initializer so that it's consistent with how all other ->getname() implementations deal with this issue?

It's easier to audit that way.

Thanks.

#2 lore raw

Em Sun, Aug 23, 2009 at 06:56:17PM -0700, David Miller escreveu:

Quoted 9 lines

From: Jiri Slaby <[email protected]>
Date: Sat, 22 Aug 2009 20:58:55 +0200

Quoted 5 lines

sllc_arphrd member of sockaddr_llc might not be set. Zero sllc before copying it to the above layers.

Cc Arnaldo Carvalho de Melo <[email protected]>
Quoted 6 lines

I know it seems arbitrary, but could you please memset() on the structure instead of using an empty initializer so that it's consistent with how all other ->getname() implementations deal with this issue?

It's easier to audit that way.

Or just set the uninitialized field to zero. But yeah, if what other implementations are doing is to memset it to zero... maybe its more clear from a quick glance :-)

- Arnaldo

author
#3 lore raw

PATCH v2 1/1 NET: llc, zero sockaddr_llc struct

In reply to David Miller

sllc_arphrd member of sockaddr_llc might not be changed. Zero sllc before copying to the above layer's structure.

Cc Arnaldo Carvalho de Melo <[email protected]>
---
 net/llc/af_llc.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/llc/af_llc.c +1 -0
index 9208cf5..c45eee1 100644
@@ -914,6 +914,7 @@ static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
 	struct llc_sock *llc = llc_sk(sk);
 	int rc = 0;
 
+	memset(&sllc, 0, sizeof(sllc));
 	lock_sock(sk);
 	if (sock_flag(sk, SOCK_ZAPPED))
 		goto out;
Signature · 1 line
1.6.3.3