The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "yangx.jy@fujitsu.com" <yangx.jy@fujitsu.com>
To: Bart Van Assche <bvanassche@acm.org>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"leon@kernel.org" <leon@kernel.org>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] RDMA/srp: Set scmnd->result only when scmnd is not NULL
Date: Wed, 31 Aug 2022 03:16:28 +0000	[thread overview]
Message-ID: <bff7565b-7159-e8f4-e8f5-711994f95056@fujitsu.com> (raw)
In-Reply-To: <5daac9db-2b34-fbe5-a891-8ecf77fbe46f@acm.org>

On 2022/8/31 10:47, Bart Van Assche wrote:
> On 8/30/22 18:47, yangx.jy@fujitsu.com wrote:
>> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c 
>> b/drivers/infiniband/ulp/srp/ib_srp.c
>> index 7720ea270ed8..528cdd0daba4 100644
>> --- a/drivers/infiniband/ulp/srp/ib_srp.c
>> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
>> @@ -1961,6 +1961,7 @@ static void srp_process_rsp(struct srp_rdma_ch 
>> *ch, struct srp_rsp *rsp)
>>           if (scmnd) {
>>               req = scsi_cmd_priv(scmnd);
>>               scmnd = srp_claim_req(ch, req, NULL, scmnd);
>> +            scmnd->result = rsp->status;
>>           } else {
>>               shost_printk(KERN_ERR, target->scsi_host,
>>                        "Null scmnd for RSP w/tag %#016llx received on 
>> ch %td / QP %#x\n",
>> @@ -1972,7 +1973,6 @@ static void srp_process_rsp(struct srp_rdma_ch 
>> *ch, struct srp_rsp *rsp)
>>               return;
>>           }
>> -        scmnd->result = rsp->status;
>>           if (rsp->flags & SRP_RSP_FLAG_SNSVALID) {
>>               memcpy(scmnd->sense_buffer, rsp->data +
> 
> Since there is a 'return' statement in the else branch, I don't see how 
> this patch can make a difference?

Hi Bart,

Sorry, I didn't make the right fix. I will send v2 patch.
I think scmnd may be set to NULL after srp_claim_req() is called and 
then setting scmnd->result can trigger the NULL pointer dereference.

Best Regards,
Xiao Yang
> 
> Thanks,
> 
> Bart.

  reply	other threads:[~2022-08-31  3:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31  1:47 [PATCH] RDMA/srp: Set scmnd->result only when scmnd is not NULL yangx.jy
2022-08-31  1:59 ` Li Zhijian
2022-08-31  2:31   ` yangx.jy
2022-08-31  3:02     ` Li Zhijian
2022-08-31  2:47 ` Bart Van Assche
2022-08-31  3:16   ` yangx.jy [this message]
2022-08-31  4:04     ` 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=bff7565b-7159-e8f4-e8f5-711994f95056@fujitsu.com \
    --to=yangx.jy@fujitsu.com \
    --cc=bvanassche@acm.org \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@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