linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scripts/dtc: Replace 0-length arrays with flexible arrays
@ 2023-01-27 22:41 Kees Cook
  2023-01-27 23:44 ` Rob Herring
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2023-01-27 22:41 UTC (permalink / raw)
  To: Rob Herring
  Cc: Kees Cook, Frank Rowand, devicetree, Gustavo A. R. Silva,
	linux-kernel, linux-hardening

Replace the 0-length array with a C99 flexible array. Seen with GCC 13
under -fstrict-flex-arrays:

In file included from ../lib/fdt_ro.c:2:
../lib/../scripts/dtc/libfdt/fdt_ro.c: In function 'fdt_get_name':
../lib/../scripts/dtc/libfdt/fdt_ro.c:319:24: warning: 'strrchr' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
  319 |                 leaf = strrchr(nameptr, '/');
      |                        ^~~~~~~~~~~~~~~~~~~~~

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: devicetree@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 scripts/dtc/libfdt/fdt.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/dtc/libfdt/fdt.h b/scripts/dtc/libfdt/fdt.h
index f2e68807f277..0c91aa7f67b5 100644
--- a/scripts/dtc/libfdt/fdt.h
+++ b/scripts/dtc/libfdt/fdt.h
@@ -35,14 +35,14 @@ struct fdt_reserve_entry {
 
 struct fdt_node_header {
 	fdt32_t tag;
-	char name[0];
+	char name[];
 };
 
 struct fdt_property {
 	fdt32_t tag;
 	fdt32_t len;
 	fdt32_t nameoff;
-	char data[0];
+	char data[];
 };
 
 #endif /* !__ASSEMBLY */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/dtc: Replace 0-length arrays with flexible arrays
  2023-01-27 22:41 [PATCH] scripts/dtc: Replace 0-length arrays with flexible arrays Kees Cook
@ 2023-01-27 23:44 ` Rob Herring
  2023-01-28  0:12   ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2023-01-27 23:44 UTC (permalink / raw)
  To: Kees Cook
  Cc: Frank Rowand, devicetree, Gustavo A. R. Silva, linux-kernel,
	linux-hardening

On Fri, Jan 27, 2023 at 4:41 PM Kees Cook <keescook@chromium.org> wrote:
>
> Replace the 0-length array with a C99 flexible array. Seen with GCC 13
> under -fstrict-flex-arrays:
>
> In file included from ../lib/fdt_ro.c:2:
> ../lib/../scripts/dtc/libfdt/fdt_ro.c: In function 'fdt_get_name':
> ../lib/../scripts/dtc/libfdt/fdt_ro.c:319:24: warning: 'strrchr' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
>   319 |                 leaf = strrchr(nameptr, '/');
>       |                        ^~~~~~~~~~~~~~~~~~~~~
>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Frank Rowand <frowand.list@gmail.com>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  scripts/dtc/libfdt/fdt.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Changes to dtc/libfdt go to upstream dtc first and then we sync them back.

Rob

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/dtc: Replace 0-length arrays with flexible arrays
  2023-01-27 23:44 ` Rob Herring
@ 2023-01-28  0:12   ` Kees Cook
  2023-01-28  0:24     ` Kees Cook
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2023-01-28  0:12 UTC (permalink / raw)
  To: Rob Herring
  Cc: Frank Rowand, devicetree, Gustavo A. R. Silva, linux-kernel,
	linux-hardening

On Fri, Jan 27, 2023 at 05:44:13PM -0600, Rob Herring wrote:
> On Fri, Jan 27, 2023 at 4:41 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > Replace the 0-length array with a C99 flexible array. Seen with GCC 13
> > under -fstrict-flex-arrays:
> >
> > In file included from ../lib/fdt_ro.c:2:
> > ../lib/../scripts/dtc/libfdt/fdt_ro.c: In function 'fdt_get_name':
> > ../lib/../scripts/dtc/libfdt/fdt_ro.c:319:24: warning: 'strrchr' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
> >   319 |                 leaf = strrchr(nameptr, '/');
> >       |                        ^~~~~~~~~~~~~~~~~~~~~
> >
> > Cc: Rob Herring <robh+dt@kernel.org>
> > Cc: Frank Rowand <frowand.list@gmail.com>
> > Cc: devicetree@vger.kernel.org
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > ---
> >  scripts/dtc/libfdt/fdt.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Changes to dtc/libfdt go to upstream dtc first and then we sync them back.

Ah-ha, I've found it: https://github.com/dgibson/dtc

Thanks!

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/dtc: Replace 0-length arrays with flexible arrays
  2023-01-28  0:12   ` Kees Cook
@ 2023-01-28  0:24     ` Kees Cook
  2023-01-29 21:20       ` Rob Herring
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2023-01-28  0:24 UTC (permalink / raw)
  To: Rob Herring
  Cc: Frank Rowand, devicetree, Gustavo A. R. Silva, linux-kernel,
	linux-hardening

On Fri, Jan 27, 2023 at 04:12:21PM -0800, Kees Cook wrote:
> On Fri, Jan 27, 2023 at 05:44:13PM -0600, Rob Herring wrote:
> > On Fri, Jan 27, 2023 at 4:41 PM Kees Cook <keescook@chromium.org> wrote:
> > >
> > > Replace the 0-length array with a C99 flexible array. Seen with GCC 13
> > > under -fstrict-flex-arrays:
> > >
> > > In file included from ../lib/fdt_ro.c:2:
> > > ../lib/../scripts/dtc/libfdt/fdt_ro.c: In function 'fdt_get_name':
> > > ../lib/../scripts/dtc/libfdt/fdt_ro.c:319:24: warning: 'strrchr' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
> > >   319 |                 leaf = strrchr(nameptr, '/');
> > >       |                        ^~~~~~~~~~~~~~~~~~~~~
> > >
> > > Cc: Rob Herring <robh+dt@kernel.org>
> > > Cc: Frank Rowand <frowand.list@gmail.com>
> > > Cc: devicetree@vger.kernel.org
> > > Signed-off-by: Kees Cook <keescook@chromium.org>
> > > ---
> > >  scripts/dtc/libfdt/fdt.h | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > Changes to dtc/libfdt go to upstream dtc first and then we sync them back.
> 
> Ah-ha, I've found it: https://github.com/dgibson/dtc

Sent upstream: https://github.com/dgibson/dtc/pull/76

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts/dtc: Replace 0-length arrays with flexible arrays
  2023-01-28  0:24     ` Kees Cook
@ 2023-01-29 21:20       ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2023-01-29 21:20 UTC (permalink / raw)
  To: Kees Cook
  Cc: Frank Rowand, devicetree, Gustavo A. R. Silva, linux-kernel,
	linux-hardening

On Fri, Jan 27, 2023 at 6:24 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Fri, Jan 27, 2023 at 04:12:21PM -0800, Kees Cook wrote:
> > On Fri, Jan 27, 2023 at 05:44:13PM -0600, Rob Herring wrote:
> > > On Fri, Jan 27, 2023 at 4:41 PM Kees Cook <keescook@chromium.org> wrote:
> > > >
> > > > Replace the 0-length array with a C99 flexible array. Seen with GCC 13
> > > > under -fstrict-flex-arrays:
> > > >
> > > > In file included from ../lib/fdt_ro.c:2:
> > > > ../lib/../scripts/dtc/libfdt/fdt_ro.c: In function 'fdt_get_name':
> > > > ../lib/../scripts/dtc/libfdt/fdt_ro.c:319:24: warning: 'strrchr' reading 1 or more bytes from a region of size 0 [-Wstringop-overread]
> > > >   319 |                 leaf = strrchr(nameptr, '/');
> > > >       |                        ^~~~~~~~~~~~~~~~~~~~~
> > > >
> > > > Cc: Rob Herring <robh+dt@kernel.org>
> > > > Cc: Frank Rowand <frowand.list@gmail.com>
> > > > Cc: devicetree@vger.kernel.org
> > > > Signed-off-by: Kees Cook <keescook@chromium.org>
> > > > ---
> > > >  scripts/dtc/libfdt/fdt.h | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > Changes to dtc/libfdt go to upstream dtc first and then we sync them back.
> >
> > Ah-ha, I've found it: https://github.com/dgibson/dtc
>
> Sent upstream: https://github.com/dgibson/dtc/pull/76

Maybe David will take that PR, but upstream is here[1]. Patches go to
devicetree-compiler@vger.kernel.org.

Rob

[1] https://git.kernel.org/pub/scm/utils/dtc/dtc.git

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-29 21:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 22:41 [PATCH] scripts/dtc: Replace 0-length arrays with flexible arrays Kees Cook
2023-01-27 23:44 ` Rob Herring
2023-01-28  0:12   ` Kees Cook
2023-01-28  0:24     ` Kees Cook
2023-01-29 21:20       ` Rob Herring

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).