mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rhyland Klein <rklein@nvidia.com>
To: Rob Herring <robh@kernel.org>,
	Sasha Levin <sasha.levin@oracle.com>,
	"Gavin Shan" <gwshan@linux.vnet.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Grant Likely <grant.likely@linaro.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: drivers/of: crash on boot
Date: Wed, 18 May 2016 17:26:39 -0400	[thread overview]
Message-ID: <d0e2564c-c8d4-2c4c-f194-60b43b0ab80e@nvidia.com> (raw)
In-Reply-To: <80967a3a-3b97-e131-97e5-f449f567b01c@nvidia.com>

On 5/18/2016 3:58 PM, Rhyland Klein wrote:
> On 5/18/2016 3:36 PM, Rob Herring wrote:
>> On Wed, May 18, 2016 at 10:34 AM, Sasha Levin <sasha.levin@oracle.com> wrote:
>>> Hi Rhyland,
>>>
>>> I'm seeing a crash on boot that seems to have been caused by
>>> "drivers/of: Fix depth when unflattening devicetree":
>>>
>>> [   61.145229] ==================================================================
>>>
>>> [   61.147588] BUG: KASAN: stack-out-of-bounds in unflatten_dt_nodes+0x11d2/0x1290 at addr ffff88005b30777c
>>
>> The following appears to fix it for me. Rhyland, please confirm.
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 7f38241..888ec2a 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -409,7 +409,7 @@ static int unflatten_dt_nodes(const void *blob,
>>         fpsizes[depth] = dad ? strlen(of_node_full_name(dad)) : 0;
>>         nps[depth+1] = dad;
>>         for (offset = 0;
>> -            offset >= 0;
>> +            offset >= 0, depth >= 0;
>>              offset = fdt_next_node(blob, offset, &depth)) {
>>                 if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH))
>>                         continue;
>>
> 
> If I try that patch, i see this when compiling:
> 
> In function ‘unflatten_dt_nodes’:
> warning: left-hand operand of comma expression has no effect
> [-Wunused-value]
> 	offset >= 0, depth >= 0;
> 

This patch seems to work for me. I found a bug in my original patch.
Sasha/Rob, can you see if this works for you too:

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0b5850027bb5..e7a8caac5b27 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -407,9 +407,9 @@ static int unflatten_dt_nodes(const void *blob,

        root = dad;
        fpsizes[depth] = dad ? strlen(of_node_full_name(dad)) : 0;
-       nps[depth+1] = dad;
+       nps[depth] = dad;
        for (offset = 0;
-            offset >= 0;
+            offset >= 0 && depth >= 0;
             offset = fdt_next_node(blob, offset, &depth)) {
                if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH))
                        continue;

-rhyland


-- 
nvpublic

  reply	other threads:[~2016-05-18 21:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18 15:34 Sasha Levin
2016-05-18 19:36 ` Rob Herring
2016-05-18 19:58   ` Rhyland Klein
2016-05-18 21:26     ` Rhyland Klein [this message]
2016-05-19  0:23       ` Rob Herring
2016-05-19  1:51         ` Rob Herring
2016-05-19 11:19           ` Gavin Shan
2016-05-19 12:48             ` Rob Herring
2016-05-20  2:40               ` Gavin Shan
2016-05-19 14:20           ` Rob Herring

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=d0e2564c-c8d4-2c4c-f194-60b43b0ab80e@nvidia.com \
    --to=rklein@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=gwshan@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sasha.levin@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®