[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAL_JsqKu2yC_xaq6SY472XRxJr-pMp8msFQ2HeqppZ-16yhRzw@mail.gmail.com>
Date: Thu, 5 Sep 2024 09:54:07 -0500
From: Rob Herring <robh@...nel.org>
To: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Cc: Saravana Kannan <saravanak@...gle.com>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Nam Cao <namcao@...utronix.de>
Subject: Re: [PATCH] of: address: Report error on resource bounds overflow
On Thu, Sep 5, 2024 at 8:41 AM Thomas Weißschuh
<thomas.weissschuh@...utronix.de> wrote:
>
> On Thu, Sep 05, 2024 at 08:15:40AM GMT, Rob Herring wrote:
> > On Thu, Sep 5, 2024 at 2:46 AM Thomas Weißschuh
> > <thomas.weissschuh@...utronix.de> wrote:
> > >
> > > The members "start" and "end" of struct resource are of type
> > > "resource_size_t" which can be 32bit wide.
> > > Values read from OF however are always 64bit wide.
> > > Avoid silently truncating the value and instead return an error value.
> > >
> > > This can happen on real systems when the DT was created for a
> > > PAE-enabled kernel and a non-PAE kernel is actually running.
> > > For example with an arm defconfig and "qemu-system-arm -M virt".
> >
> > A nice follow-up would be to make of_pci_range_to_resource() use
> > overflows_type() as well instead of open coding it.
>
> Good catch.
>
> There are some differences though, it
> * returns -EINVAL on overflow instead of -EOVERFLOW
I think that is safe to change. I don't see any cases looking at the
specific errno. Note that of_range_to_resource() kerneldoc would need
updating too.
> * sets ->start and ->end to OF_BAD_ADDR on overflow
Don't need to do that. No user accesses the resource on error.
> * does not check ->end for overflow
Obviously we want to do that.
Rob
Powered by blists - more mailing lists