Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace one-element array with flex-array member in drivers/gpu/drm/vmwgfx/vmwgfx_so.c #254

Closed
GustavoARSilva opened this issue Feb 3, 2023 · 0 comments
Assignees
Labels
1-element array arg in memcpy() [Idiom] fake flexible array [Linux] -next Present in linux-next; expected for next Linux release [PATCH] Accepted A submitted patch has been accepted upstream [PATCH] Exists A patch exists to address the issue [Refactor] 1-element array Conversion away from one-element array

Comments

@GustavoARSilva
Copy link
Collaborator

drivers/gpu/drm/vmwgfx/vmwgfx_so.c:
 61 struct vmw_view {
 62         struct rcu_head rcu;
 63         struct vmw_resource res;
 64         struct vmw_resource *ctx;      /* Immutable */
 65         struct vmw_resource *srf;      /* Immutable */
 66         struct vmw_resource *cotable;  /* Immutable */
 67         struct list_head srf_head;     /* Protected by binding_mutex */
 68         struct list_head cotable_head; /* Protected by binding_mutex */
 69         unsigned view_type;            /* Immutable */
 70         unsigned view_id;              /* Immutable */
 71         u32 cmd_size;                  /* Immutable */
 72         bool committed;                /* Protected by binding_mutex */
 73         u32 cmd[1];                     /* Immutable */
 74 };

Also, worth noting is that this fake flex-array is currently being used as argument in calls to memcpy():

drivers/gpu/drm/vmwgfx/vmwgfx_so.c:
memcpy(cmd, &view->cmd, view->cmd_size);
memcpy(&view->cmd, cmd, cmd_size);
@GustavoARSilva GustavoARSilva self-assigned this Feb 3, 2023
@GustavoARSilva GustavoARSilva added the [PATCH] Exists A patch exists to address the issue label Feb 3, 2023
jessfraz pushed a commit to jessfraz/linux that referenced this issue Mar 7, 2023
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: KSPP/linux#79
Link: KSPP/linux#254
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [1]
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Zack Rusin <zackr@vmware.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
@GustavoARSilva GustavoARSilva added the [Linux] -next Present in linux-next; expected for next Linux release label Mar 8, 2023
@GustavoARSilva GustavoARSilva added the [PATCH] Accepted A submitted patch has been accepted upstream label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-element array arg in memcpy() [Idiom] fake flexible array [Linux] -next Present in linux-next; expected for next Linux release [PATCH] Accepted A submitted patch has been accepted upstream [PATCH] Exists A patch exists to address the issue [Refactor] 1-element array Conversion away from one-element array
Projects
None yet
Development

No branches or pull requests

1 participant