Message ID | ZJTV61z4+lsKlzQG@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5407921vqr; Thu, 22 Jun 2023 16:29:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+O1G4eYAUEmFeqK3QuzzrMySKpDOSi1ZjsAMcOAQMWqtQyuJSLWFRznQKAqQWV5c71Hgz X-Received: by 2002:a05:6a00:13a3:b0:66a:2ff1:deee with SMTP id t35-20020a056a0013a300b0066a2ff1deeemr8238377pfg.7.1687476559847; Thu, 22 Jun 2023 16:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687476559; cv=none; d=google.com; s=arc-20160816; b=XVvtUUM+bkveoceTuGWSeD6JN4u6ayQ4aPRli+4t/+6LjBKfmhga4Q5FaFAyzfT1JT VVBvphyCMvWCB+e0nEObAulDkGGcpSaVrWzkleNZt4spSmTwFODYpYY21XoWLRWtkvRE gbJWrUIsOTd0O+PkP8++9bf4c4RtE26cnRVk6vYzSiv8CiNnblRzvpZUhb9qNC5dbj1p b13hd49ivhAoJNuWobYL8RhjvN/E2dn4r760wtM5JVvROcIHhJKOPwyRvgKm9tgNZSGM 44PYF0sQDBCzCg1YdEHS9nw5Ewg883ZztX7VMot6YX4mQR/CT/lSWgT+gUZBgpIqj1k7 YUxw== 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=SD2S+tz64XM3qUgv1klzKVmx2c2KHoJ+AyGGGU4XSmE=; b=flW6zfLoVbTXaXh5ZEUrOsOX/GEy34lbk84AT4boAuDwb2bhOBp7VnwX9c/1GA1ubs /zPwFHEH403zmZyeSsDIDGoGn1h9ZEmULunaM6cPGX8zlZ3vqggZ8sgc3GYHgc6dQ5fY C4G//jDZ7gd7G41xcBvZh1yhHSayPBgW6Pe1BhA2tKibkuwUKPRzwOlxZl3YuUnToqXM JlvXkFsSXKC08GMjdsqqLLv7YNcf+RkgDKrzUBco9UsQx5n4F2H1y2RQ08bkY5oQsg0w vQ7RtQ9QZ7fksi2rsR0GWAnPQa4hbasxcl5l/pf8rwfOXh1HVD2rI4xDV5h0cZ2wbu2I OO9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ucx7W2AB; 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 f6-20020aa79d86000000b0063b64166faesi7427482pfq.157.2023.06.22.16.29.07; Thu, 22 Jun 2023 16:29:19 -0700 (PDT) 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=ucx7W2AB; 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 S231539AbjFVXO1 (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Thu, 22 Jun 2023 19:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjFVXO0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 22 Jun 2023 19:14:26 -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 59BFA2955; Thu, 22 Jun 2023 16:13:57 -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 8E69E6192D; Thu, 22 Jun 2023 23:13:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A0E3C433C0; Thu, 22 Jun 2023 23:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687475636; bh=F5fKLwWsn2Ex3oJMKpK31v1vclgJv3wOl/KwcKpYG/M=; h=Date:From:To:Cc:Subject:From; b=ucx7W2ABWTBywvvU1AWEZ1mSnVbGErmem/s7WNHKglONcK+802866X9mZvB40h7+i CDuqaE6crrY8gdVxhdEthcYq2ZhQVG1CTqnzdjCcneLKgFVWVgQzTWYWF2j6REESPf Le0YlrKLx8VkZRn7H3KESPzkw+J1vSy1gv1dsW5Djdqiz8YMclYV5Lkeueem1TVhyA d/xYBfmgGsMVY8GxkjBmQGknX5CBNxu36mZDVghqhn0wY4SibTunxnV7/P00huAPxz Q1vFpaBHEI0EAYOoqC2/n90I6RedksmmZm8e+/P5am8elM7U0nBL2HSsXV7fQwgalK dIh56o1a/KMZg== Date: Thu, 22 Jun 2023 17:14:51 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: "David S. Miller" <davem@davemloft.net> Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] sparc: openpromio: Address -Warray-bounds warning Message-ID: <ZJTV61z4+lsKlzQG@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1769447420977224224?= X-GMAIL-MSGID: =?utf-8?q?1769447420977224224?= |
Series |
[next] sparc: openpromio: Address -Warray-bounds warning
|
|
Commit Message
Gustavo A. R. Silva
June 22, 2023, 11:14 p.m. UTC
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element array with flexible-array
member in struct openpromio.
Address the following warning found after building (with GCC-13) sparc
with sparc64_defconfig:
In function 'opromgetprop',
inlined from 'openprom_sunos_ioctl.isra' at drivers/sbus/char/openprom.c:312:11:
drivers/sbus/char/openprom.c:141:24: warning: array subscript 1 is above array bounds of 'char[1]' [-Warray-bounds=]
141 | op->oprom_array[len] = '\0';
| ~~~~~~~~~~~~~~~^~~~~
In file included from drivers/sbus/char/openprom.c:31:
arch/sparc/include/uapi/asm/openpromio.h: In function 'openprom_sunos_ioctl.isra':
arch/sparc/include/uapi/asm/openpromio.h:16:17: note: while referencing 'oprom_array'
16 | char oprom_array[1]; /* Holds property names and values. */
| ^~~~~~~~~~~
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -Warray-bounds.
This results in no differences in binary output.
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/322
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
arch/sparc/include/uapi/asm/openpromio.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
On Thu, Jun 22, 2023 at 05:14:51PM -0600, Gustavo A. R. Silva wrote: > One-element arrays are deprecated, and we are replacing them with flexible > array members instead. So, replace one-element array with flexible-array > member in struct openpromio. > > Address the following warning found after building (with GCC-13) sparc > with sparc64_defconfig: > In function 'opromgetprop', > inlined from 'openprom_sunos_ioctl.isra' at drivers/sbus/char/openprom.c:312:11: > drivers/sbus/char/openprom.c:141:24: warning: array subscript 1 is above array bounds of 'char[1]' [-Warray-bounds=] > 141 | op->oprom_array[len] = '\0'; > | ~~~~~~~~~~~~~~~^~~~~ > In file included from drivers/sbus/char/openprom.c:31: > arch/sparc/include/uapi/asm/openpromio.h: In function 'openprom_sunos_ioctl.isra': > arch/sparc/include/uapi/asm/openpromio.h:16:17: note: while referencing 'oprom_array' > 16 | char oprom_array[1]; /* Holds property names and values. */ > | ^~~~~~~~~~~ > > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE > routines on memcpy() and help us make progress towards globally > enabling -Warray-bounds. > > This results in no differences in binary output. > > Link: https://github.com/KSPP/linux/issues/79 > Link: https://github.com/KSPP/linux/issues/322 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
diff --git a/arch/sparc/include/uapi/asm/openpromio.h b/arch/sparc/include/uapi/asm/openpromio.h index d4494b679e99..2a73ec77aba6 100644 --- a/arch/sparc/include/uapi/asm/openpromio.h +++ b/arch/sparc/include/uapi/asm/openpromio.h @@ -10,10 +10,9 @@ * were chosen to be exactly equal to the SunOS equivalents. */ -struct openpromio -{ +struct openpromio { unsigned int oprom_size; /* Actual size of the oprom_array. */ - char oprom_array[1]; /* Holds property names and values. */ + char oprom_array[]; /* Holds property names and values. */ }; #define OPROMMAXPARAM 4096 /* Maximum size of oprom_array. */