From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19137EB64DA for ; Tue, 13 Jun 2023 22:51:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235733AbjFMWvP (ORCPT ); Tue, 13 Jun 2023 18:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbjFMWvN (ORCPT ); Tue, 13 Jun 2023 18:51:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37217EC; Tue, 13 Jun 2023 15:51:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C0DC363611; Tue, 13 Jun 2023 22:51:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B613C433C8; Tue, 13 Jun 2023 22:51:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686696671; bh=zVWmLSa3tOz3dzkcme4HlB9HKtQ3K2iGtgg1kJGmiRI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ePMi2Q+CTmtpgJVaIzPrukxiTC3TxB3QFM0s88Sryp7g8J8pap0u8KRphDdUOa+Hc 3n+gjevd+rbchrqK4t2C1AGaXtIUWAfKwlbnR4LjJwWOf42AsMGc5MSAt4EcLvTsGo RbyH9qwiqhUtcOHEDRlk0jRnI3n7YzvISckIc/nbWNKwchWGJt0cP+YWJGPUJ5hlsF 8HkgyK7aNwncdd/FWqY0Wu4FUsKEFKLyix7my73Xm5JYXhDZeZRuPQGPQwxeYUhzf1 7WsV7bPegyYRBugI8AdTh7llIeRbqerMKLniBHW5Cyp8KQe95Rg8dlg5pZF1neqnNG O/GAuthnXjn9A== Date: Tue, 13 Jun 2023 16:52:08 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Greg Kroah-Hartman , kernel test robot , kernel test robot , Dan Williams , =?iso-8859-1?Q?J=F3_=C1gila?= Bitsch , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] usb: ch9: Replace 1-element array with flexible array Message-ID: References: <20230613210400.never.078-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230613210400.never.078-kees@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 13, 2023 at 02:04:04PM -0700, Kees Cook wrote: > With "-fstrict-flex-arrays=3" enabled, 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 > Fixes: df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") I always have mixed feelings about a 'Fixes' tag applied to a commit like this (one that enables a compiler option that avoids the introduction of buggy code), when we are addressing the potentially buggy code that the option is inteded to prevent. (thinkingface) > 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 Reviewed-by: Gustavo A. R. Silva Thanks! -- Gustavo > --- > include/uapi/linux/usb/ch9.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h > index b17e3a21b15f..82ec6af71a1d 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 > -- > 2.34.1 >