From: Stephen Hemminger <shemminger@vyatta.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Linux Netdev List <netdev@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>,
Pekka Enberg <penberg@cs.helsinki.fi>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: net: uninitialized loopback addr leaks to userspace
Date: Sun, 7 Jun 2009 16:11:05 -0700 [thread overview]
Message-ID: <20090607161105.385d6e92@nehalam> (raw)
In-Reply-To: <19f34abd0905301323k1498ca3fv31b271de65d60afc@mail.gmail.com>
On Sat, 30 May 2009 22:23:24 +0200
Vegard Nossum <vegard.nossum@gmail.com> wrote:
> Hi,
>
> 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). This can be demonstrated by creating a new network
> namespace (CLONE_NEWNET), which creates a new loopback device, then
> call ioctl() with SIOCGIFHWADDR on "lo". If this is done in a loop,
> with some background load, or by running multiple instances, random
> data will start to show up in the returned address.
>
> [ 406.750329] WARNING: kmemcheck: Caught 16-bit read from
> uninitialized memory (ffff880007220974)
> [ 406.753555] 18a2d7060088ffff18a2d7060088ffff00000000010000000100000003000000
> [ 406.758862] i i i i i i i i i i i i i i i i i u u u u u u u u u u u u u u u
> [ 406.766224] ^
> [ 406.768792] Modules linked in:
> [ 406.770416] Pid: 757, comm: ifconfig Not tainted
> 2.6.30-rc7-next-20090529 #404
> [ 406.772876] RIP: 0010:[<ffffffff80664789>] [<ffffffff80664789>]
> dev_ioctl+0x5d9/0x600
> [ 406.804677] [<ffffffff8064ff75>] sock_ioctl+0x95/0x2a0
> [ 406.807242] [<ffffffff802c35eb>] vfs_ioctl+0x1b/0x70
> [ 406.809348] [<ffffffff802c36fa>] do_vfs_ioctl+0x8a/0x570
> [ 406.811419] [<ffffffff802c3c79>] sys_ioctl+0x99/0xa0
> [ 406.813400] [<ffffffff802f3941>] dev_ifsioc+0x81/0x2f0
> [ 406.815424] [<ffffffff802f454d>] compat_sys_ioctl+0xed/0x3c0
> [ 406.817596] [<ffffffff8022d476>] cstar_dispatch+0x7/0x26
> [ 406.819978] [<ffffffffffffffff>] 0xffffffffffffffff
>
> This is the code that triggers the warning, in net/core/dev.c, around line 4150:
>
> memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr,
> min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) dev->addr_len));
>
> So it's dev->dev_addr that is the pointer to the uninitialized data.
>
> I didn't know how to fix it.
>
The whole dev structure is zeroed in alloc_netdev(), kmemcheck
is giving bogus warning.
--
next prev parent reply other threads:[~2009-06-07 23:11 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 ` [PATCH net-next-2.6] net: dev_addr_init() fix Eric Dumazet
2009-06-08 12:41 ` 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 ` Stephen Hemminger [this message]
2009-06-08 9:16 ` net: uninitialized loopback addr leaks to userspace 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=20090607161105.385d6e92@nehalam \
--to=shemminger@vyatta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.