linux/include/rdma
Gustavo A. R. Silva 155f04366e RDMA/uverbs: Avoid -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

There are currently a couple of objects (`alloc_head` and `bundle`) in
`struct bundle_priv` that contain a couple of flexible structures:

struct bundle_priv {
        /* Must be first */
        struct bundle_alloc_head alloc_head;

	...

        /*
         * Must be last. bundle ends in a flex array which overlaps
         * internal_buffer.
         */
        struct uverbs_attr_bundle bundle;
        u64 internal_buffer[32];
};

So, in order to avoid ending up with a couple of flexible-array members
in the middle of a struct, we use the `struct_group_tagged()` helper to
separate the flexible array from the rest of the members in the flexible
structures:

struct uverbs_attr_bundle {
        struct_group_tagged(uverbs_attr_bundle_hdr, hdr,
		... the rest of the members
        );
        struct uverbs_attr attrs[];
};

With the change described above, we now declare objects of the type of
the tagged struct without embedding flexible arrays in the middle of
another struct:

struct bundle_priv {
        /* Must be first */
        struct bundle_alloc_head_hdr alloc_head;

        ...

        struct uverbs_attr_bundle_hdr bundle;
        u64 internal_buffer[32];
};

We also use `container_of()` whenever we need to retrieve a pointer
to the flexible structures.

Notice that the `bundle_size` computed in `uapi_compute_bundle_size()`
remains the same.

So, with these changes, fix the following warnings:

drivers/infiniband/core/uverbs_ioctl.c:45:34: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
   45 |         struct bundle_alloc_head alloc_head;
      |                                  ^~~~~~~~~~
drivers/infiniband/core/uverbs_ioctl.c:67:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
   67 |         struct uverbs_attr_bundle bundle;
      |                                   ^~~~~~

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZeIgeZ5Sb0IZTOyt@neat
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
2024-03-03 15:38:44 +02:00
..
ib_addr.h RDMA/cma: Always set static rate to 0 for RoCE 2023-06-11 11:26:02 +03:00
ib_cache.h RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
ib_cm.h RDMA/cm: Use DLID from inbound/outbound PathRecords as the datapath DLID 2022-09-22 12:35:31 +03:00
ib_hdrs.h RDMA/mlx5: Add steering support in optional flow counters 2021-10-12 12:48:06 -03:00
ib_mad.h IB/mlx5: Expose XDR speed through MAD 2023-09-26 12:38:43 +03:00
ib_marshall.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
ib_pack.h RDMA: Extend RDMA kernel verbs ABI to support flush 2022-12-09 19:36:01 -04:00
ib_pma.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
ib_sa.h RDMA/cma: Refactor the inbound/outbound path records process flow 2023-01-10 10:49:50 +02:00
ib_smi.h RDMA/mad: Delete duplicated init_query_mad functions 2022-01-05 15:18:36 -04:00
ib_sysfs.h RDMA: Change ops->init_port to ops->port_groups 2021-06-16 20:58:31 -03:00
ib_umem_odp.h IB/core: Enable ODP sync without faulting 2020-10-01 16:44:05 -03:00
ib_umem.h RDMA/core: Fix umem iterator when PAGE_SIZE is greater then HCA pgsz 2023-12-04 20:02:41 -04:00
ib_verbs.h RDMA/uverbs: Remove flexible arrays from struct *_filter 2024-02-21 13:28:52 -04:00
ib.h uaccess: remove CONFIG_SET_FS 2022-02-25 09:36:06 +01:00
iba.h RDMA/cm: Add SET/GET implementations to hide IBA wire format 2020-01-25 15:05:59 -04:00
ibta_vol1_c12.h RDMA/cm: Add Enhanced Connection Establishment (ECE) bits 2020-05-27 16:05:05 -03:00
iw_cm.h RDMA Remove unused function declarations 2023-08-13 10:32:35 +03:00
iw_portmap.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
lag.h RDMA/core: Add LAG functionality 2020-05-02 20:19:54 -03:00
mr_pool.h Linux 5.2-rc6 2019-06-28 21:18:23 -03:00
opa_addr.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
opa_port_info.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
opa_smi.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
opa_vnic.h RDMA/opa_vnic: fix spelling typo in comment 2022-10-19 10:02:37 +03:00
rdma_cm_ib.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
rdma_cm.h RDMA/cma: Refactor the inbound/outbound path records process flow 2023-01-10 10:49:50 +02:00
rdma_counter.h RDMA/counter: Add optional counter support 2021-10-12 12:48:05 -03:00
rdma_netlink.h RDMA/netlink: Add __maybe_unused to static inline in C file 2021-11-16 13:13:08 -04:00
rdma_vt.h IB: move from strlcpy with unused retval to strscpy 2022-08-21 14:18:02 +03:00
rdmavt_cq.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
rdmavt_mr.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
rdmavt_qp.h RDMA/rdmavt: Decouple QP and SGE lists allocations 2021-08-03 13:44:27 -03:00
restrack.h RDMA/restrack: Correct spelling 2023-02-07 11:25:10 +02:00
rw.h RDMA: Support more than 255 rdma ports 2021-03-26 09:31:21 -03:00
signature.h RDMA: Make most headers compile stand alone 2019-07-25 13:58:47 -03:00
tid_rdma_defs.h IB/hfi1: Build TID RDMA WRITE request 2019-02-05 18:07:43 -05:00
uverbs_ioctl.h RDMA/uverbs: Avoid -Wflex-array-member-not-at-end warnings 2024-03-03 15:38:44 +02:00
uverbs_named_ioctl.h RDMA/uverbs: Make UVERBS_OBJECT_METHODS to consider line number 2021-04-13 19:36:35 -03:00
uverbs_std_types.h RDMA/include: Replace license text with SPDX tags 2020-07-29 14:48:36 -03:00
uverbs_types.h RDMA/uverbs: Allow drivers to create a new HW object during rereg_mr 2020-12-07 14:06:23 -04:00