Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix -Wstringop-overflow warning in drivers/infiniband/hw/mlx4/main.c #308

Closed
GustavoARSilva opened this issue Jun 13, 2023 · 1 comment
Closed
Labels
-Wstringop-overflow Emits warnings under -Wstringop-overflow

Comments

@GustavoARSilva
Copy link
Collaborator

GustavoARSilva commented Jun 13, 2023

Found in s390 with defconfig

drivers/infiniband/hw/mlx4/main.c:296:33: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
@kees kees added the -Wstringop-overflow Emits warnings under -Wstringop-overflow label Jun 14, 2023
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 15, 2023
Copy union directly instead of using memcpy().

Note that in this case, a direct assignment is more readable and
consistent with the subsequent assignments.

This addresses the following -Wstringop-overflow warning seen in s390
with defconfig:
drivers/infiniband/hw/mlx4/main.c:296:33: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
  296 |                                 memcpy(&port_gid_table->gids[free].gid,
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  297 |                                        &attr->gid, sizeof(attr->gid));
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This helps with the ongoing efforts to globally enable
-Wstringop-overflow.

Link: KSPP#308
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
rleon pushed a commit to Mellanox/nic-kernel that referenced this issue Aug 20, 2023
Copy union directly instead of using memcpy().

Note that in this case, a direct assignment is more readable and
consistent with the subsequent assignments.

This addresses the following -Wstringop-overflow warning seen in s390
with defconfig:
drivers/infiniband/hw/mlx4/main.c:296:33: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
  296 |                                 memcpy(&port_gid_table->gids[free].gid,
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  297 |                                        &attr->gid, sizeof(attr->gid));
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This helps with the ongoing efforts to globally enable
-Wstringop-overflow.

Link: KSPP/linux#308
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ZNvimeRAPkJ24zRG@work
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
@GustavoARSilva
Copy link
Collaborator Author

fixed in commit 18ddaeb

bella485 pushed a commit to bella485/centos-stream-9 that referenced this issue May 1, 2024
JIRA: https://issues.redhat.com/browse/RHEL-24474
Upstream-status: v6.6-rc1

commit 18ddaeb03bdb65b84fece11a8cac5bf583ae1b91
Author: Gustavo A. R. Silva <gustavoars@kernel.org>
Date:   Tue Aug 15 14:39:53 2023 -0600

    RDMA/mlx4: Copy union directly

    Copy union directly instead of using memcpy().

    Note that in this case, a direct assignment is more readable and
    consistent with the subsequent assignments.

    This addresses the following -Wstringop-overflow warning seen in s390
    with defconfig:
    drivers/infiniband/hw/mlx4/main.c:296:33: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
      296 |                                 memcpy(&port_gid_table->gids[free].gid,
          |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      297 |                                        &attr->gid, sizeof(attr->gid));
          |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    This helps with the ongoing efforts to globally enable
    -Wstringop-overflow.

    Link: KSPP/linux#308
    Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
    Link: https://lore.kernel.org/r/ZNvimeRAPkJ24zRG@work
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Leon Romanovsky <leon@kernel.org>

Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wstringop-overflow Emits warnings under -Wstringop-overflow
Projects
None yet
Development

No branches or pull requests

2 participants