Skip to content

Commit 260cce6

Browse files
abhijitG-xlnxrleon
authored andcommitted
RDMA/ionic: Use ether_addr_copy instead of memcpy
eth header from ib_ud_header structure packs the mac into 4B high and 2B low parts. But when 4B high is used in memcpy, it sees it as overflow. However, this is safe due to the 4B high and 2B low arrangement in the structure. To avoid the memcpy warning, use ether_addr_copy to copy the mac address. In function ‘fortify_memcpy_chk’, inlined from ‘ionic_set_ah_attr.isra’ at drivers/infiniband/hw/ionic/ionic_controlpath.c:609:3: ./include/linux/fortify-string.h:580:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning] 580 | __read_overflow2_field(q_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[6]: *** [scripts/Makefile.build:287: drivers/infiniband/hw/ionic/ionic_controlpath.o] Error 1 make[5]: *** [scripts/Makefile.build:556: drivers/infiniband/hw/ionic] Error 2 make[5]: *** Waiting for unfinished jobs.... make[4]: *** [scripts/Makefile.build:556: drivers/infiniband/hw] Error 2 make[3]: *** [scripts/Makefile.build:556: drivers/infiniband] Error 2 make[2]: *** [scripts/Makefile.build:556: drivers] Error 2 make[1]: *** [/tmp/tmp53nb1nwr/Makefile:2011: .] Error 2 make: *** [Makefile:248: __sub-make] Error 2 Fixes: e852182 ("RDMA/ionic: Register device ops for control path") Reported-by: Leon Romanovsky <[email protected]> Closes: https://lore.kernel.org/lkml/20250918180750.GA135135@unreal/ Signed-off-by: Abhijit Gangurde <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent ed9836c commit 260cce6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/infiniband/hw/ionic/ionic_controlpath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ static void ionic_set_ah_attr(struct ionic_ibdev *dev,
606606
memset(ah_attr, 0, sizeof(*ah_attr));
607607
ah_attr->type = RDMA_AH_ATTR_TYPE_ROCE;
608608
if (hdr->eth_present)
609-
memcpy(&ah_attr->roce.dmac, &hdr->eth.dmac_h, ETH_ALEN);
609+
ether_addr_copy(ah_attr->roce.dmac, hdr->eth.dmac_h);
610610
rdma_ah_set_sl(ah_attr, vlan >> VLAN_PRIO_SHIFT);
611611
rdma_ah_set_port_num(ah_attr, 1);
612612
rdma_ah_set_grh(ah_attr, NULL, flow_label, sgid_index, ttl, tos);

0 commit comments

Comments
 (0)