From: Andrea Righi <righi.andrea@gmail.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Cc: Robert LeBlanc <robert@leblancnet.us>,
Sean Jenkins <sean@betterservers.com>,
Sagi Grimberg <sagi@grimberg.me>,
Doug Ledford <dledford@redhat.com>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
linux-rdma <linux-rdma@vger.kernel.org>,
target-devel <target-devel@vger.kernel.org>,
lkml <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] ib_isert: prevent NULL pointer dereference in isert_login_recv_done() (was: Re: NULL pointer dereference in isert_login_recv_done in 4.9.32)
Date: Wed, 28 Jun 2017 19:53:54 +0200 [thread overview]
Message-ID: <20170628175354.GB1769@Dell> (raw)
In-Reply-To: <1498435084.26123.66.camel@haakon3.risingtidesystems.com>
On Sun, Jun 25, 2017 at 04:58:04PM -0700, Nicholas A. Bellinger wrote:
...
> So I assume isert_cma_handler() -> isert_connect_error() getting called
> to clear isert_conn->cm_id before connection established, and
> subsequently isert_conn->login_req_buf->rx_cqe.done() ->
> isert_login_recv_done() still getting invoked after connection failure
> is new RDMA API behavior..
>
> That said, following Sagi's original patch that added the clearing of
> isert_conn->cm_id to isert_connect_error(), it probably makes sense to
> use isert_conn->device->ib_device, and avoid dereferencing
> isert_conn->cm_id before connection is established.
>
> Here's a quick (untested) patch to do this for recv/send done callbacks,
> and avoid using isert_conn->cm_id during isert_rdma_accept().
>
> Sagi + Co, WDYT..?
Just tested this patch, I wasn't able to reproduce the NULL pointer
dereference or any other bugs, so this fix seems safe enough to me.
Tested-by: Andrea Righi <righi.andrea@gmail.com>
>
> diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
> index fcbed35..f7f97f3 100644
> --- a/drivers/infiniband/ulp/isert/ib_isert.c
> +++ b/drivers/infiniband/ulp/isert/ib_isert.c
> @@ -52,7 +52,7 @@
> static int
> isert_login_post_recv(struct isert_conn *isert_conn);
> static int
> -isert_rdma_accept(struct isert_conn *isert_conn);
> +isert_rdma_accept(struct isert_conn *isert_conn, struct rdma_cm_id *cm_id);
> struct rdma_cm_id *isert_setup_id(struct isert_np *isert_np);
>
> static void isert_release_work(struct work_struct *work);
> @@ -543,7 +543,7 @@
> if (ret)
> goto out_conn_dev;
>
> - ret = isert_rdma_accept(isert_conn);
> + ret = isert_rdma_accept(isert_conn, cma_id);
> if (ret)
> goto out_conn_dev;
>
> @@ -1452,7 +1452,7 @@
> isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc)
> {
> struct isert_conn *isert_conn = wc->qp->qp_context;
> - struct ib_device *ib_dev = isert_conn->cm_id->device;
> + struct ib_device *ib_dev = isert_conn->device->ib_device;
>
> if (unlikely(wc->status != IB_WC_SUCCESS)) {
> isert_print_wc(wc, "login recv");
> @@ -1769,7 +1769,7 @@
> isert_login_send_done(struct ib_cq *cq, struct ib_wc *wc)
> {
> struct isert_conn *isert_conn = wc->qp->qp_context;
> - struct ib_device *ib_dev = isert_conn->cm_id->device;
> + struct ib_device *ib_dev = isert_conn->device->ib_device;
> struct iser_tx_desc *tx_desc = cqe_to_tx_desc(wc->wr_cqe);
>
> if (unlikely(wc->status != IB_WC_SUCCESS)) {
> @@ -2369,9 +2369,8 @@ struct rdma_cm_id *
> }
>
> static int
> -isert_rdma_accept(struct isert_conn *isert_conn)
> +isert_rdma_accept(struct isert_conn *isert_conn, struct rdma_cm_id *cm_id)
> {
> - struct rdma_cm_id *cm_id = isert_conn->cm_id;
> struct rdma_conn_param cp;
> int ret;
> struct iser_cm_hdr rsp_hdr;
next prev parent reply other threads:[~2017-06-28 17:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 18:54 NULL pointer dereference in isert_login_recv_done in 4.9.32 Robert LeBlanc
2017-06-21 15:17 ` Robert LeBlanc
[not found] ` <CAANLjFp6Y8wvLvmWrk1ECjm-OoyEppxD1svNYKpg+HDEZevJig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-21 16:33 ` Robert LeBlanc
[not found] ` <CAANLjFoQcmfkjq9N1fehTC9Zi6aOC7ArOEPXz-he3EnOvWeEDw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-21 22:48 ` Robert LeBlanc
2017-06-22 22:37 ` [PATCH] ib_isert: prevent NULL pointer dereference in isert_login_recv_done() (was: Re: NULL pointer dereference in isert_login_recv_done in 4.9.32) Andrea Righi
2017-06-25 23:58 ` Nicholas A. Bellinger
2017-06-27 7:03 ` [PATCH] ib_isert: prevent NULL pointer dereference in isert_login_recv_done() Sagi Grimberg
2017-06-28 17:53 ` Andrea Righi [this message]
2017-06-29 5:36 ` Sagi Grimberg
2017-06-29 8:20 ` Andrea Righi
2017-06-29 8:28 ` Sagi Grimberg
[not found] ` <7f1b1f07-0670-10ee-620d-0ab3b1a6c2bf-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-06-30 5:53 ` Nicholas A. Bellinger
2017-06-26 8:53 ` [PATCH] ib_isert: prevent NULL pointer dereference in isert_login_recv_done() (was: Re: NULL pointer dereference in isert_login_recv_done in 4.9.32) Leon Romanovsky
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=20170628175354.GB1769@Dell \
--to=righi.andrea@gmail.com \
--cc=dledford@redhat.com \
--cc=hal.rosenstock@gmail.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=robert@leblancnet.us \
--cc=sagi@grimberg.me \
--cc=sean.hefty@intel.com \
--cc=sean@betterservers.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