From: Andrew Lunn <andrew@lunn.ch>
To: Stefan Hellermann <stefan@the2masters.de>
Cc: linux@arm.linux.org.uk, jason@lakedaemon.net,
netdev@vger.kernel.org, "\[ 4 . 4+ \]" <stable@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org,
gregory.clement@free-electrons.com,
andriy.shevchenko@linux.intel.com, adobriyan@gmail.com,
dv@vollmann.ch
Subject: Re: [PATCH] net: Allow mac_pton() to work on non-NULL terminated strings
Date: Fri, 23 Feb 2018 21:27:20 +0100 [thread overview]
Message-ID: <20180223202720.GA27961@lunn.ch> (raw)
In-Reply-To: <20180223201748.14328-1-stefan@the2masters.de>
On Fri, Feb 23, 2018 at 09:17:48PM +0100, Stefan Hellermann wrote:
> Commit 4904dbda41c8 ("ARM: orion5x: use mac_pton() helper") crashes my
> QNAP TS-209 NAS early on boot.
>
> The boot code for the TS-209 is looping through an ext2 filesystem on a
> 384kB mtd partition (factory configuration put there by QNAP). There it
> looks on every 1kB boundary if there is a valid MAC address. The
> filesystem has a 1kB block size, so this seems to work.
>
> On my device the MAC address is on the 37th 1kB block. But: On the 27th
> block is a large file (1,5kB) without 0 bytes inside. The code in
> qnap_tsx09_find_mac_addr() maps 1kB into memory (not a whole file or the
> whole 384kB) and then calls qnap_tsx09_check_mac_addr() -> mac_pton() ->
> strlen() on this memory block. as there is no 0 byte in the file on the
> 27th block, strlen() runs into bad memory and the machine panics. The old
> code had no strlen().
>
> Actually mac_pton() doesn't need to call strlen(), the following loop
> catches short strings quite nicely. The strlen() seems to be an
> optimization for calls to mac_pton with empty string. But this is rarely
> the case and this is not a hot path. Remove it to reduce code size and
> speed up calls with an not empty string.
>
> Besides fixing the crash there is are other users interested in
> this change, see https://patchwork.ozlabs.org/patch/851008/
>
> Fixes: 4904dbda41c8 ("ARM: orion5x: use mac_pton() helper")
> Signed-off-by: Stefan Hellermann <stefan@the2masters.de>
> Cc: <stable@vger.kernel.org> [4.4+]
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
next prev parent reply other threads:[~2018-02-23 20:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180223182006.GA2116@avx2>
2018-02-23 20:17 ` [PATCH] net: Allow mac_pton() to work on non-NULL terminated strings Stefan Hellermann
2018-02-23 20:27 ` Andrew Lunn [this message]
2018-02-23 20:41 ` Alexey Dobriyan
2018-02-23 20:51 ` Andy Shevchenko
2018-02-26 18:37 ` David Miller
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=20180223202720.GA27961@lunn.ch \
--to=andrew@lunn.ch \
--cc=adobriyan@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dv@vollmann.ch \
--cc=gregory.clement@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux@arm.linux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefan@the2masters.de \
/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).