devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frank Rowand <frowand.list@gmail.com>
To: Stephen Boyd <stephen.boyd@linaro.org>, Rob Herring <robh+dt@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [RFC/PATCH] of: Mark property::value as const
Date: Thu, 23 Feb 2017 13:47:07 -0800	[thread overview]
Message-ID: <58AF585B.7060303@gmail.com> (raw)
In-Reply-To: <58AF3E06.4030701@gmail.com>

On 02/23/17 11:54, Frank Rowand wrote:
> On 02/13/17 18:50, Stephen Boyd wrote:
>> The 'blob' we pass into populate_properties() is marked as const,
>> but we cast that const away when we assign the result of
>> fdt_getprop_by_offset() to pp->value. Let's mark value as const
>> instead, so that code can't mistakenly write to the value of the
>> property that we've so far advertised as const.
>>
>> Unfortunately, this exposes a problem with the fdt resolver code,
>> where we overwrite the value member of properties of phandles to
>> update them with their final value. Add a comment for now to
>> indicate where we're potentially writing over const data.
> 
> The resolver should not be over writing anything in the FDT.  I'll
> look at what is going on there.

OK, now that I have looked at the resolver, I see that you meant that
the resolver code is modifying the _overlay_ FDT, not the FDT that
was used at initial boot.  So not what I thought you meant.

I'll reply separately to the original patch email with a more complete
response.

-Frank

> 
> The FDT we expose to user space should be the FDT we booted with,
> not something later modified.
> 
> -Frank
> 
>>
>> You can see the problem here by loading an overlay dtb into
>> the kernel via the request firmware helper method (not direct
>> loading) and then passing that tree to the resolver on an arm64
>> device. In this case, the firmware data is vmapped with KERNEL_PAGE_RO
>> and the code crashes when attempting to write to the blob to update
>> the phandle properties.
>>
>> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
>> ---
>>
>> I was thinking perhaps it would work to store another __be32 variant
>> of the phandle in each device node, but then we still have a problem
>> with properties that have phandles inside them at some offset that we
>> need to update. I guess the only real solution is to deep copy the
>> property in that case and then save around some info to free the
>> duplicated property later on?
>>
>>  drivers/of/base.c     |  2 +-
>>  drivers/of/fdt.c      | 12 ++++++------
>>  drivers/of/resolver.c |  3 +++
>>  include/linux/of.h    |  2 +-
>>  4 files changed, 11 insertions(+), 8 deletions(-)
> 
> < snip >
> 

      parent reply	other threads:[~2017-02-23 21:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14  2:50 [RFC/PATCH] of: Mark property::value as const Stephen Boyd
     [not found] ` <20170214025040.23955-1-stephen.boyd-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-02-23 13:39   ` Rob Herring
2017-02-23 23:08   ` Frank Rowand
     [not found]     ` <58AF6B88.6020709-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-23 23:25       ` Frank Rowand
2017-02-23 23:38       ` Rob Herring
2017-03-12  6:27       ` Frank Rowand
     [not found]         ` <58C4EA3C.4070503-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-14 19:23           ` Stephen Boyd
2017-03-17  7:46             ` [PATCH] " kbuild test robot
2017-03-17  9:17             ` kbuild test robot
2017-02-23 19:54 ` [RFC/PATCH] " Frank Rowand
     [not found]   ` <58AF3E06.4030701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-23 20:58     ` Frank Rowand
     [not found]       ` <58AF4D03.7020908-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-23 22:09         ` Rob Herring
     [not found]           ` <CAL_Jsq+OQgmqvHQ_AWXOqnK0Yh8T3EVyxyiTFk1+0AwNHCf+Ag-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-23 23:23             ` Frank Rowand
2017-02-23 21:47   ` Frank Rowand [this message]

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=58AF585B.7060303@gmail.com \
    --to=frowand.list@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=stephen.boyd@linaro.org \
    /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).