[PATCH] firmware: xilinx: fix out-of-bounds access

Arnd Bergmann arnd at kernel.org
Tue Oct 27 09:32:09 EDT 2020


On Tue, Oct 27, 2020 at 10:53 AM Michal Simek <michal.simek at xilinx.com> wrote:
> On 26. 10. 20 16:54, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd at arndb.de>
> >
> > The zynqmp_pm_set_suspend_mode() and zynqmp_pm_get_trustzone_version()
> > functions pass values as api_id into zynqmp_pm_invoke_fn
> > that are beyond PM_API_MAX, resulting in an out-of-bounds access:
> >
> > drivers/firmware/xilinx/zynqmp.c: In function 'zynqmp_pm_set_suspend_mode':
> > drivers/firmware/xilinx/zynqmp.c:150:24: warning: array subscript 2562 is above array bounds of 'u32[64]' {aka 'unsigned int[64]'} [-Warray-bounds]
> >   150 |  if (zynqmp_pm_features[api_id] != PM_FEATURE_UNCHECKED)
> >       |      ~~~~~~~~~~~~~~~~~~^~~~~~~~
> > drivers/firmware/xilinx/zynqmp.c:28:12: note: while referencing 'zynqmp_pm_features'
> >    28 | static u32 zynqmp_pm_features[PM_API_MAX];
> >       |            ^~~~~~~~~~~~~~~~~~
>
> Which CONFIG option/tool is reporting this issue?

This is with gcc-10. Commit 44720996e2d7 ("gcc-10: disable
'array-bounds' warning for
now") turned off this warning globally, but most of the reported warnings got
fixed in the meantime. I'm trying to take care of the rest so we can enabled it
again.

You should be able to reproduce the problem by removing the cc-disable-warning
line from the top-level Makefile.

        Arnd



More information about the linux-arm-kernel mailing list