Skip to content

Commit

Permalink
vboxsf: Use flexible arrays for trailing string member
Browse files Browse the repository at this point in the history
The declaration of struct shfl_string used trailing fake flexible arrays
for the string member. This was tripping FORTIFY_SOURCE since commit
df8fc4e ("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>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230720151458.never.673-kees@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
Kees Cook committed Jul 26, 2023
1 parent ec7633d commit a8f014e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/vboxsf/shfl_hostintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a8f014e

Please sign in to comment.