From patchwork Mon Jun 8 12:13:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 28225 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 91105B70B9 for ; Mon, 8 Jun 2009 22:14:19 +1000 (EST) Received: by ozlabs.org (Postfix) id 42A9EDDD1B; Mon, 8 Jun 2009 22:14:19 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 4B184DDD04 for ; Mon, 8 Jun 2009 22:14:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755092AbZFHMOF (ORCPT ); Mon, 8 Jun 2009 08:14:05 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754884AbZFHMOF (ORCPT ); Mon, 8 Jun 2009 08:14:05 -0400 Received: from gw1.cosmosbay.com ([212.99.114.194]:37323 "EHLO gw1.cosmosbay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754629AbZFHMOE convert rfc822-to-8bit (ORCPT ); Mon, 8 Jun 2009 08:14:04 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by gw1.cosmosbay.com (8.13.7/8.13.7) with ESMTP id n58CDW7c023845; Mon, 8 Jun 2009 14:13:32 +0200 Message-ID: <4A2D006C.70302@cosmosbay.com> Date: Mon, 08 Jun 2009 14:13:32 +0200 From: Eric Dumazet User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Vegard Nossum , "David S. Miller" CC: John Dykstra , Linux Netdev List , Ingo Molnar , Pekka Enberg , LKML , Jiri Pirko Subject: [PATCH net-next-2.6] net: dev_addr_init() fix References: <19f34abd0905301323k1498ca3fv31b271de65d60afc@mail.gmail.com> <1244408607.9064.8.camel@Maple> <19f34abd0906080300w796c6b65o6b537064cac917b0@mail.gmail.com> <4A2CEB9E.7080109@gmail.com> In-Reply-To: <4A2CEB9E.7080109@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-1.6 (gw1.cosmosbay.com [0.0.0.0]); Mon, 08 Jun 2009 14:13:35 +0200 (CEST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Eric Dumazet a écrit : > Vegard Nossum a écrit : >> 2009/6/7 John Dykstra : >>> 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 >> 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 > Signed-off-by: Eric Dumazet 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 Signed-off-by: Eric Dumazet Signed-off-by: Jiri Pirko --- -- 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 --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) { /*