lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 01 Apr 2015 11:05:50 -0700
From:	Joe Perches <joe@...ches.com>
To:	Jonas Gorski <jogo@...nwrt.org>
Cc:	Florian Fainelli <florian@...nwrt.org>,
	Daniel Walter <dwalter@...gle.com>,
	Ralf Baechle <ralf@...ux-mips.org>,
	Linux-MIPS <linux-mips@...ux-mips.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] ar7: replace mac address parsing

On Wed, 2015-04-01 at 14:17 +0200, Jonas Gorski wrote:
> On Tue, Jun 24, 2014 at 9:26 PM, Florian Fainelli <florian@...nwrt.org> wrote:
> > 2014-06-24 8:48 GMT-07:00 Joe Perches <joe@...ches.com>:
> >> On Tue, 2014-06-24 at 16:39 +0100, Daniel Walter wrote:
> >>> Replace sscanf() with mac_pton().
> >> []
> >>> diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
> >> []
> >>> @@ -307,10 +307,7 @@ static void __init cpmac_get_mac(int instance, unsigned char *dev_addr)
> >>>       }
> >>>
> >>>       if (mac) {
> >>> -             if (sscanf(mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
> >>> -                                     &dev_addr[0], &dev_addr[1],
> >>> -                                     &dev_addr[2], &dev_addr[3],
> >>> -                                     &dev_addr[4], &dev_addr[5]) != 6) {
> >>> +             if (!mac_pton(mac, dev_addr)) {
> >>
> >> There is a slight functional change with this conversion.
> >>
> >> mac_pton is strict about leading 0's and requires a 17 char strlen.
> >
> > I do not have my devices handy, but I am fairly positive the use of
> > sscanf() was exactly for that, we may or may not have leading zeroes.
> > I am feeling a little uncomfortable with random code changes like that
> > without being actually able to test on real hardware that has a
> > variety of bootloaders and environment variables.
> 
> One of my two devices has a mac address with one of the numbers being
> < 16, and it uses a fixed length mac:
> 
> (psbl) printenv
> ...
> HWA_0           00:16:B6:2A:A4:3B
> 
> Also looking at the history[1] of this code, it looks like this was
> just an optimization of an earlier code which did expect 17 char len:
> 
>        for (i = 0; i < 6; i++)
>                dev_addr[i] = (char2hex(mac[i * 3]) << 4) +
>                        char2hex(mac[i * 3 + 1]);
> 
> 
> So I'm tempted to say it should not cause any issues. But my sample
> size is rather small.
> [1] d16f7093b6eb4f3859856f6ee4ab504cbeeea0b9

Wow Jonas, a 9 month thread gestation...

Given the old code and the commit comment, I'd
say it was almost certainly safe and my issue with
the patch resolved.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ