From: Eric Dumazet <dada1@cosmosbay.com>
To: Vegard Nossum <vegard.nossum@gmail.com>,
"David S. Miller" <davem@davemloft.net>
Cc: John Dykstra <john.dykstra1@gmail.com>,
Linux Netdev List <netdev@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>,
Pekka Enberg <penberg@cs.helsinki.fi>,
LKML <linux-kernel@vger.kernel.org>,
Jiri Pirko <jpirko@redhat.com>
Subject: [PATCH net-next-2.6] net: dev_addr_init() fix
Date: Mon, 08 Jun 2009 14:13:32 +0200 [thread overview]
Message-ID: <4A2D006C.70302@cosmosbay.com> (raw)
In-Reply-To: <4A2CEB9E.7080109@gmail.com>
Eric Dumazet a écrit :
> Vegard Nossum a écrit :
>> 2009/6/7 John Dykstra <john.dykstra1@gmail.com>:
>>> On Sat, 2009-05-30 at 22:23 +0200, Vegard Nossum wrote:
>>>> It seems that loopback's hardware address is never initialized by the
>>>> kernel. So if userspace attempts to read this address before it has
>>>> been set, the kernel will return some uninitialized data (only 6
>>>> bytes, though).
>>> Thank you for the report, Vegard.
>>>
>>> I've been unable to reproduce the problem you describe, using
>>> 2.6-30-rc8, this test program and a couple of kernel builds for system
>>> load:
>> [...]
>>> ------------------------------------------------------------------
>>>
>>> Looking at the kernel code, it appears that all bytes of struct
>>> net_device, including the L2 address, are initialized to zeros at
>>> interface creation time.
>>>
>>> Can you spot a difference between your test procedures and mine that
>>> would enable me to reproduce the problem?
>> Hi,
>>
>> I just tried your test program on a linux-next kernel, it works beautifully :-)
>>
>> (I made one change: The stack grows downwards on x86, so I think you
>> should put child_stack + 16386 as the stack to clone()?)
>>
>> As I wrote in reply to Stephen Hemminger, this problem seems to be
>> caused by a particular patch in linux-next:
>>
>> commit f001fde5eadd915f4858d22ed70d7040f48767cf
>> Author: Jiri Pirko <jpirko@redhat.com>
>> Date: Tue May 5 02:48:28 2009 +0000
>>
>> net: introduce a list of device addresses dev_addr_list (v6)
>>
>
> I believe following patch should fix this problem.
>
> Thank you
>
> [PATCH net-next-2.6] net: loopback device dev->addr_len fix
>
> commit f001fde5eadd915f4858d22ed70d7040f48767cf
> (net: introduce a list of device addresses dev_addr_list (v6))
> added one regression Vegard Nossum found in its testings.
>
> loopback device doesnt have a hw address, we should set its
> dev->addr_len to 0, not ETH_ALEN.
>
> Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Oh well, following is probably even more appropriate
[PATCH net-next-2.6] net: dev_addr_init() fix
commit f001fde5eadd915f4858d22ed70d7040f48767cf
(net: introduce a list of device addresses dev_addr_list (v6))
added one regression Vegard Nossum found in its testings.
dev_addr_init() incorrectly uses sizeof() operator
Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
diff --git a/net/core/dev.c b/net/core/dev.c
index 1f38401..65387d9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3655,8 +3655,8 @@ static int dev_addr_init(struct net_device *dev)
/* rtnl_mutex must be held here */
INIT_LIST_HEAD(&dev->dev_addr_list);
- memset(addr, 0, sizeof(*addr));
- err = __hw_addr_add(&dev->dev_addr_list, NULL, addr, sizeof(*addr),
+ memset(addr, 0, sizeof(addr));
+ err = __hw_addr_add(&dev->dev_addr_list, NULL, addr, sizeof(addr),
NETDEV_HW_ADDR_T_LAN);
if (!err) {
/*
next prev parent reply other threads:[~2009-06-08 12:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-30 20:23 net: uninitialized loopback addr leaks to userspace Vegard Nossum
2009-06-07 21:03 ` John Dykstra
2009-06-08 10:00 ` Vegard Nossum
2009-06-08 10:44 ` [PATCH net-next-2.6] net: loopback device dev->addr_len fix Eric Dumazet
2009-06-08 12:13 ` Eric Dumazet [this message]
2009-06-08 12:41 ` [PATCH net-next-2.6] net: dev_addr_init() fix Jiri Pirko
2009-06-08 13:06 ` Ingo Molnar
2009-06-08 13:49 ` Eric Dumazet
2009-06-09 12:21 ` David Miller
2009-06-07 23:11 ` net: uninitialized loopback addr leaks to userspace Stephen Hemminger
2009-06-08 9:16 ` Vegard Nossum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A2D006C.70302@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=davem@davemloft.net \
--cc=john.dykstra1@gmail.com \
--cc=jpirko@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=netdev@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=vegard.nossum@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).