Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: lirongqing <lirongqing@baidu.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH] RDMA/mlx5: Restore flow_attr-first layout in leftovers flow rules
Date: Thu, 17 Sep 2026 11:25:27 +0000	[thread overview]
Message-ID: <20260917112527.820AE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260917111722.1723-1-lirongqing@baidu.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] rdma: embedding struct with flexible array member not at end
--

commit 8e283bb18af02522e075bf4c88abcbec6ff60c4a
Author: Li RongQing <lirongqing@baidu.com>
RDMA/mlx5: Restore flow_attr-first layout in leftovers flow rules

This commit restores the original ordering of members in the leftovers
flow rule structs to fix an out-of-bounds read during flow rule creation.
By moving flow_attr to the front, the layout matches the offset calculations
expected by the flow creation code.

> diff --git a/drivers/infiniband/hw/mlx5/fs.c b/drivers/infiniband/hw/mlx5/fs.c
> index b155baee0017c..e27826c3087bf 100644
> --- a/drivers/infiniband/hw/mlx5/fs.c
> +++ b/drivers/infiniband/hw/mlx5/fs.c
> @@ -1651,8 +1651,8 @@ static struct mlx5_ib_flow_handler *create_leftovers_rule(struct mlx5_ib_dev *de
>  	struct mlx5_ib_flow_handler *handler = NULL;
>  
>  	static struct {
> -		struct ib_flow_spec_eth eth_flow;
>  		struct ib_flow_attr	flow_attr;
> +		struct ib_flow_spec_eth eth_flow;

[Severity: Low]
Does embedding struct ib_flow_attr at the beginning of this anonymous
structure violate the C standard for flexible array members?

Looking at struct ib_flow_attr, it contains a C99 flexible array member
union ib_flow_spec flows[] at the end. The C standard specifies that a
structure containing a flexible array member should not be embedded within
another structure, particularly as a non-last member.

While this ordering fixes the runtime offset calculation expected by
create_flow_rule(), does placing it before eth_flow trigger modern compiler
warnings like -Wflex-array-member-not-at-end?

>  	} leftovers_wc = { .flow_attr = { .num_of_specs = 1,
>  					  .size = sizeof(leftovers_wc) },
>  			   .eth_flow = {
> @@ -1662,8 +1662,8 @@ static struct mlx5_ib_flow_handler *create_leftovers_rule(struct mlx5_ib_dev *de
>  				   .val = { .dst_mac = { 0x1 } } } };
>  
>  	static struct {
> -		struct ib_flow_spec_eth eth_flow;
>  		struct ib_flow_attr	flow_attr;
> +		struct ib_flow_spec_eth eth_flow;

[Severity: Low]
Similarly, does this second anonymous struct declaration also embed
struct ib_flow_attr and its flexible array member improperly?

>  	} leftovers_uc = { .flow_attr = { .num_of_specs = 1,
>  					  .size = sizeof(leftovers_uc) },
>  			   .eth_flow = {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260917111722.1723-1-lirongqing@baidu.com?part=1

  reply	other threads:[~2026-09-17 11:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 11:17 [PATCH] RDMA/mlx5: Restore flow_attr-first layout in leftovers flow rules lirongqing
2026-09-17 11:25 ` sashiko-bot [this message]
2026-09-18  6:55 ` 答复: " Li,Rongqing
2026-09-23 12:41 ` Leon Romanovsky
2026-09-23 12:45   ` Leon Romanovsky
2026-09-23 15:45     ` Jason Gunthorpe

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=20260917112527.820AE1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox