All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: RDMA/srpt: Fix incorrect pointer dereference
Date: Tue, 17 Dec 2019 11:33:45 -0800	[thread overview]
Message-ID: <4103701f-27f0-f856-7aae-97420b8236d2@acm.org> (raw)
In-Reply-To: <20191217192649.24212-1-pakki001@umn.edu>

On 12/17/19 11:26 AM, Aditya Pakki wrote:
> In srpt_queue_response(), the rdma channel ch is first
> dereferenced and then checked for NULL. This renders the
> assertion ineffective. This patch removes the assertion and
> avoids potential NULL pointer dereference.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/infiniband/ulp/srpt/ib_srpt.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 23c782e3d49a..bbc6729c81c0 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -2803,15 +2803,17 @@ static void srpt_queue_response(struct se_cmd *cmd)
>   	struct srpt_send_ioctx *ioctx =
>   		container_of(cmd, struct srpt_send_ioctx, cmd);
>   	struct srpt_rdma_ch *ch = ioctx->ch;
> -	struct srpt_device *sdev = ch->sport->sdev;
>   	struct ib_send_wr send_wr, *first_wr = &send_wr;
> -	struct ib_sge sge;
>   	enum srpt_command_state state;
> +	struct srpt_device *sdev;
>   	int resp_len, ret, i;
> +	struct ib_sge sge;
>   	u8 srp_tm_status;
>   
> -	BUG_ON(!ch);
> +	if (WARN_ON(!ch))
> +		return;
>   
> +	sdev = ch->sport->sdev;
>   	state = ioctx->state;
>   	switch (state) {
>   	case SRPT_STATE_NEW:

Instead of making all these changes, please remove the BUG_ON(!ch) 
statement. If the condition ioctx->ch == NULL would ever be encountered 
then the call trace reported on the console will be sufficient to figure 
out what happened.

Thanks,

Bart.



WARNING: multiple messages have this Message-ID (diff)
From: Bart Van Assche <bvanassche@acm.org>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Doug Ledford <dledford@redhat.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: RDMA/srpt: Fix incorrect pointer dereference
Date: Tue, 17 Dec 2019 19:33:45 +0000	[thread overview]
Message-ID: <4103701f-27f0-f856-7aae-97420b8236d2@acm.org> (raw)
In-Reply-To: <20191217192649.24212-1-pakki001@umn.edu>

On 12/17/19 11:26 AM, Aditya Pakki wrote:
> In srpt_queue_response(), the rdma channel ch is first
> dereferenced and then checked for NULL. This renders the
> assertion ineffective. This patch removes the assertion and
> avoids potential NULL pointer dereference.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/infiniband/ulp/srpt/ib_srpt.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 23c782e3d49a..bbc6729c81c0 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -2803,15 +2803,17 @@ static void srpt_queue_response(struct se_cmd *cmd)
>   	struct srpt_send_ioctx *ioctx >   		container_of(cmd, struct srpt_send_ioctx, cmd);
>   	struct srpt_rdma_ch *ch = ioctx->ch;
> -	struct srpt_device *sdev = ch->sport->sdev;
>   	struct ib_send_wr send_wr, *first_wr = &send_wr;
> -	struct ib_sge sge;
>   	enum srpt_command_state state;
> +	struct srpt_device *sdev;
>   	int resp_len, ret, i;
> +	struct ib_sge sge;
>   	u8 srp_tm_status;
>   
> -	BUG_ON(!ch);
> +	if (WARN_ON(!ch))
> +		return;
>   
> +	sdev = ch->sport->sdev;
>   	state = ioctx->state;
>   	switch (state) {
>   	case SRPT_STATE_NEW:

Instead of making all these changes, please remove the BUG_ON(!ch) 
statement. If the condition ioctx->ch = NULL would ever be encountered 
then the call trace reported on the console will be sufficient to figure 
out what happened.

Thanks,

Bart.

  reply	other threads:[~2019-12-17 19:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 19:26 [PATCH] scsi: RDMA/srpt: Fix incorrect pointer dereference Aditya Pakki
2019-12-17 19:26 ` Aditya Pakki
2019-12-17 19:33 ` Bart Van Assche [this message]
2019-12-17 19:33   ` Bart Van Assche

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=4103701f-27f0-f856-7aae-97420b8236d2@acm.org \
    --to=bvanassche@acm.org \
    --cc=dledford@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.