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/xen/xen-front-pgdir-shbuf.c #255

Closed
GustavoARSilva opened this issue Feb 3, 2023 · 1 comment
Assignees
Labels
1-element array arg in memcpy() [Idiom] fake flexible array [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/xen/xen-front-pgdir-shbuf.c:
 30 struct xen_page_directory {
 31         grant_ref_t gref_dir_next_page;
 32 #define XEN_GREF_LIST_END       0
 33         grant_ref_t gref[1]; /* Variable length */
 34 };

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

drivers/xen/xen-front-pgdir-shbuf.c-384-                memcpy(&page_dir->gref, &buf->grefs[cur_gref],
drivers/xen/xen-front-pgdir-shbuf.c-385-                       to_copy * sizeof(grant_ref_t));
@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
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Feb 14, 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 xen_page_directory.

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#79
Link: KSPP#255
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>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/Y9xjN6Wa3VslgXeX@work
Signed-off-by: Juergen Gross <jgross@suse.com>
@GustavoARSilva
Copy link
Collaborator Author

In mainline now.

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 [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