From: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
To: linux-rdma <linux-rdma@vger.kernel.org>
Cc: target-devel <target-devel@vger.kernel.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
Roland Dreier <roland@purestorage.com>,
Bart Van Assche <bvanassche@acm.org>,
Nicholas Bellinger <nab@linux-iscsi.org>
Subject: [PATCH 2/2] ib_srpt: Fix possible race with srp_max_rsp_size in srpt_release_channel_work
Date: Mon, 24 Oct 2011 19:15:55 +0000 [thread overview]
Message-ID: <1319483755-11522-2-git-send-email-nab@linux-iscsi.org> (raw)
In-Reply-To: <1319483755-11522-1-git-send-email-nab@linux-iscsi.org>
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
prev parent reply other threads:[~2011-10-24 19:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1319483755-11522-2-git-send-email-nab@linux-iscsi.org \
--to=nab@linux-iscsi.org \
--cc=bvanassche@acm.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=roland@purestorage.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox