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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0jcDztpR4rn0JqksCDwbFzq8VD8nZG-9QypQo63y-h1Sg@mail.gmail.com>
Date:   Wed, 13 Apr 2022 20:21:41 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Rob Herring <robh@...nel.org>,
        ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        devicetree <devicetree@...r.kernel.org>,
        Daniel Scally <djrscally@...il.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        Len Brown <lenb@...nel.org>
Subject: Re: [PATCH v6 4/5] device property: Constify fwnode_handle_get()

On Wed, Apr 13, 2022 at 6:58 PM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> On Wed, Apr 13, 2022 at 05:35:46PM +0300, Sakari Ailus wrote:
> > On Sun, Apr 10, 2022 at 05:10:23PM +0300, Andy Shevchenko wrote:
> > > On Sat, Apr 9, 2022 at 2:35 AM Sakari Ailus
> > > <sakari.ailus@...ux.intel.com> wrote:
> > > > On Fri, Apr 08, 2022 at 09:48:43PM +0300, Andy Shevchenko wrote:
> > > > > As to_of_node() suggests and the way the code in the OF and software node
> > > > > back ends actually uses the fwnode handle, it may be constified. Do this
> > > > > for good.
> > > >
> > > > How?
> > > >
> > > > If the fwnode is const, then the struct it contains must be presumed to be
> > > > const, too.
> > >
> > > Why? The idea is that we are not updating the fwnode, but the container.
> > > The container may or may not be const. It's orthogonal, no?
> >
> > As you wrote: may or may not. The stricter requirement, i.e. const, must be
> > thus followed. I think it would be fine (after adding a comment on what is
> > being done) if you *know* the container struct is not const. But that is
> > not the case here.
>
> But even with the original code one may not guarantee that. How the original
> code works or prevents of using a const container against non-const fwnode
> pointer?

I don't think that this is the point here.

If const struct fwnode_handle *fwnode is passed to the ->get()
callback, the callback itself (and any function called by it)
shouldn't attempt to update the memory pointed to by fwnode.  It need
not be the memory starting at the fwnode address IIUC, so that would
cover the whole object the fwnode is embedded in.

This way the caller of ->get() can assume the immutability of the
memory passed to it for read access.

The question is whether or not ->get() needs to update the memory in
question.  If it doesn't, making fwnode const is correct.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ