From: Kees Cook Date: Wed, 14 Jun 2023 18:13:11 +0000 (-0700) Subject: usb: ch9: Replace 1-element array with flexible array X-Git-Tag: v6.6.7~2446^2~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09b69dd4378b91b3ac3fbac387fb992dc21c0f88;p=platform%2Fkernel%2Flinux-starfive.git usb: ch9: Replace 1-element array with flexible array Since commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"), UBSAN_BOUNDS no longer pretends 1-element arrays are unbounded. Walking wData will trigger a warning, so make it a proper flexible array. Add a union to keep the struct size identical for userspace in case anything was depending on the old size. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202306102333.8f5a7443-oliver.sang@intel.com Cc: Greg Kroah-Hartman Cc: kernel test robot Cc: "Gustavo A. R. Silva" Cc: Dan Williams Cc: "Jó Ágila Bitsch" Signed-off-by: Kees Cook Message-ID: <20230614181307.gonna.256-kees@kernel.org> Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index b17e3a2..82ec6af 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -376,7 +376,10 @@ struct usb_string_descriptor { __u8 bLength; __u8 bDescriptorType; - __le16 wData[1]; /* UTF-16LE encoded */ + union { + __le16 legacy_padding; + __DECLARE_FLEX_ARRAY(__le16, wData); /* UTF-16LE encoded */ + }; } __attribute__ ((packed)); /* note that "string" zero is special, it holds language codes that