Skip to contentSkip to conversation

drm/nouveau/fb/ga102: Replace zero-length array of trailing structs with flex-array

PATCH RESEND In review Kees Cook 4 participants 5 messages Jan 3, 2023 – Jan 18, 2023

Subsystems (3)

v1 of 2 In review Latest is v2 →

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH RESEND 1/1 drm/nouveau/fb/ga102: Replace zero-length array of trailing structs with flex-array

Zero-length arrays are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Cc Ben Skeggs <[email protected]>
Cc Karol Herbst <[email protected]>
Cc Lyude Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Gourav Samaiya <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>

---
Sent before as: https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/nouveau/include/nvfw/hs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/include/nvfw/hs.h +1 -1
index 8c4cd08a7b5f..8b58b668fc0c 100644
@@ -52,7 +52,7 @@ struct nvfw_hs_load_header_v2 {
 	struct {
 		u32 offset;
 		u32 size;
-	} app[0];
+	} app[];
 };
 
 const struct nvfw_hs_load_header_v2 *nvfw_hs_load_header_v2(struct nvkm_subdev *, const void *);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Kees Cook

Zero-length arrays are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 10 lines
Cc Ben Skeggs <[email protected]>
Cc Karol Herbst <[email protected]>
Cc Lyude Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Gourav Samaiya <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>

Here is my RB again:

Thanks!
--
Gustavo

Quoted 22 lines

---
Sent before as: https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/nouveau/include/nvfw/hs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/include/nvfw/hs.h +1 -1
index 8c4cd08a7b5f..8b58b668fc0c 100644
@@ -52,7 +52,7 @@ struct nvfw_hs_load_header_v2 {
 	struct {
 		u32 offset;
 		u32 size;
-	} app[0];
+	} app[];
 };
 
 const struct nvfw_hs_load_header_v2 *nvfw_hs_load_header_v2(struct nvkm_subdev *, const void *);
Signature · 1 line
2.34.1
Reviewed-by
#2 lore raw
Quoted 24 lines · Gustavo A. R. Silva
Quoted 11 lines · Kees Cook

Zero-length arrays are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 10 lines
Cc Ben Skeggs <[email protected]>
Cc Karol Herbst <[email protected]>
Cc Lyude Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Gourav Samaiya <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Quoted 4 lines

Here is my RB again:

will push in a moment

Quoted 27 lines

Thanks!
--
Gustavo

Quoted 22 lines

---
Sent before as: https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/nouveau/include/nvfw/hs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/include/nvfw/hs.h +1 -2
index 8c4cd08a7b5f..8b58b668fc0c 100644
@@ -52,7 +52,7 @@ struct nvfw_hs_load_header_v2 {
      struct {
              u32 offset;
              u32 size;
-     } app[0];
+     } app[];
 };
 
 const struct nvfw_hs_load_header_v2 *nvfw_hs_load_header_v2(struct nvkm_subdev *, const void *);
--

2.34.1

#3 lore raw
Quoted 27 lines · Karol Herbst
Quoted 24 lines · Gustavo A. R. Silva
Quoted 21 lines · Kees Cook

Zero-length arrays are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Cc Ben Skeggs <[email protected]>
Cc Karol Herbst <[email protected]>
Cc Lyude Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Gourav Samaiya <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Quoted 9 lines
Quoted 4 lines

Here is my RB again:

will push in a moment

just noticed it's the same change than the other one... anyway, will push the oldest one

Quoted 27 lines
Quoted 27 lines

Thanks!
--
Gustavo

Quoted 22 lines

---
Sent before as: https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/nouveau/include/nvfw/hs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/include/nvfw/hs.h +1 -2
index 8c4cd08a7b5f..8b58b668fc0c 100644
@@ -52,7 +52,7 @@ struct nvfw_hs_load_header_v2 {
      struct {
              u32 offset;
              u32 size;
-     } app[0];
+     } app[];
 };
 
 const struct nvfw_hs_load_header_v2 *nvfw_hs_load_header_v2(struct nvkm_subdev *, const void *);
--

2.34.1

maintainer
#4 lore raw
In reply to Gustavo A. R. Silva

Hi! Sorry for the late response, I've had my head buried in some regressions from AMD for a while now and am now just catching up on my email.

Does this still need to be pushed upstream?

Quoted 54 lines · Gustavo A. R. Silva
Quoted 11 lines · Kees Cook

Zero-length arrays are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3.

Replace zero-length array with flexible-array member.

This results in no differences in binary output.

[1] https://github.com/KSPP/linux/issues/78

Quoted 10 lines
Cc Ben Skeggs <[email protected]>
Cc Karol Herbst <[email protected]>
Cc Lyude Paul <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Gourav Samaiya <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>

Here is my RB again:

Thanks!
--
Gustavo

Quoted 22 lines

---
Sent before as: https://lore.kernel.org/all/[email protected]/

---
 drivers/gpu/drm/nouveau/include/nvfw/hs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/include/nvfw/hs.h +1 -1
index 8c4cd08a7b5f..8b58b668fc0c 100644
@@ -52,7 +52,7 @@ struct nvfw_hs_load_header_v2 {
 	struct {
 		u32 offset;
 		u32 size;
-	} app[0];
+	} app[];
 };
 
 const struct nvfw_hs_load_header_v2 *nvfw_hs_load_header_v2(struct nvkm_subdev *, const void *);
Signature · 1 line
2.34.1
Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat