* [PATCH] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array
@ 2024-07-10 23:15 Kees Cook
2024-07-10 23:21 ` Gustavo A. R. Silva
2024-08-22 23:58 ` Kees Cook
0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2024-07-10 23:15 UTC (permalink / raw)
To: Hans de Goede
Cc: Kees Cook, Arnd Bergmann, Greg Kroah-Hartman, Gustavo A. R. Silva,
linux-hardening, linux-kernel
Replace the deprecated[1] use of a 1-element array in
struct vmmdev_hgcm_pagelist with a modern flexible array. As this is
UAPI, we cannot trivially change the size of the struct, so use a union
to retain the old first element's size, but switch "pages" to a flexible
array.
No binary differences are present after this conversion.
Link: https://github.com/KSPP/linux/issues/79 [1]
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-hardening@vger.kernel.org
---
include/uapi/linux/vbox_vmmdev_types.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h
index f8a8d6b3c521..6073858d52a2 100644
--- a/include/uapi/linux/vbox_vmmdev_types.h
+++ b/include/uapi/linux/vbox_vmmdev_types.h
@@ -282,7 +282,10 @@ struct vmmdev_hgcm_pagelist {
__u32 flags; /** VMMDEV_HGCM_F_PARM_*. */
__u16 offset_first_page; /** Data offset in the first page. */
__u16 page_count; /** Number of pages. */
- __u64 pages[1]; /** Page addresses. */
+ union {
+ __u64 unused; /** Deprecated place-holder for first "pages" entry. */
+ __DECLARE_FLEX_ARRAY(__u64, pages); /** Page addresses. */
+ };
};
VMMDEV_ASSERT_SIZE(vmmdev_hgcm_pagelist, 4 + 2 + 2 + 8);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array
2024-07-10 23:15 [PATCH] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array Kees Cook
@ 2024-07-10 23:21 ` Gustavo A. R. Silva
2024-08-22 23:58 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2024-07-10 23:21 UTC (permalink / raw)
To: Kees Cook, Hans de Goede
Cc: Arnd Bergmann, Greg Kroah-Hartman, Gustavo A. R. Silva,
linux-hardening, linux-kernel
On 10/07/24 17:15, Kees Cook wrote:
> Replace the deprecated[1] use of a 1-element array in
> struct vmmdev_hgcm_pagelist with a modern flexible array. As this is
> UAPI, we cannot trivially change the size of the struct, so use a union
> to retain the old first element's size, but switch "pages" to a flexible
> array.
>
> No binary differences are present after this conversion.
>
> Link: https://github.com/KSPP/linux/issues/79 [1]
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: linux-hardening@vger.kernel.org
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks
--
Gustavo
> ---
> include/uapi/linux/vbox_vmmdev_types.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/vbox_vmmdev_types.h b/include/uapi/linux/vbox_vmmdev_types.h
> index f8a8d6b3c521..6073858d52a2 100644
> --- a/include/uapi/linux/vbox_vmmdev_types.h
> +++ b/include/uapi/linux/vbox_vmmdev_types.h
> @@ -282,7 +282,10 @@ struct vmmdev_hgcm_pagelist {
> __u32 flags; /** VMMDEV_HGCM_F_PARM_*. */
> __u16 offset_first_page; /** Data offset in the first page. */
> __u16 page_count; /** Number of pages. */
> - __u64 pages[1]; /** Page addresses. */
> + union {
> + __u64 unused; /** Deprecated place-holder for first "pages" entry. */
> + __DECLARE_FLEX_ARRAY(__u64, pages); /** Page addresses. */
> + };
> };
> VMMDEV_ASSERT_SIZE(vmmdev_hgcm_pagelist, 4 + 2 + 2 + 8);
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array
2024-07-10 23:15 [PATCH] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array Kees Cook
2024-07-10 23:21 ` Gustavo A. R. Silva
@ 2024-08-22 23:58 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2024-08-22 23:58 UTC (permalink / raw)
To: Hans de Goede, Kees Cook
Cc: Arnd Bergmann, Greg Kroah-Hartman, Gustavo A. R. Silva,
linux-hardening, linux-kernel
On Wed, 10 Jul 2024 16:15:55 -0700, Kees Cook wrote:
> Replace the deprecated[1] use of a 1-element array in
> struct vmmdev_hgcm_pagelist with a modern flexible array. As this is
> UAPI, we cannot trivially change the size of the struct, so use a union
> to retain the old first element's size, but switch "pages" to a flexible
> array.
>
> No binary differences are present after this conversion.
>
> [...]
Applied to for-next/hardening, thanks!
[1/1] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array
https://git.kernel.org/kees/c/5ac86f0ed04b
Take care,
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-22 23:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-10 23:15 [PATCH] virt: vbox: struct vmmdev_hgcm_pagelist: Replace 1-element array with flexible array Kees Cook
2024-07-10 23:21 ` Gustavo A. R. Silva
2024-08-22 23:58 ` Kees Cook
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.