All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Kees Cook <keescook@chromium.org>
Cc: Potnuri Bharat Teja <bharat@chelsio.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] RDMA/cxgb4: Replace 0-length arrays with flexible arrays
Date: Sun, 8 Jan 2023 14:08:52 +0200	[thread overview]
Message-ID: <Y7qyVPlNBQaGbInf@unreal> (raw)
In-Reply-To: <20230105223225.never.252-kees@kernel.org>

On Thu, Jan 05, 2023 at 02:32:32PM -0800, Kees Cook wrote:
> Zero-length arrays are deprecated[1]. Replace all remaining
> 0-length arrays with flexible arrays. Detected with GCC 13, using
> -fstrict-flex-arrays=3:
> 
> In function 'build_rdma_write',
>     inlined from 'c4iw_post_send' at ../drivers/infiniband/hw/cxgb4/qp.c:1173:10:
> ../drivers/infiniband/hw/cxgb4/qp.c:597:38: warning: array subscript 0 is outside array bounds of 'struct fw_ri_immd[0]' [-Warray-bounds=]
>   597 |                 wqe->write.u.immd_src[0].r2 = 0;
>       |                 ~~~~~~~~~~~~~~~~~~~~~^~~
> ../drivers/infiniband/hw/cxgb4/t4fw_ri_api.h: In function 'c4iw_post_send':
> ../drivers/infiniband/hw/cxgb4/t4fw_ri_api.h:567:35: note: while referencing 'immd_src'
>   567 |                 struct fw_ri_immd immd_src[0];
>       |                                   ^~~~~~~~
> 
> Additionally drop the unused C99_NOT_SUPPORTED ifndef lines.
> 
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
> 
> Cc: Potnuri Bharat Teja <bharat@chelsio.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: linux-rdma@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  drivers/infiniband/hw/cxgb4/t4fw_ri_api.h | 26 ++++++-----------------
>  1 file changed, 6 insertions(+), 20 deletions(-)

<...>

>  #define FW_RI_SEND_WR_SENDOP_S		0
> @@ -618,12 +606,10 @@ struct fw_ri_rdma_write_cmpl_wr {
>  		struct fw_ri_isgl isgl_src;
>  	} u_cmpl;
>  	__be64 r3;
> -#ifndef C99_NOT_SUPPORTED
>  	union fw_ri_write {
> -		struct fw_ri_immd immd_src[0];
> -		struct fw_ri_isgl isgl_src[0];
> +		DECLARE_FLEX_ARRAY(struct fw_ri_immd, immd_src);
> +		DECLARE_FLEX_ARRAY(struct fw_ri_isgl, isgl_src);

smatch built from commit 40351132df3b ("strlen: add __builtin and
__fortify functions") produces the following warning:
drivers/infiniband/hw/cxgb4/t4fw_ri_api.h:575:17: warning: array of flexible structures

Is it expected? What will prevent from getting this warning from 0-day
build bots?

Thanks


>  	} u;
> -#endif
>  };
>  
>  struct fw_ri_rdma_read_wr {
> -- 
> 2.34.1
> 

  parent reply	other threads:[~2023-01-08 12:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 22:32 [PATCH] RDMA/cxgb4: Replace 0-length arrays with flexible arrays Kees Cook
2023-01-06 16:08 ` Gustavo A. R. Silva
2023-01-08 12:08 ` Leon Romanovsky [this message]
2023-01-14  1:03   ` Kees Cook
2023-01-15 10:13     ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y7qyVPlNBQaGbInf@unreal \
    --to=leon@kernel.org \
    --cc=bharat@chelsio.com \
    --cc=gustavoars@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.