diff mbox

[1/1] NET: llc, zero sockaddr_llc struct

Message ID 1250967535-30692-1-git-send-email-jirislaby@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Jiri Slaby Aug. 22, 2009, 6:58 p.m. UTC
sllc_arphrd member of sockaddr_llc might not be set. Zero sllc
before copying it to the above layers.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
---
 net/llc/af_llc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

David Miller Aug. 24, 2009, 1:56 a.m. UTC | #1
From: Jiri Slaby <jirislaby@gmail.com>
Date: Sat, 22 Aug 2009 20:58:55 +0200

> sllc_arphrd member of sockaddr_llc might not be set. Zero sllc
> before copying it to the above layers.
> 
> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>

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.
--
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
Arnaldo Carvalho de Melo Aug. 24, 2009, 2:20 a.m. UTC | #2
Em Sun, Aug 23, 2009 at 06:56:17PM -0700, David Miller escreveu:
> From: Jiri Slaby <jirislaby@gmail.com>
> Date: Sat, 22 Aug 2009 20:58:55 +0200
> 
> > sllc_arphrd member of sockaddr_llc might not be set. Zero sllc
> > before copying it to the above layers.
> > 
> > Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
> > Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
> 
> 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
--
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/llc/af_llc.c b/net/llc/af_llc.c
index 9208cf5..22629fc 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -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;