Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1587104

Re: [RFC/PATCH] of: Mark property::value as const

From Frank Rowand <frowand.list@gmail.com>
Newsgroups linux.kernel
Subject Re: [RFC/PATCH] of: Mark property::value as const
Date 2017-02-23 21:00 +0100
Message-ID <te7It-5Pd-5@gated-at.bofh.it> (permalink)
References <taBvr-43Z-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.

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 >

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC/PATCH] of: Mark property::value as const Stephen Boyd <stephen.boyd@linaro.org> - 2017-02-14 04:00 +0100
  Re: [RFC/PATCH] of: Mark property::value as const Rob Herring <robh+dt@kernel.org> - 2017-02-23 14:50 +0100
  Re: [RFC/PATCH] of: Mark property::value as const Frank Rowand <frowand.list@gmail.com> - 2017-02-23 21:00 +0100
    Re: [RFC/PATCH] of: Mark property::value as const Frank Rowand <frowand.list@gmail.com> - 2017-02-23 22:00 +0100
      Re: [RFC/PATCH] of: Mark property::value as const Rob Herring <robh+dt@kernel.org> - 2017-02-23 23:20 +0100
        Re: [RFC/PATCH] of: Mark property::value as const Frank Rowand <frowand.list@gmail.com> - 2017-02-24 00:30 +0100
    Re: [RFC/PATCH] of: Mark property::value as const Frank Rowand <frowand.list@gmail.com> - 2017-02-23 22:50 +0100
  Re: [RFC/PATCH] of: Mark property::value as const Frank Rowand <frowand.list@gmail.com> - 2017-02-24 00:10 +0100
    Re: [RFC/PATCH] of: Mark property::value as const Frank Rowand <frowand.list@gmail.com> - 2017-02-24 00:30 +0100
    Re: [RFC/PATCH] of: Mark property::value as const Rob Herring <robh+dt@kernel.org> - 2017-02-24 00:40 +0100

csiph-web