diff mbox series

[next] drm/vmwgfx: Replace one-element array with flexible-array member

Message ID Y9xi7nFWRV3S9gCg@work (mailing list archive)
State Mainlined
Commit edfea16a6dae9c03bdc97babdd69960093263354
Headers show
Series [next] drm/vmwgfx: Replace one-element array with flexible-array member | expand

Commit Message

Gustavo A. R. Silva Feb. 3, 2023, 1:27 a.m. UTC
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element array with flexible-array
member in struct vmw_view.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].

This results in no differences in binary output.

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/254
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kees Cook Feb. 3, 2023, 5:54 p.m. UTC | #1
On Thu, Feb 02, 2023 at 07:27:10PM -0600, Gustavo A. R. Silva wrote:
> One-element arrays are deprecated, and we are replacing them with flexible
> array members instead. So, replace one-element array with flexible-array
> member in struct vmw_view.
> 
> This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
> routines on memcpy() and help us make progress towards globally
> enabling -fstrict-flex-arrays=3 [1].
> 
> This results in no differences in binary output.
> 
> Link: https://github.com/KSPP/linux/issues/79
> Link: https://github.com/KSPP/linux/issues/254
> Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Reviewed-by: Kees Cook <keescook@chromium.org>
Zack Rusin Feb. 3, 2023, 5:59 p.m. UTC | #2
On Thu, 2023-02-02 at 19:27 -0600, Gustavo A. R. Silva wrote:
> One-element arrays are deprecated, and we are replacing them with flexible
> array members instead. So, replace one-element array with flexible-array
> member in struct vmw_view.
> 
> This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
> routines on memcpy() and help us make progress towards globally
> enabling -fstrict-flex-arrays=3 [1].
> 
> This results in no differences in binary output.
> 
> Link:
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSPP%2Flinux%2Fissues%2F79&data=05%7C01%7Czackr%40vmware.com%7Ca3eb026ab82f44e3b1d708db0585bd84%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C638109844250628429%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=I7IzZMu692BHi68sJFTfSonR4OYW1Kd5D6CENIizrsw%3D&reserved=0
> Link:
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSPP%2Flinux%2Fissues%2F254&data=05%7C01%7Czackr%40vmware.com%7Ca3eb026ab82f44e3b1d708db0585bd84%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C638109844250628429%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Hk97x3i6xHOrq09iuDYojySU9H8ulvlArzGXoKrEDtU%3D&reserved=0
> Link:
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgcc.gnu.org%2Fpipermail%2Fgcc-patches%2F2022-October%2F602902.html&data=05%7C01%7Czackr%40vmware.com%7Ca3eb026ab82f44e3b1d708db0585bd84%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C638109844250628429%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2B3QRmhuEvEOem89Do6hpS3%2B5sFDcuS%2BWWh9yv6triog%3D&reserved=0
>  [1]
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
> index 4ea32b01efc0..0f696ccaddc6 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
> @@ -70,7 +70,7 @@ struct vmw_view {
>         unsigned view_id;              /* Immutable */
>         u32 cmd_size;                  /* Immutable */
>         bool committed;                /* Protected by binding_mutex */
> -       u32 cmd[1];                    /* Immutable */
> +       u32 cmd[];                     /* Immutable */
>  };
>  
>  static int vmw_view_create(struct vmw_resource *res);

Reviewed-by: Zack Rusin <zackr@vmware.com>

Will this go in through linux-next directly or do you want me to push it through
drm-misc-next?

z
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
index 4ea32b01efc0..0f696ccaddc6 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
@@ -70,7 +70,7 @@  struct vmw_view {
 	unsigned view_id;              /* Immutable */
 	u32 cmd_size;                  /* Immutable */
 	bool committed;                /* Protected by binding_mutex */
-	u32 cmd[1];                    /* Immutable */
+	u32 cmd[];		       /* Immutable */
 };
 
 static int vmw_view_create(struct vmw_resource *res);