Message ID | 20230105215706.never.027-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp513689wrt; Thu, 5 Jan 2023 14:02:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXsp0UeudP4ZujItSqhVaumNv50RLj33QpNog5BpyNvOfKG245PUr9Uvcu6MGCWdjPFXDbeO X-Received: by 2002:a05:6a20:9e05:b0:af:9391:449 with SMTP id ms5-20020a056a209e0500b000af93910449mr64019067pzb.45.1672956143262; Thu, 05 Jan 2023 14:02:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672956143; cv=none; d=google.com; s=arc-20160816; b=Sqg2G+mitcvzIny6feietQx49mreDdzaP3SFGaHwMW57kBBoYZ8OhlkQop5S0CdxC6 +T1X3UnAHoL2fJtC0c8VC2rcLmpOFenPFZbkh8YIkbB7XYXtEgWrI2yKSS8mr+1Eb1Ux +6dnT2uxYxp3dkn/EXZ3d+8kKLPXBRtHnZ3kJy5MM2B0KQNsN49pXi/84z5YK+EyxiNQ 2BxaA9qKCrw0dA6lKDTnO3/Px8lq19UxYNxwOw/PuRrbelCiTfmfNGGhkC2am1dVJ7Mb wxsZTr+f4R9aKHPZSVBjmusKgB7XxDVY2dOlM0WSrLbxFk/knYfFsprRkj0j7JcPcv2b esvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=d1UYEX8MsU4bEwMmiObVLxS4IPZo14Y0LIp/cyznldk=; b=y9YpxMvxjv3+i8ZJRbeWp731oByK2ybozhQZ7sRThjBDXt8dAfqwP81TRlf9lULTgN tgTj18pH3IPXUvS6lI6p360gt+gxip1IRmkvaKtFRPinUHOu16w0a+ALYgxV3ZSM/skQ iaRnIkHdb/I81hkNJhe1x3jDIhZtrXzepgLE4Wdcn086O/OOHY19rLnPZ06n5vMZpUIQ suPIK/iS3TFlvC/lWCxxYU8ObOLx3zHZClAR5MxzbYnyfpHyBL/wGrPtFPiFPPfo2e+w IUbC4L54DakhXQgar17fxk0OIgGWt5BUY0H7dj1e+goS45oZXepi4X/fN9HfTlA67pTb seYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HeOcmUiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 138-20020a630090000000b004a42c4cc051si8801981pga.657.2023.01.05.14.02.10; Thu, 05 Jan 2023 14:02:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HeOcmUiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235697AbjAEV5X (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Thu, 5 Jan 2023 16:57:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236112AbjAEV5P (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 5 Jan 2023 16:57:15 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A439F67BF0 for <linux-kernel@vger.kernel.org>; Thu, 5 Jan 2023 13:57:13 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id z9-20020a17090a468900b00226b6e7aeeaso3485392pjf.1 for <linux-kernel@vger.kernel.org>; Thu, 05 Jan 2023 13:57:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=d1UYEX8MsU4bEwMmiObVLxS4IPZo14Y0LIp/cyznldk=; b=HeOcmUiOtWV1+8PfRES0oRY+JONWF763kwgst44lTtXBPkP94fxrZ/VZYs1Kc/dGHr ikhnYe/UZqdVoOyCKb1taN3k4XST0BroOrYGU8yLnocvufrCNNLpQTbYCBoEgN37hKxW iBVkl02D5ywyFnBpZBmIPNf9xAzVMYo6varak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=d1UYEX8MsU4bEwMmiObVLxS4IPZo14Y0LIp/cyznldk=; b=dTTrXuPYqWT5+1nhom6a8kyxV65vRIeWaCJU7Y0k98jXEt5iLj5HAPe+HF89WfrlsO rk0dY2/h63bQV0stBchUtku2IStpdlHvXlZ3/VyG1631NfyWdJ6+yUn2UwxJHRH/cn43 ZttZH7obtNq/0BCY9e6pnpmfMcHa4tMPxcnvCx1gGWELrDD83LFIdaDdPxQAizCoR/pR hAaMyTlUUi5OlFu8LqDjjbgeepxzwYutir0lIuAcNG9iiTEyR4AEByqNccvxahCCi9kc pN48IQ6loRtspb2OtbzQmR4ShE+UaRzSzsveXWPxHEQGnILLHNR0AF6DB7Iiq37i+QvB QgnA== X-Gm-Message-State: AFqh2krijt36APUx1fkTVcK5QJPkyL3Nd2vJOtFiJgpcXvh5eUHCMCHc RUSpVY+Czevh6o9Kfuf+XdWSzw== X-Received: by 2002:a17:902:c10d:b0:186:8568:be7e with SMTP id 13-20020a170902c10d00b001868568be7emr58800196pli.15.1672955833062; Thu, 05 Jan 2023 13:57:13 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b15-20020a170903228f00b00182a9c27acfsm26530709plh.227.2023.01.05.13.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 13:57:12 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Krzysztof Halasa <khalasa@piap.pl> Cc: Kees Cook <keescook@chromium.org>, Linus Walleij <linus.walleij@linaro.org>, Arnd Bergmann <arnd@arndb.de>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] ARM: ixp4xx: Replace 0-length arrays with flexible arrays Date: Thu, 5 Jan 2023 13:57:10 -0800 Message-Id: <20230105215706.never.027-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2175; h=from:subject:message-id; bh=SvmvBLYwxKSOzLUuSIXZGbFL0TR/DpojohZSWMIMbSc=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjt0e2mOhkRvq1+sLpEol9eP3fGihD+cgpRMXX3kfQ mo/fQ/CJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7dHtgAKCRCJcvTf3G3AJmNKEA CoyZFzSYOZhQ5WleBkgUiHN1VwMNfMDvAmZvHcBNNPrnJYotSJw/QQscXFATgy5YPR9siAsQmysnZF HgoeHixgu4YBzaWQFZqk6+WQ3AzzY/8ynXTLwYv5uT0bSVtbJZIGl0xA2PJB407F1hfKb9h2BVtYlN 08nrxwdoEroAyxJC+S/PUA+F+DJ3v6x3u5ZgljnOWKmsg7s5MtzqRY8Ohd5r2dr/qbznZEfruhpcis mNwAq5oeoI0GwY3SoLHsF+O86GxNJA4T2DwHVzuMWU4C5Mor/uFA+RBzx8E5704CxeTAjtJMaZl7Ua Lj8VMJNKCHJo+gByL2l8wCZ1F5eGGuYFGDXHwCJO6V1edVAEpIqu9aOjqTc3WgLRtvfJlN0ISpwwDi bURxiAyLk0K09+01tJ1G0G2SmHvdZ2fDX1k89aI1J/Yi6wDAicfVEpDl6sCblrWQBpQLwJIeVGho4O v10LrSl5ZOcTLttRbKsyXXpVeqYymYq0kd1WiuM3QG3AYh6oZ5/kOA2BCICN2fSAWjCqX6W9GMlTkg XSjO4kRcAVimU4UMA+d+J7hidWAAtzPz1UyoHXBRbpKSa5MKGPoINK+CU14ahy3X5n/8BzbfJAnXmU W4UJFUYV6h2qUPgjFxg9h3e/1VrLS+cPWCCoJ0gd07CzarY77tjsCnBf0L1A== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754221660728477328?= X-GMAIL-MSGID: =?utf-8?q?1754221660728477328?= |
Series |
ARM: ixp4xx: Replace 0-length arrays with flexible arrays
|
|
Commit Message
Kees Cook
Jan. 5, 2023, 9:57 p.m. UTC
Zero-length arrays are deprecated[1]. Replace npe_load_firmware's
union of 0-length arrays with flexible arrays. Detected with GCC 13,
using -fstrict-flex-arrays=3:
drivers/soc/ixp4xx/ixp4xx-npe.c: In function 'npe_load_firmware':
drivers/soc/ixp4xx/ixp4xx-npe.c:570:60: warning: array subscript i is outside array bounds of 'u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=]
570 | image->data[i] = swab32(image->data[i]);
include/uapi/linux/swab.h:115:54: note: in definition of macro '__swab32'
115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
| ^
drivers/soc/ixp4xx/ixp4xx-npe.c:570:42: note: in expansion of macro 'swab32'
570 | image->data[i] = swab32(image->data[i]);
| ^~~~~~
drivers/soc/ixp4xx/ixp4xx-npe.c:522:29: note: while referencing 'data'
522 | u32 data[0];
| ^~~~
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
Cc: Krzysztof Halasa <khalasa@piap.pl>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/soc/ixp4xx/ixp4xx-npe.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Thu, Jan 5, 2023 at 10:57 PM Kees Cook <keescook@chromium.org> wrote: > Zero-length arrays are deprecated[1]. Replace npe_load_firmware's > union of 0-length arrays with flexible arrays. Detected with GCC 13, > using -fstrict-flex-arrays=3: > > drivers/soc/ixp4xx/ixp4xx-npe.c: In function 'npe_load_firmware': > drivers/soc/ixp4xx/ixp4xx-npe.c:570:60: warning: array subscript i is outside array bounds of 'u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=] > 570 | image->data[i] = swab32(image->data[i]); > include/uapi/linux/swab.h:115:54: note: in definition of macro '__swab32' > 115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) > | ^ > drivers/soc/ixp4xx/ixp4xx-npe.c:570:42: note: in expansion of macro 'swab32' > 570 | image->data[i] = swab32(image->data[i]); > | ^~~~~~ > drivers/soc/ixp4xx/ixp4xx-npe.c:522:29: note: while referencing 'data' > 522 | u32 data[0]; > | ^~~~ > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays > > Cc: Krzysztof Halasa <khalasa@piap.pl> > Cc: Linus Walleij <linus.walleij@linaro.org> > Cc: Arnd Bergmann <arnd@arndb.de> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: linux-arm-kernel@lists.infradead.org > Signed-off-by: Kees Cook <keescook@chromium.org> Looks good to me: Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Do you need me to funnel this to the SoC tree or do you have some quickpath for fixes like this? Yours, Linus Walleij
On Sun, Jan 08, 2023 at 12:58:37AM +0100, Linus Walleij wrote: > On Thu, Jan 5, 2023 at 10:57 PM Kees Cook <keescook@chromium.org> wrote: > > > Zero-length arrays are deprecated[1]. Replace npe_load_firmware's > > union of 0-length arrays with flexible arrays. Detected with GCC 13, > > using -fstrict-flex-arrays=3: > > > > drivers/soc/ixp4xx/ixp4xx-npe.c: In function 'npe_load_firmware': > > drivers/soc/ixp4xx/ixp4xx-npe.c:570:60: warning: array subscript i is outside array bounds of 'u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=] > > 570 | image->data[i] = swab32(image->data[i]); > > include/uapi/linux/swab.h:115:54: note: in definition of macro '__swab32' > > 115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) > > | ^ > > drivers/soc/ixp4xx/ixp4xx-npe.c:570:42: note: in expansion of macro 'swab32' > > 570 | image->data[i] = swab32(image->data[i]); > > | ^~~~~~ > > drivers/soc/ixp4xx/ixp4xx-npe.c:522:29: note: while referencing 'data' > > 522 | u32 data[0]; > > | ^~~~ > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays > > > > Cc: Krzysztof Halasa <khalasa@piap.pl> > > Cc: Linus Walleij <linus.walleij@linaro.org> > > Cc: Arnd Bergmann <arnd@arndb.de> > > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > > Cc: linux-arm-kernel@lists.infradead.org > > Signed-off-by: Kees Cook <keescook@chromium.org> > > Looks good to me: > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Thanks! > Do you need me to funnel this to the SoC tree or do you have > some quickpath for fixes like this? I'll take it via my tree if unless you'd rather it go through yours. Most maintainers take these directly, but some don't want to. I'm flexible! :)
On Thu, Jan 12, 2023 at 11:54 PM Kees Cook <keescook@chromium.org> wrote: > On Sun, Jan 08, 2023 at 12:58:37AM +0100, Linus Walleij wrote: > > On Thu, Jan 5, 2023 at 10:57 PM Kees Cook <keescook@chromium.org> wrote: > > > > > Zero-length arrays are deprecated[1]. Replace npe_load_firmware's > > > union of 0-length arrays with flexible arrays. Detected with GCC 13, > > > using -fstrict-flex-arrays=3: > > > > > > drivers/soc/ixp4xx/ixp4xx-npe.c: In function 'npe_load_firmware': > > > drivers/soc/ixp4xx/ixp4xx-npe.c:570:60: warning: array subscript i is outside array bounds of 'u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=] > > > 570 | image->data[i] = swab32(image->data[i]); > > > include/uapi/linux/swab.h:115:54: note: in definition of macro '__swab32' > > > 115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x)) > > > | ^ > > > drivers/soc/ixp4xx/ixp4xx-npe.c:570:42: note: in expansion of macro 'swab32' > > > 570 | image->data[i] = swab32(image->data[i]); > > > | ^~~~~~ > > > drivers/soc/ixp4xx/ixp4xx-npe.c:522:29: note: while referencing 'data' > > > 522 | u32 data[0]; > > > | ^~~~ > > > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays > > > > > > Cc: Krzysztof Halasa <khalasa@piap.pl> > > > Cc: Linus Walleij <linus.walleij@linaro.org> > > > Cc: Arnd Bergmann <arnd@arndb.de> > > > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > > > Cc: linux-arm-kernel@lists.infradead.org > > > Signed-off-by: Kees Cook <keescook@chromium.org> > > > > Looks good to me: > > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> > > Thanks! > > > Do you need me to funnel this to the SoC tree or do you have > > some quickpath for fixes like this? > > I'll take it via my tree if unless you'd rather it go through yours. > Most maintainers take these directly, but some don't want to. I'm > flexible! :) Just pick it into your tree, the IXP4xx is low activity and I do not submit new material every merge window, so this is easiest. Thanks! Linus Walleij
diff --git a/drivers/soc/ixp4xx/ixp4xx-npe.c b/drivers/soc/ixp4xx/ixp4xx-npe.c index 58240e320c13..5be9988f30ce 100644 --- a/drivers/soc/ixp4xx/ixp4xx-npe.c +++ b/drivers/soc/ixp4xx/ixp4xx-npe.c @@ -519,15 +519,15 @@ int npe_load_firmware(struct npe *npe, const char *name, struct device *dev) u32 id; u32 size; union { - u32 data[0]; - struct dl_block blocks[0]; + DECLARE_FLEX_ARRAY(u32, data); + DECLARE_FLEX_ARRAY(struct dl_block, blocks); }; } *image; struct dl_codeblock { u32 npe_addr; u32 size; - u32 data[0]; + u32 data[]; } *cb; int i, j, err, data_size, instr_size, blocks, table_end;