aboutsummaryrefslogtreecommitdiffstats
path: root/net/smc
diff options
context:
space:
mode:
authorUrsula Braun <ubraun@linux.vnet.ibm.com>2017-01-12 08:57:15 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-12 09:47:01 -0500
commit143c017108f8a695e4e1c1f5ec57ee89be9cad70 (patch)
tree397034c602b8b7ef3982b76193bb63c13583d985 /net/smc
parent526735ddc0ae8c7a7751e9ad3a57ae76cd3c35d5 (diff)
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')
-rw-r--r--net/smc/smc_clc.c10
-rw-r--r--net/smc/smc_ib.h4
2 files changed, 7 insertions, 7 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 @@
10 */ 10 */
11 11
12#include <linux/in.h> 12#include <linux/in.h>
13#include <linux/if_ether.h>
13#include <net/sock.h> 14#include <net/sock.h>
14#include <net/tcp.h> 15#include <net/tcp.h>
15 16
@@ -151,8 +152,7 @@ int smc_clc_send_proposal(struct smc_sock *smc,
151 pclc.hdr.version = SMC_CLC_V1; /* SMC version */ 152 pclc.hdr.version = SMC_CLC_V1; /* SMC version */
152 memcpy(pclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid)); 153 memcpy(pclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid));
153 memcpy(&pclc.lcl.gid, &smcibdev->gid[ibport - 1], SMC_GID_SIZE); 154 memcpy(&pclc.lcl.gid, &smcibdev->gid[ibport - 1], SMC_GID_SIZE);
154 memcpy(&pclc.lcl.mac, &smcibdev->mac[ibport - 1], 155 memcpy(&pclc.lcl.mac, &smcibdev->mac[ibport - 1], ETH_ALEN);
155 sizeof(smcibdev->mac[ibport - 1]));
156 156
157 /* determine subnet and mask from internal TCP socket */ 157 /* determine subnet and mask from internal TCP socket */
158 rc = smc_netinfo_by_tcpsk(smc->clcsock, &pclc.outgoing_subnet, 158 rc = smc_netinfo_by_tcpsk(smc->clcsock, &pclc.outgoing_subnet,
@@ -199,8 +199,7 @@ int smc_clc_send_confirm(struct smc_sock *smc)
199 memcpy(cclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid)); 199 memcpy(cclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid));
200 memcpy(&cclc.lcl.gid, &link->smcibdev->gid[link->ibport - 1], 200 memcpy(&cclc.lcl.gid, &link->smcibdev->gid[link->ibport - 1],
201 SMC_GID_SIZE); 201 SMC_GID_SIZE);
202 memcpy(&cclc.lcl.mac, &link->smcibdev->mac[link->ibport - 1], 202 memcpy(&cclc.lcl.mac, &link->smcibdev->mac[link->ibport - 1], ETH_ALEN);
203 sizeof(link->smcibdev->mac));
204 hton24(cclc.qpn, link->roce_qp->qp_num); 203 hton24(cclc.qpn, link->roce_qp->qp_num);
205 cclc.rmb_rkey = 204 cclc.rmb_rkey =
206 htonl(conn->rmb_desc->mr_rx[SMC_SINGLE_LINK]->rkey); 205 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)
252 memcpy(aclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid)); 251 memcpy(aclc.lcl.id_for_peer, local_systemid, sizeof(local_systemid));
253 memcpy(&aclc.lcl.gid, &link->smcibdev->gid[link->ibport - 1], 252 memcpy(&aclc.lcl.gid, &link->smcibdev->gid[link->ibport - 1],
254 SMC_GID_SIZE); 253 SMC_GID_SIZE);
255 memcpy(&aclc.lcl.mac, link->smcibdev->mac[link->ibport - 1], 254 memcpy(&aclc.lcl.mac, link->smcibdev->mac[link->ibport - 1], ETH_ALEN);
256 sizeof(link->smcibdev->mac[link->ibport - 1]));
257 hton24(aclc.qpn, link->roce_qp->qp_num); 255 hton24(aclc.qpn, link->roce_qp->qp_num);
258 aclc.rmb_rkey = 256 aclc.rmb_rkey =
259 htonl(conn->rmb_desc->mr_rx[SMC_SINGLE_LINK]->rkey); 257 htonl(conn->rmb_desc->mr_rx[SMC_SINGLE_LINK]->rkey);
diff --git a/net/smc/smc_ib.h b/net/smc/smc_ib.h
index 3fe2d55c6051..a95f74bb5569 100644
--- a/net/smc/smc_ib.h
+++ b/net/smc/smc_ib.h
@@ -11,6 +11,7 @@
11#ifndef _SMC_IB_H 11#ifndef _SMC_IB_H
12#define _SMC_IB_H 12#define _SMC_IB_H
13 13
14#include <linux/if_ether.h>
14#include <rdma/ib_verbs.h> 15#include <rdma/ib_verbs.h>
15 16
16#define SMC_MAX_PORTS 2 /* Max # of ports */ 17#define SMC_MAX_PORTS 2 /* Max # of ports */
@@ -34,7 +35,8 @@ struct smc_ib_device { /* ib-device infos for smc */
34 struct ib_cq *roce_cq_recv; /* recv completion queue */ 35 struct ib_cq *roce_cq_recv; /* recv completion queue */
35 struct tasklet_struct send_tasklet; /* called by send cq handler */ 36 struct tasklet_struct send_tasklet; /* called by send cq handler */
36 struct tasklet_struct recv_tasklet; /* called by recv cq handler */ 37 struct tasklet_struct recv_tasklet; /* called by recv cq handler */
37 char mac[SMC_MAX_PORTS][6]; /* mac address per port*/ 38 char mac[SMC_MAX_PORTS][ETH_ALEN];
39 /* mac address per port*/
38 union ib_gid gid[SMC_MAX_PORTS]; /* gid per port */ 40 union ib_gid gid[SMC_MAX_PORTS]; /* gid per port */
39 u8 initialized : 1; /* ib dev CQ, evthdl done */ 41 u8 initialized : 1; /* ib dev CQ, evthdl done */
40 struct work_struct port_event_work; 42 struct work_struct port_event_work;