Message ID | 20230105222115.never.661-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 p1csp522148wrt; Thu, 5 Jan 2023 14:26:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXv0OIAMvKwVbGByL0Zhu1xG2Bv3jSbGwwZMyM7hmLSNh2R2lepdyHWkwgVxC9KSGw7TBryg X-Received: by 2002:a05:6402:2217:b0:48b:c8de:9d15 with SMTP id cq23-20020a056402221700b0048bc8de9d15mr18088249edb.1.1672957607236; Thu, 05 Jan 2023 14:26:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672957607; cv=none; d=google.com; s=arc-20160816; b=cn0ohVPU35/owKNfYzlXPKC00GwOwtXeVN90i62AoeZuwkGV20VAsCXK7CRJopo536 BTnC6TqMDWILszMRiKGqnecO95J3/cx0coGu4zsPR4T0hidC6O+kLzABWVc/bJxy0QNx 2VgYYNQ83FaU7TsSutsleatKWeZ4PPBbf4pfsn/vsBPN0pbHkKxqNej+w/7u5ZAq6GDH b4SsTpvvyPz0rINK9q5ejd0mIRUgDw1/29HRJimBMnmsOk3ObP4aj7zFVSVEU2rG0dWA 2DDQQ42l2D+cJgHNPgnspgVp+8z8HlpEA8CL858iLGlQ5Z4An+D+oQINOeHv72G/0rCc ZK8g== 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=+/rwlFIn0hzbcNETA4wyU6wemvJ1Z4GiTdDdXZcLwaY=; b=Lb/EzOZ6FkDw9WtfTjp/HVKtO9kSp9M8hNokCuRGdzgL89neocNGwJOHb1TZcjgtPY PtAIFtbWwrg0hC5FfC9cPnXZ1VGSQLh04GGKSW+DaWBFqpG5s7LhOXexYfFCcR13tzps A14c48KXCoQAB/+gbywTba5ianMUBNCWJ62CHA72OtI6eme8Sj7yNnMoF3HUTPB6OKig rw2l1J59u4twSVSLNIOJE3nRassHDol8+7/vUWG7lqCVsz2JNkk85JkgG5slDy6F7m4f XMAKytPRSTLUyri4KtmKciG0PMByOaf10q7oCTkWYLc/7gJ+tkz/nUmUtsjILKlF7GAr eVvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dkTzAk+1; 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 f10-20020a056402150a00b0048ec4a278besi7773094edw.606.2023.01.05.14.26.10; Thu, 05 Jan 2023 14:26:47 -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=dkTzAk+1; 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 S235815AbjAEWVX (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Thu, 5 Jan 2023 17:21:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjAEWVU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 5 Jan 2023 17:21:20 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0B469528 for <linux-kernel@vger.kernel.org>; Thu, 5 Jan 2023 14:21:20 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id 124so26420797pfy.0 for <linux-kernel@vger.kernel.org>; Thu, 05 Jan 2023 14:21:20 -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=+/rwlFIn0hzbcNETA4wyU6wemvJ1Z4GiTdDdXZcLwaY=; b=dkTzAk+1ntj0auXOIzhxwO3g6qxTLW5rcQufexl+8slQLretMtDK9f5HKR4Aliyo39 TBXDLPSZZ+cPoJEh5357XW2coZYeq+1e9MNXq7GSKaeRBrIVMhLdSL2gmSWInW2aRur7 qX5tn4dbTdyy53FZ/I69t664nI2sKKOffks2Y= 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=+/rwlFIn0hzbcNETA4wyU6wemvJ1Z4GiTdDdXZcLwaY=; b=hJT/WBghWGdy5XdGnp0fEEXiU+PVXnnCM0zc0bXxoM+8g8Qf+6we0KLckxmkXNhwAN K4V99F2sVX7Yy0mZu/cqKUA6eZ8GdbXQsD/y6B2EsEZxDRrLgqTlLgBD1WDGiOnODAiM 7P/5SZJ0aiSiaoHlKMhbcFhse1bXdi0c04V8OOadzerW4+oMq16YLA/ZHi8IcbCLy7y8 vxBuuqIEMhRkOZD79DujWGJR4MTSBqjcY7YJgYJjZKTMHpZ6uUTDhwDpgLw8gi3OKdjd R/QUGS06zkiiQ0T6jl6TEnVgni/ugKl0Wfl3E2EFU6JV0DKgg10Ga/BVaIxYJOdhm5W9 e9YA== X-Gm-Message-State: AFqh2kqfVeMYSjUfh5Rg3ZgzM5GKjnSjQuSuDTltV4NcxKkt+zoNsVW1 II/M5Sn/dy9Qc/wa4lvjavNH5w== X-Received: by 2002:a62:6d82:0:b0:580:da4d:d42a with SMTP id i124-20020a626d82000000b00580da4dd42amr41325570pfc.14.1672957279547; Thu, 05 Jan 2023 14:21:19 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 68-20020a621947000000b00580e679dcf2sm21861943pfz.157.2023.01.05.14.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 14:21:19 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: "David S. Miller" <davem@davemloft.net> Cc: Kees Cook <keescook@chromium.org>, Jakub Kicinski <kuba@kernel.org>, Justin Iurman <justin.iurman@uliege.be>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] ipv6: ioam: Replace 0-length array with flexible array Date: Thu, 5 Jan 2023 14:21:16 -0800 Message-Id: <20230105222115.never.661-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1685; h=from:subject:message-id; bh=8PkLlA/lLOXSW+eJB32T+aG9Kn60zUa4hKXC+rzMGLs=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjt01cz7/LecK3nXxfm63JdHDplN1K4Q+y5tGGGSPM pUHKzwGJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7dNXAAKCRCJcvTf3G3AJvCJD/ 9dtKcuau0YnqLh8x7WrForeOZfMnYtRszMXUYKVft4FOrOsQ1BAzfridH4lEFedSI0AKz34hSCQxNI 9pU9cHvUjhC/gCo/ssOAQl9wJJ4HZhUqFWjzKpAHuaHE3e1VRoOJYt6L/RoF0EjE0XlVCLMZ9x1Vqs r+Le39VVbucfueuZyrYi9EzDHAw3zF46MNjMcq+m/FWvq4/n+g79tmQRJqEmUeLr2eHVdXqu+AI39R /t6xkHYShlreOKfsg4+qeySTppv/Go0fNAkVuU6ExrA/f6uWBZUQxb8NhSgRcR7U9RF1O3YydmqOFN cqzv7/8m6aUw9mxIojwCPpM+cn1jvTR13BLgwVYe5m+RW4LxUceL04xi/L1YZEhALEWzDXj+gWxotQ GVhwpNAPpztHLjX8fY0Jdzu3Pk8iAPFfqQkl1YNz89kk2bPNyuCDKjBPyGHzeK4x6GNgbKkQZ68Ilm TroxxrefIN30wEIhaLki1WABr+rZs0neuiRFkMMtfZAkA9PbdO1iIb260Ei+FbNutOcTYx1AZR6v7b Mcm1Dx0wF27u+OS0E6bME4TPp/JN3R6YpcsFNUa37xsXm/z7wfsjF10gPcUaMWTHbKaGIXG4X4Z+dc nPIUp2LUnE7439+DrZRdr9Nc/UhV8/G+2Hu+dkW97XuczBseF8nZVsKhlUvQ== 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?1754223195804419130?= X-GMAIL-MSGID: =?utf-8?q?1754223195804419130?= |
Series |
ipv6: ioam: Replace 0-length array with flexible array
|
|
Commit Message
Kees Cook
Jan. 5, 2023, 10:21 p.m. UTC
Zero-length arrays are deprecated[1]. Replace struct ioam6_trace_hdr's
"data" 0-length array with a flexible array. Detected with GCC 13,
using -fstrict-flex-arrays=3:
net/ipv6/ioam6_iptunnel.c: In function 'ioam6_build_state':
net/ipv6/ioam6_iptunnel.c:194:37: warning: array subscript <unknown> is outside array bounds of '__u8[0]' {aka 'unsigned char[]'} [-Warray-bounds=]
194 | tuninfo->traceh.data[trace->remlen * 4] = IPV6_TLV_PADN;
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from include/linux/ioam6.h:11,
from net/ipv6/ioam6_iptunnel.c:13:
include/uapi/linux/ioam6.h:130:17: note: while referencing 'data'
130 | __u8 data[0];
| ^~~~
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Justin Iurman <justin.iurman@uliege.be>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
include/uapi/linux/ioam6.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Jan 05, 2023 at 02:21:16PM -0800, Kees Cook wrote: > Zero-length arrays are deprecated[1]. Replace struct ioam6_trace_hdr's > "data" 0-length array with a flexible array. Detected with GCC 13, > using -fstrict-flex-arrays=3: > > net/ipv6/ioam6_iptunnel.c: In function 'ioam6_build_state': > net/ipv6/ioam6_iptunnel.c:194:37: warning: array subscript <unknown> is outside array bounds of '__u8[0]' {aka 'unsigned char[]'} [-Warray-bounds=] > 194 | tuninfo->traceh.data[trace->remlen * 4] = IPV6_TLV_PADN; > | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ > In file included from include/linux/ioam6.h:11, > from net/ipv6/ioam6_iptunnel.c:13: > include/uapi/linux/ioam6.h:130:17: note: while referencing 'data' > 130 | __u8 data[0]; > | ^~~~ > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays > > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Justin Iurman <justin.iurman@uliege.be> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks! -- Gustavo > --- > include/uapi/linux/ioam6.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/linux/ioam6.h b/include/uapi/linux/ioam6.h > index ac4de376f0ce..8f72b24fefb3 100644 > --- a/include/uapi/linux/ioam6.h > +++ b/include/uapi/linux/ioam6.h > @@ -127,7 +127,7 @@ struct ioam6_trace_hdr { > #endif > > #define IOAM6_TRACE_DATA_SIZE_MAX 244 > - __u8 data[0]; > + __u8 data[]; > } __attribute__((packed)); > > #endif /* _UAPI_LINUX_IOAM6_H */ > -- > 2.34.1 >
On 1/5/23 23:21, Kees Cook wrote: > Zero-length arrays are deprecated[1]. Replace struct ioam6_trace_hdr's > "data" 0-length array with a flexible array. Detected with GCC 13, > using -fstrict-flex-arrays=3: > > net/ipv6/ioam6_iptunnel.c: In function 'ioam6_build_state': > net/ipv6/ioam6_iptunnel.c:194:37: warning: array subscript <unknown> is outside array bounds of '__u8[0]' {aka 'unsigned char[]'} [-Warray-bounds=] > 194 | tuninfo->traceh.data[trace->remlen * 4] = IPV6_TLV_PADN; > | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ > In file included from include/linux/ioam6.h:11, > from net/ipv6/ioam6_iptunnel.c:13: > include/uapi/linux/ioam6.h:130:17: note: while referencing 'data' > 130 | __u8 data[0]; > | ^~~~ > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays > > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Justin Iurman <justin.iurman@uliege.be> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Justin Iurman <justin.iurman@uliege.be> Tested-by: Justin Iurman <justin.iurman@uliege.be> LGTM, thanks. > --- > include/uapi/linux/ioam6.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/linux/ioam6.h b/include/uapi/linux/ioam6.h > index ac4de376f0ce..8f72b24fefb3 100644 > --- a/include/uapi/linux/ioam6.h > +++ b/include/uapi/linux/ioam6.h > @@ -127,7 +127,7 @@ struct ioam6_trace_hdr { > #endif > > #define IOAM6_TRACE_DATA_SIZE_MAX 244 > - __u8 data[0]; > + __u8 data[]; > } __attribute__((packed)); > > #endif /* _UAPI_LINUX_IOAM6_H */
Hello: This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <kuba@kernel.org>: On Thu, 5 Jan 2023 14:21:16 -0800 you wrote: > Zero-length arrays are deprecated[1]. Replace struct ioam6_trace_hdr's > "data" 0-length array with a flexible array. Detected with GCC 13, > using -fstrict-flex-arrays=3: > > net/ipv6/ioam6_iptunnel.c: In function 'ioam6_build_state': > net/ipv6/ioam6_iptunnel.c:194:37: warning: array subscript <unknown> is outside array bounds of '__u8[0]' {aka 'unsigned char[]'} [-Warray-bounds=] > 194 | tuninfo->traceh.data[trace->remlen * 4] = IPV6_TLV_PADN; > | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ > In file included from include/linux/ioam6.h:11, > from net/ipv6/ioam6_iptunnel.c:13: > include/uapi/linux/ioam6.h:130:17: note: while referencing 'data' > 130 | __u8 data[0]; > | ^~~~ > > [...] Here is the summary with links: - ipv6: ioam: Replace 0-length array with flexible array https://git.kernel.org/netdev/net-next/c/0b5dfa35da03 You are awesome, thank you!
diff --git a/include/uapi/linux/ioam6.h b/include/uapi/linux/ioam6.h index ac4de376f0ce..8f72b24fefb3 100644 --- a/include/uapi/linux/ioam6.h +++ b/include/uapi/linux/ioam6.h @@ -127,7 +127,7 @@ struct ioam6_trace_hdr { #endif #define IOAM6_TRACE_DATA_SIZE_MAX 244 - __u8 data[0]; + __u8 data[]; } __attribute__((packed)); #endif /* _UAPI_LINUX_IOAM6_H */