Message ID | Y7zB+s2AC6O+CRR+@work |
---|---|
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 p1csp2488249wrt; Mon, 9 Jan 2023 17:42:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXu9Af8lrEgyR/FU04u6VrdSC+Eqc5ujrMtdRKRrNKNSZTa9ImgKsUcsTWGpSF4l+d8NQCGy X-Received: by 2002:a05:6a20:9591:b0:b1:28a8:7c85 with SMTP id iu17-20020a056a20959100b000b128a87c85mr80667059pzb.13.1673314935174; Mon, 09 Jan 2023 17:42:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673314935; cv=none; d=google.com; s=arc-20160816; b=yqzM/Jx/Cc7dRwairr7DW8S/gT8/Kc6w83PaXCB/JWlU+yPoZwMHviI+PTKOAlaRxc 0A581w1iKnqrcOU12bmHOz6CdOVpiXO77ecWo/MUUK1WUDTrnzZkHCCpQMY0qfph46DB 6XZ/xkLi/s79rzuBaS52yEPNnT/6oGS1b3ErQzyok1FuNgTL9ZcGJLIOI9ipMSOLT5Cv 5bojS+EvBudvwVt5QxflKmQUBkdYqMXGlH3kDMKAofiaerMfYEkcidyVlIlYLX0nI6OS vHZPdbSai81yKiSmU4Y4b4cYuE5ozS20hovRWHHyJeNuBhXR0eJG5eCY8UGzc52hwR27 rIoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=34clBR1h2/8+2FGSMjp/L8pzBS1UvaUqHBCfD6E6hUM=; b=eTPK+ksjc9ctgnFnecgvDre8hrjSe7JSvtgmgRBZTE0AUl3zC9MyC1nT3JZ7goMeFZ qu5ZK8nqcXjYBYwiciWrBkRJbd6DSLoe6T6Tr/XYhBQtFwUnq0qJipVpFEbsro9tS3jA kDrU/sKAaFBGuMjzTwQqL/9a3l7MIzlKQgGQH5+/TalF5HN9Fiwqo5tgcHmiK4HY5DaI YTmmzYorioUYqMxQSeSLKt6GSP0bNxsoDtqZb49UlVfIgBbfOuXj4GdU1xDLYcskncPF rRl+QEnoa6czIOJpU/ptlx/zC3my9+K2xGErzWqA0L+RNjaGx8tytnPLFgo/qgvrgw1Z XrUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KwtiLhcC; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l191-20020a6391c8000000b004b42b4fff4esi1972537pge.795.2023.01.09.17.42.02; Mon, 09 Jan 2023 17:42:15 -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=@kernel.org header.s=k20201202 header.b=KwtiLhcC; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235173AbjAJBko (ORCPT <rfc822;syz17693488234@gmail.com> + 99 others); Mon, 9 Jan 2023 20:40:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235239AbjAJBkU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Jan 2023 20:40:20 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F6483AA84; Mon, 9 Jan 2023 17:40:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E9BF6B810B3; Tue, 10 Jan 2023 01:40:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08390C433F0; Tue, 10 Jan 2023 01:40:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673314802; bh=0XRaSMKMF65v6PaaPxlzlon39xDFwuy4Mex263cEfq4=; h=Date:From:To:Cc:Subject:From; b=KwtiLhcCuBFU6WjfUQ6rJ94CB4jppcI6FBU8LY0zR9y5h79fvwT0pD7J6BLNB38Sj dbTceFPZmncr0NGW9yhrQOn3ITkOD2igAiua9u5Rpe8LbCTc8JaWbKB+w7XJVMsxe5 gmRVI2NEZ+dTA4DEtFKOxN/COEj/NFZ6ZBU8AwLq7yo1jNcJ1HmA7+nCXf2WPVujVh nCW5qttlLdjJxes2Ypq54aRbsmlN+xjeb5rQXGuB4gr78vCwDVwJfGS1wjjl8Yp4qq pctcbBfSEACtXSpfYifbsWvD1NrgfpnU1+14USiscConIuEP/gNELSML0BuhqmwFbY MGiQ9b/tfoHVQ== Date: Mon, 9 Jan 2023 19:40:10 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= <rafal@milecki.pl>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] nvmem: u-boot-env: replace zero-length array with flexible-array member Message-ID: <Y7zB+s2AC6O+CRR+@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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?1754597881523709814?= X-GMAIL-MSGID: =?utf-8?q?1754597881523709814?= |
Series |
[next] nvmem: u-boot-env: replace zero-length array with flexible-array member
|
|
Commit Message
Gustavo A. R. Silva
Jan. 10, 2023, 1:40 a.m. UTC
Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
array declaration in struct u_boot_env_image_broadcom with flex-array
member.
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: https://github.com/KSPP/linux/issues/78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/nvmem/u-boot-env.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Mon, Jan 09, 2023 at 07:40:10PM -0600, Gustavo A. R. Silva wrote: > Zero-length arrays are deprecated[1] and we are moving towards > adopting C99 flexible-array members instead. So, replace zero-length > array declaration in struct u_boot_env_image_broadcom with flex-array > member. > > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE > routines on memcpy() and help us make progress towards globally > enabling -fstrict-flex-arrays=3 [2]. > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1] > Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2] > Link: https://github.com/KSPP/linux/issues/78 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
On 2023-01-10 02:40, Gustavo A. R. Silva wrote: > Zero-length arrays are deprecated[1] and we are moving towards > adopting C99 flexible-array members instead. So, replace zero-length > array declaration in struct u_boot_env_image_broadcom with flex-array > member. > > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE > routines on memcpy() and help us make progress towards globally > enabling -fstrict-flex-arrays=3 [2]. I also handled this issue in my [PATCH V2 4/6] nvmem: u-boot-env: convert to layout driver https://lore.kernel.org/linux-arm-kernel/20230111073102.8147-4-zajec5@gmail.com/
On Fri, Jan 13, 2023 at 07:41:02AM +0100, Rafał Miłecki wrote: > On 2023-01-10 02:40, Gustavo A. R. Silva wrote: > > Zero-length arrays are deprecated[1] and we are moving towards > > adopting C99 flexible-array members instead. So, replace zero-length > > array declaration in struct u_boot_env_image_broadcom with flex-array > > member. > > > > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE > > routines on memcpy() and help us make progress towards globally > > enabling -fstrict-flex-arrays=3 [2]. > > I also handled this issue in my > [PATCH V2 4/6] nvmem: u-boot-env: convert to layout driver > https://lore.kernel.org/linux-arm-kernel/20230111073102.8147-4-zajec5@gmail.com/ Ah-ha, thanks! Looks good. :)
diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c index 29b1d87a3c51..6b48637d9e64 100644 --- a/drivers/nvmem/u-boot-env.c +++ b/drivers/nvmem/u-boot-env.c @@ -45,7 +45,7 @@ struct u_boot_env_image_broadcom { __le32 magic; __le32 len; __le32 crc32; - uint8_t data[0]; + uint8_t data[]; } __packed; static int u_boot_env_read(void *context, unsigned int offset, void *val,