netdev
[Top] [All Lists]

Re: [PATCH 2.6] dev.c: clear SIOCGIFHWADDR buffer if !dev->addr_len

To: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Subject: Re: [PATCH 2.6] dev.c: clear SIOCGIFHWADDR buffer if !dev->addr_len
From: Matt Domsch <Matt_Domsch@xxxxxxxx>
Date: Mon, 1 Nov 2004 14:38:21 -0600
Cc: netdev@xxxxxxxxxxx, jamal <hadi@xxxxxxxxxx>
In-reply-to: <20041101202754.GA23149@xxxxxxxxxxxxxxxxxxx>
References: <20041030013700.GA21540@xxxxxxxxxxxxxxxxx> <E1CNiOT-0008GU-00@xxxxxxxxxxxxxxxxxxxxxxxx> <20041030030936.GA25102@xxxxxxxxxxxxxxxxx> <1099163419.1039.97.camel@xxxxxxxxxxxxxxxx> <20041101044433.GA18772@xxxxxxxxxxxxxxxxx> <20041101173434.GA12437@xxxxxxxxxxxxxxxxx> <20041101202754.GA23149@xxxxxxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.1i
On Tue, Nov 02, 2004 at 07:27:54AM +1100, Herbert Xu wrote:
> Same problem as before.  If dev->addr_len is greater than zero but less
> than sizeof ifr->ifr_hwaddr.sa_data, then you've got garbage in there.
> Zero is not a special case.

OK, I'll unconditionally clear it all first.  How's this?

Signed-off-by: Matt Domsch <Matt_Domsch@xxxxxxxx>

-- 
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

===== net/core/dev.c 1.169 vs edited =====
--- 1.169/net/core/dev.c        2004-10-26 11:09:33 -05:00
+++ edited/net/core/dev.c       2004-11-01 14:35:02 -06:00
@@ -2375,6 +2375,12 @@
                        return dev_set_mtu(dev, ifr->ifr_mtu);
 
                case SIOCGIFHWADDR:
+                       if (net_ratelimit())
+                               printk(KERN_DEBUG "Warning: %s uses obsolete 
ioctl(SIOCGIFHWADDR), please convert it to rtnetlink(3,7)\n", current->comm);
+
+                       if ((size_t) dev->addr_len > sizeof 
ifr->ifr_hwaddr.sa_data)
+                               return -EOVERFLOW;
+                       memset(ifr->ifr_hwaddr.sa_data, 0, sizeof 
ifr->ifr_hwaddr.sa_data);
                        memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr,
                               min(sizeof ifr->ifr_hwaddr.sa_data, (size_t) 
dev->addr_len));
                        ifr->ifr_hwaddr.sa_family = dev->type;

<Prev in Thread] Current Thread [Next in Thread>