* [PATCH] vboxsf: Use flexible arrays for trailing string member
@ 2023-07-20 15:15 Kees Cook
2023-07-25 9:00 ` Hans de Goede
2023-07-26 21:55 ` Kees Cook
0 siblings, 2 replies; 5+ messages in thread
From: Kees Cook @ 2023-07-20 15:15 UTC (permalink / raw)
To: Hans de Goede
Cc: Kees Cook, Larry Finger, linux-kernel, linux-fsdevel, linux-hardening
The declaration of struct shfl_string used trailing fake flexible arrays
for the string member. This was tripping FORTIFY_SOURCE since commit
df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the
utf8 and utf16 members with actual flexible arrays, drop the unused ucs2
member, and retriain a 2 byte padding to keep the structure size the same.
Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Closes: https://lore.kernel.org/lkml/ab3a70e9-60ed-0f13-e3d4-8866eaccc8c1@lwfinger.net/
Tested-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
fs/vboxsf/shfl_hostintf.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/vboxsf/shfl_hostintf.h b/fs/vboxsf/shfl_hostintf.h
index aca829062c12..069a019c9247 100644
--- a/fs/vboxsf/shfl_hostintf.h
+++ b/fs/vboxsf/shfl_hostintf.h
@@ -68,9 +68,9 @@ struct shfl_string {
/** UTF-8 or UTF-16 string. Nul terminated. */
union {
- u8 utf8[2];
- u16 utf16[1];
- u16 ucs2[1]; /* misnomer, use utf16. */
+ u8 legacy_padding[2];
+ DECLARE_FLEX_ARRAY(u8, utf8);
+ DECLARE_FLEX_ARRAY(u16, utf16);
} string;
};
VMMDEV_ASSERT_SIZE(shfl_string, 6);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] vboxsf: Use flexible arrays for trailing string member
2023-07-20 15:15 [PATCH] vboxsf: Use flexible arrays for trailing string member Kees Cook
@ 2023-07-25 9:00 ` Hans de Goede
2023-07-26 21:55 ` Kees Cook
1 sibling, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2023-07-25 9:00 UTC (permalink / raw)
To: Kees Cook; +Cc: Larry Finger, linux-kernel, linux-fsdevel, linux-hardening
Hi Kees, Larry,
On 7/20/23 17:15, Kees Cook wrote:
> The declaration of struct shfl_string used trailing fake flexible arrays
> for the string member. This was tripping FORTIFY_SOURCE since commit
> df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the
> utf8 and utf16 members with actual flexible arrays, drop the unused ucs2
> member, and retriain a 2 byte padding to keep the structure size the same.
>
> Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
> Closes: https://lore.kernel.org/lkml/ab3a70e9-60ed-0f13-e3d4-8866eaccc8c1@lwfinger.net/
> Tested-by: Larry Finger <Larry.Finger@lwfinger.net>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Kees, Larry thank you for fixing this while I was on vacation.
The patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Kees, I'm the vboxsf maintainer and it would be easiest for
me if you can include this in a future 6.5 fixes pull-request
to Linus if that is possible ?
Regards,
Hans
> ---
> fs/vboxsf/shfl_hostintf.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/vboxsf/shfl_hostintf.h b/fs/vboxsf/shfl_hostintf.h
> index aca829062c12..069a019c9247 100644
> --- a/fs/vboxsf/shfl_hostintf.h
> +++ b/fs/vboxsf/shfl_hostintf.h
> @@ -68,9 +68,9 @@ struct shfl_string {
>
> /** UTF-8 or UTF-16 string. Nul terminated. */
> union {
> - u8 utf8[2];
> - u16 utf16[1];
> - u16 ucs2[1]; /* misnomer, use utf16. */
> + u8 legacy_padding[2];
> + DECLARE_FLEX_ARRAY(u8, utf8);
> + DECLARE_FLEX_ARRAY(u16, utf16);
> } string;
> };
> VMMDEV_ASSERT_SIZE(shfl_string, 6);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vboxsf: Use flexible arrays for trailing string member
2023-07-20 15:15 [PATCH] vboxsf: Use flexible arrays for trailing string member Kees Cook
2023-07-25 9:00 ` Hans de Goede
@ 2023-07-26 21:55 ` Kees Cook
2023-08-08 19:20 ` Larry Finger
1 sibling, 1 reply; 5+ messages in thread
From: Kees Cook @ 2023-07-26 21:55 UTC (permalink / raw)
To: Hans de Goede, Kees Cook
Cc: Larry Finger, linux-kernel, linux-fsdevel, linux-hardening
On Thu, 20 Jul 2023 08:15:06 -0700, Kees Cook wrote:
> The declaration of struct shfl_string used trailing fake flexible arrays
> for the string member. This was tripping FORTIFY_SOURCE since commit
> df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the
> utf8 and utf16 members with actual flexible arrays, drop the unused ucs2
> member, and retriain a 2 byte padding to keep the structure size the same.
>
>
> [...]
Applied to for-linus/hardening, thanks!
[1/1] vboxsf: Use flexible arrays for trailing string member
https://git.kernel.org/kees/c/a8f014ec6a21
Best regards,
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vboxsf: Use flexible arrays for trailing string member
2023-07-26 21:55 ` Kees Cook
@ 2023-08-08 19:20 ` Larry Finger
2023-08-08 21:01 ` Kees Cook
0 siblings, 1 reply; 5+ messages in thread
From: Larry Finger @ 2023-08-08 19:20 UTC (permalink / raw)
To: Kees Cook, Hans de Goede; +Cc: linux-kernel, linux-fsdevel, linux-hardening
On 7/26/23 16:55, Kees Cook wrote:
>
> On Thu, 20 Jul 2023 08:15:06 -0700, Kees Cook wrote:
>> The declaration of struct shfl_string used trailing fake flexible arrays
>> for the string member. This was tripping FORTIFY_SOURCE since commit
>> df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the
>> utf8 and utf16 members with actual flexible arrays, drop the unused ucs2
>> member, and retriain a 2 byte padding to keep the structure size the same.
>>
>>
>> [...]
>
> Applied to for-linus/hardening, thanks!
>
> [1/1] vboxsf: Use flexible arrays for trailing string member
> https://git.kernel.org/kees/c/a8f014ec6a21
Kees,
This patch has not been applied to kernel 6.5-rc5. Is there some problem?
Larry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vboxsf: Use flexible arrays for trailing string member
2023-08-08 19:20 ` Larry Finger
@ 2023-08-08 21:01 ` Kees Cook
0 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2023-08-08 21:01 UTC (permalink / raw)
To: Larry Finger; +Cc: Hans de Goede, linux-kernel, linux-fsdevel, linux-hardening
On Tue, Aug 08, 2023 at 02:20:06PM -0500, Larry Finger wrote:
> On 7/26/23 16:55, Kees Cook wrote:
> >
> > On Thu, 20 Jul 2023 08:15:06 -0700, Kees Cook wrote:
> > > The declaration of struct shfl_string used trailing fake flexible arrays
> > > for the string member. This was tripping FORTIFY_SOURCE since commit
> > > df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"). Replace the
> > > utf8 and utf16 members with actual flexible arrays, drop the unused ucs2
> > > member, and retriain a 2 byte padding to keep the structure size the same.
> > >
> > >
> > > [...]
> >
> > Applied to for-linus/hardening, thanks!
> >
> > [1/1] vboxsf: Use flexible arrays for trailing string member
> > https://git.kernel.org/kees/c/a8f014ec6a21
>
> Kees,
>
> This patch has not been applied to kernel 6.5-rc5. Is there some problem?
Hi! Sorry, I was waiting for linux-next testing, and then got distracted
on Friday. I will send the PR to Linus today.
Thanks for the poke!
-Kees
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-08 21:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 15:15 [PATCH] vboxsf: Use flexible arrays for trailing string member Kees Cook
2023-07-25 9:00 ` Hans de Goede
2023-07-26 21:55 ` Kees Cook
2023-08-08 19:20 ` Larry Finger
2023-08-08 21:01 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).