diff options
author | Ursula Braun <ubraun@linux.vnet.ibm.com> | 2017-01-12 14:57:15 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-12 15:47:01 +0100 |
commit | 143c017108f8a695e4e1c1f5ec57ee89be9cad70 (patch) | |
tree | 397034c602b8b7ef3982b76193bb63c13583d985 /net/smc/smc_clc.c | |
parent | net: fix AF_SMC related typo (diff) | |
download | linux-143c017108f8a695e4e1c1f5ec57ee89be9cad70.tar.xz linux-143c017108f8a695e4e1c1f5ec57ee89be9cad70.zip |
smc: ETH_ALEN as memcpy length for mac addresses
When creating an SMC connection, there is a CLC (connection layer control)
handshake to prepare for RDMA traffic. The corresponding code is part of
commit 0cfdd8f92cac ("smc: connection and link group creation").
Mac addresses to be exchanged in the handshake are copied with a wrong
length of 12 instead of 6 bytes. Following code overwrites the wrongly
copied code, but nevertheless the correct length should already be used for
the preceding mac address copying. Use ETH_ALEN for the memcpy length with
mac addresses.
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Fixes: 0cfdd8f92cac ("smc: connection and link group creation")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/smc/smc_clc.c')
-rw-r--r-- | net/smc/smc_clc.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index e1e684c562b8..cc6b6f8651eb 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -10,6 +10,7 @@ */ #include <linux/in.h> +#include <linux/if_ether.h> #include <net/sock.h> #include <net/tcp.h> @@ -151,8 +152,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, pclc.hdr.version = SMC_CLC_V1; /* SMC version */ memcpy(pclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid)); memcpy(&pclc.lcl.gid, &smcibdev->gid[ibport - 1], SMC_GID_SIZE); - memcpy(&pclc.lcl.mac, &smcibdev->mac[ibport - 1], - sizeof(smcibdev->mac[ibport - 1])); + memcpy(&pclc.lcl.mac, &smcibdev->mac[ibport - 1], ETH_ALEN); /* determine subnet and mask from internal TCP socket */ rc = smc_netinfo_by_tcpsk(smc->clcsock, &pclc.outgoing_subnet, @@ -199,8 +199,7 @@ int smc_clc_send_confirm(struct smc_sock *smc) memcpy(cclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid)); memcpy(&cclc.lcl.gid, &link->smcibdev->gid[link->ibport - 1], SMC_GID_SIZE); - memcpy(&cclc.lcl.mac, &link->smcibdev->mac[link->ibport - 1], - sizeof(link->smcibdev->mac)); + memcpy(&cclc.lcl.mac, &link->smcibdev->mac[link->ibport - 1], ETH_ALEN); hton24(cclc.qpn, link->roce_qp->qp_num); cclc.rmb_rkey = htonl(conn->rmb_desc->mr_rx[SMC_SINGLE_LINK]->rkey); @@ -252,8 +251,7 @@ int smc_clc_send_accept(struct smc_sock *new_smc, int srv_first_contact) memcpy(aclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid)); memcpy(&aclc.lcl.gid, &link->smcibdev->gid[link->ibport - 1], SMC_GID_SIZE); - memcpy(&aclc.lcl.mac, link->smcibdev->mac[link->ibport - 1], - sizeof(link->smcibdev->mac[link->ibport - 1])); + memcpy(&aclc.lcl.mac, link->smcibdev->mac[link->ibport - 1], ETH_ALEN); hton24(aclc.qpn, link->roce_qp->qp_num); aclc.rmb_rkey = htonl(conn->rmb_desc->mr_rx[SMC_SINGLE_LINK]->rkey); |