* [PATCH 1/2] ib_srpt: Fix possible race with srp_sq_size in srpt_create_ch_ib
@ 2011-10-24 19:15 Nicholas A. Bellinger
2011-10-24 19:15 ` [PATCH 2/2] ib_srpt: Fix possible race with srp_max_rsp_size in srpt_release_channel_work Nicholas A. Bellinger
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas A. Bellinger @ 2011-10-24 19:15 UTC (permalink / raw)
To: linux-rdma
Cc: target-devel, linux-scsi, Roland Dreier, Bart Van Assche,
Nicholas Bellinger
From: Nicholas Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
This patch fixes a possible race with srp_sq_size in srpt_create_ch_ib()
where changing sport->port_attrib.srp_sq_size via configfs could have
unintended consequences. It uses a local assignment for srp_sq_size to
ensure the values for ib_create_cq() and qp_init->cap.max_send_wr are
consistent.
Reported-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Signed-off-by: Nicholas A. Bellinger <nab-IzHhD5pYlfBP7FQvKIMDCQ@public.gmane.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 9e1c5e0..e483c54 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2130,6 +2130,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
struct ib_qp_init_attr *qp_init;
struct srpt_port *sport = ch->sport;
struct srpt_device *sdev = sport->sdev;
+ u32 srp_sq_size = sport->port_attrib.srp_sq_size;
int ret;
WARN_ON(ch->rq_size < 1);
@@ -2140,11 +2141,11 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
goto out;
ch->cq = ib_create_cq(sdev->device, srpt_completion, NULL, ch,
- ch->rq_size + sport->port_attrib.srp_sq_size, 0);
+ ch->rq_size + srp_sq_size, 0);
if (IS_ERR(ch->cq)) {
ret = PTR_ERR(ch->cq);
printk(KERN_ERR "failed to create CQ cqe= %d ret= %d\n",
- ch->rq_size + sport->port_attrib.srp_sq_size, ret);
+ ch->rq_size + srp_sq_size, ret);
goto out;
}
@@ -2156,7 +2157,7 @@ static int srpt_create_ch_ib(struct srpt_rdma_ch *ch)
qp_init->srq = sdev->srq;
qp_init->sq_sig_type = IB_SIGNAL_REQ_WR;
qp_init->qp_type = IB_QPT_RC;
- qp_init->cap.max_send_wr = sport->port_attrib.srp_sq_size;
+ qp_init->cap.max_send_wr = srp_sq_size;
qp_init->cap.max_send_sge = SRPT_DEF_SG_PER_WQE;
ch->qp = ib_create_qp(sdev->pd, qp_init);
--
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH 2/2] ib_srpt: Fix possible race with srp_max_rsp_size in srpt_release_channel_work
2011-10-24 19:15 [PATCH 1/2] ib_srpt: Fix possible race with srp_sq_size in srpt_create_ch_ib Nicholas A. Bellinger
@ 2011-10-24 19:15 ` Nicholas A. Bellinger
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2011-10-24 19:15 UTC (permalink / raw)
To: linux-rdma
Cc: target-devel, linux-scsi, Roland Dreier, Bart Van Assche,
Nicholas Bellinger
From: Nicholas Bellinger <nab@linux-iscsi.org>
This patch fixes a possible race with srp_max_rsp_size in
srpt_release_channel_work() when changing sport->port_attrib.srp_max_rsp_size
via configfs could have unintended consequences. It uses a new
srpt_rdma_ch->rsp_size and assign the value during srpt_cm_req_recv(),
which is used in subsequent calls to srpt_free_ioctx_ring() to ensure
consistency with the original srpt_alloc_ioctx_ring().
Reported-by: Bart Van Assche <bvanassche@acm.org>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 10 ++++------
drivers/infiniband/ulp/srpt/ib_srpt.h | 2 ++
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index e483c54..f7174b3 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2373,8 +2373,7 @@ static void srpt_release_channel_work(struct work_struct *w)
srpt_free_ioctx_ring((struct srpt_ioctx **)ch->ioctx_ring,
ch->sport->sdev, ch->rq_size,
- ch->sport->port_attrib.srp_max_rsp_size,
- DMA_TO_DEVICE);
+ ch->rsp_size, DMA_TO_DEVICE);
spin_lock_irq(&sdev->spinlock);
list_del(&ch->list);
@@ -2554,12 +2553,12 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
spin_lock_init(&ch->spinlock);
ch->state = CH_CONNECTING;
INIT_LIST_HEAD(&ch->cmd_wait_list);
+ ch->rsp_size = ch->sport->port_attrib.srp_max_rsp_size;
ch->ioctx_ring = (struct srpt_send_ioctx **)
srpt_alloc_ioctx_ring(ch->sport->sdev, ch->rq_size,
sizeof(*ch->ioctx_ring[0]),
- ch->sport->port_attrib.srp_max_rsp_size,
- DMA_TO_DEVICE);
+ ch->rsp_size, DMA_TO_DEVICE);
if (!ch->ioctx_ring)
goto free_ch;
@@ -2667,8 +2666,7 @@ destroy_ib:
free_ring:
srpt_free_ioctx_ring((struct srpt_ioctx **)ch->ioctx_ring,
ch->sport->sdev, ch->rq_size,
- ch->sport->port_attrib.srp_max_rsp_size,
- DMA_TO_DEVICE);
+ ch->rsp_size, DMA_TO_DEVICE);
free_ch:
kfree(ch);
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h
index 1b607ae..068f66d 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -277,6 +277,7 @@ enum rdma_ch_state {
* @qp: IB queue pair used for communicating over this channel.
* @cq: IB completion queue for this channel.
* @rq_size: IB receive queue size.
+ * @rsp_size IB response message size in bytes.
* @sq_wr_avail: number of work requests available in the send queue.
* @sport: pointer to the information of the HCA port used by this
* channel.
@@ -307,6 +308,7 @@ struct srpt_rdma_ch {
struct ib_qp *qp;
struct ib_cq *cq;
int rq_size;
+ u32 rsp_size;
atomic_t sq_wr_avail;
struct srpt_port *sport;
u8 i_port_id[16];
--
1.7.2.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-24 19:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24 19:15 [PATCH 1/2] ib_srpt: Fix possible race with srp_sq_size in srpt_create_ch_ib Nicholas A. Bellinger
2011-10-24 19:15 ` [PATCH 2/2] ib_srpt: Fix possible race with srp_max_rsp_size in srpt_release_channel_work Nicholas A. Bellinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox