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 E7646EB64D8 for ; Wed, 14 Jun 2023 18:13:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235565AbjFNSNv (ORCPT ); Wed, 14 Jun 2023 14:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236074AbjFNSNq (ORCPT ); Wed, 14 Jun 2023 14:13:46 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFE19269E for ; Wed, 14 Jun 2023 11:13:14 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6667e221f75so370624b3a.1 for ; Wed, 14 Jun 2023 11:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686766394; x=1689358394; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9HOVYsIp+BNVnNXEjvbG7xYR2tkPqgQfOST29RZSiA8=; b=Arq5vahp11WeWMMNstve4XfluDy7bBtG+2dZe+Hn8oTec/TdTu1J1xgtyS763yCl6m 1EcWD7rNKi5HD2gMEs/pF/VAXSVhyG1f80jSo8/fS4E//O2EMnWTBcTi59RKvJxqiUxa CxztbWoOlIqZGqtIVnuWbI99lX0McAmXHKe4c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686766394; x=1689358394; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9HOVYsIp+BNVnNXEjvbG7xYR2tkPqgQfOST29RZSiA8=; b=QAmO7lAeyEeogIPcas3oTlB170E5Ek+yQX/wqNEuFLrcQZe1eXvu03vIhLNaPZdZwV IVLLshUPH0eqVQcFY3bzr+7nx+X+zdz0b+aOZwqe09BFkbV85XQMS0FhXfN7PnBu+dPw cn0my1XZ5aNdIVB1KLlApStYCewmQiGJaN6AIK9BF9wQVC8tJ6ZrcEQf9eRm1xhdbicw dcMFGaDgZ8dT6qW1bsjJ/J2vKSVV1Owe5wOTGkrY5OQea7fRrB09hKAWjnQmttixIAtr Ozwo9vjZMLoBpMihOtkiK+g97yPoRLEfG2WifjljOYnismH1iYl7arRtU+FnOrsVpfPT ohJQ== X-Gm-Message-State: AC+VfDwyZr9mYI1BkonWJZwTHsfiESd6FkPhdtBnnN9Tq+ECCvR7UJ3e UXrwA4vfWjNMHxJcmMryuj47hw== X-Google-Smtp-Source: ACHHUZ4rxR6tIMcABwSIbciIoJJ2F5q64xk/3jB0Cwgn2jHH+rNv368YcOnktvJlNKTWTy4VhilYlg== X-Received: by 2002:a05:6a20:7d9d:b0:ee:f290:5b5e with SMTP id v29-20020a056a207d9d00b000eef2905b5emr2571456pzj.43.1686766394399; Wed, 14 Jun 2023 11:13:14 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id t11-20020a1709028c8b00b001ae0152d280sm12409104plo.193.2023.06.14.11.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 11:13:13 -0700 (PDT) From: Kees Cook To: Greg Kroah-Hartman Cc: Kees Cook , kernel test robot , kernel test robot , "Gustavo A. R. Silva" , Dan Williams , =?UTF-8?q?J=C3=B3=20=C3=81gila=20Bitsch?= , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v2] usb: ch9: Replace 1-element array with flexible array Date: Wed, 14 Jun 2023 11:13:11 -0700 Message-Id: <20230614181307.gonna.256-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1539; h=from:subject:message-id; bh=BC8U8xN+MrnnBw9m3tXW7ogZaXnoh7O6Bt+WmSFmWW0=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBkigM3X2rz4vWzN/vJib4rjtjbwXjlgC7OYE0iLv9o Dh/d+yyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZIoDNwAKCRCJcvTf3G3AJhojD/ 0bOCo6i5ny2n/wbMJ++PmMLUvPtE2oex8DssyDyhZW6+TthX26BDqiNXTKJnv+tPb3tRWFZ+wipDQ0 6ML+b8XpwIZDVx1cEG4/DlJxs8nWkQ2JnzEGVWZTV93GrBfc5iJvga7euh5RvYLGct2NQwP7YZv9PV AG5NI6VFGZZNCGs9tXDRGfzBdRZ+2sNuOnWHxDED6pLOF4fL1X5bZPkHlJTYDMOnOG4H1TXiP81X8b LOm95Fwn/1UCf4VoS9R46FEcwB26vocbJW6sq3SN+Zk2WAhLsuUzbRKsdaMdFk2VpFRqs+/kFGmJWh 77aJYX3bbeK4lNjHz/SV64LVBdAcUHmMkH83qwdOf/y4GUEjVwm3dE1NcsgKWsRarHy+mzXk86nDf7 KcFVnQ9LP/NsKdoxvjBVCq1ORvKILdg/R/iR3SsnJLoUiESfwJBBIhV7ZaZJY9n51WVOx14RC/XVhy leqJl9kxB6UMbTbcGhE/y8P8A0xaF/iW1yBpBq6BOAR/SrhgctRWl8u+BLablIOUj6Q76wfzTwd+HY 3V4MyhzWnMQpBESIUn+1e6b3CzY7anh36T4dhJN30EyoMlKtdSfk1SElTWDF2nm4L+yryrcmD+lIMM xQ0d4pPMoLiHlSTMPUqLkeHfvalyOMwlyoPvS4juREEsjDXovv2PKzWUEmuQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org 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 --- v2: fix commit log to avoid bogus Fixes tag (gustavo, gregkh) v1: https://lore.kernel.org/all/20230613210400.never.078-kees@kernel.org/ --- 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