From: Jing Xiangfeng <jingxiangfeng@huawei.com>
To: Bart Van Assche <bvanassche@acm.org>, <dledford@redhat.com>,
<jgg@ziepe.ca>
Cc: <linux-rdma@vger.kernel.org>, <target-devel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH] IB/srpt: Fix a potential null pointer dereference
Date: Tue, 16 Jun 2020 08:51:24 +0800 [thread overview]
Message-ID: <5EE8178C.9090005@huawei.com> (raw)
In-Reply-To: <7366b608-4474-cfaa-c465-957fd2d2366d@acm.org>
On 2020/6/15 21:37, Bart Van Assche wrote:
> On 2020-06-15 02:12, Jing Xiangfeng wrote:
>> In srpt_cm_req_recv(), it is possible that sdev is NULL,
>> so we should test sdev before using it.
>>
>> Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
>> ---
>> drivers/infiniband/ulp/srpt/ib_srpt.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
>> index 98552749d71c..72053254bf84 100644
>> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
>> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
>> @@ -2143,7 +2143,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>> const struct srp_login_req *req,
>> const char *src_addr)
>> {
>> - struct srpt_port *sport = &sdev->port[port_num - 1];
>> + struct srpt_port *sport;
>> struct srpt_nexus *nexus;
>> struct srp_login_rsp *rsp = NULL;
>> struct srp_login_rej *rej = NULL;
>> @@ -2162,6 +2162,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>> if (WARN_ON(!sdev || !req))
>> return -EINVAL;
>>
>> + sport = &sdev->port[port_num - 1];
>> it_iu_len = be32_to_cpu(req->req_it_iu_len);
>>
>
> Please remove the (!sdev || !req) check instead of making the above
> change. It's easy to show that both pointers are always valid.
OK, I will send a v2 with this change.
Thanks
>
> Thanks,
>
> Bart.
> .
>
WARNING: multiple messages have this Message-ID (diff)
From: Jing Xiangfeng <jingxiangfeng@huawei.com>
To: Bart Van Assche <bvanassche@acm.org>, dledford@redhat.com, jgg@ziepe.ca
Cc: linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] IB/srpt: Fix a potential null pointer dereference
Date: Tue, 16 Jun 2020 00:51:24 +0000 [thread overview]
Message-ID: <5EE8178C.9090005@huawei.com> (raw)
In-Reply-To: <7366b608-4474-cfaa-c465-957fd2d2366d@acm.org>
On 2020/6/15 21:37, Bart Van Assche wrote:
> On 2020-06-15 02:12, Jing Xiangfeng wrote:
>> In srpt_cm_req_recv(), it is possible that sdev is NULL,
>> so we should test sdev before using it.
>>
>> Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
>> ---
>> drivers/infiniband/ulp/srpt/ib_srpt.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
>> index 98552749d71c..72053254bf84 100644
>> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
>> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
>> @@ -2143,7 +2143,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>> const struct srp_login_req *req,
>> const char *src_addr)
>> {
>> - struct srpt_port *sport = &sdev->port[port_num - 1];
>> + struct srpt_port *sport;
>> struct srpt_nexus *nexus;
>> struct srp_login_rsp *rsp = NULL;
>> struct srp_login_rej *rej = NULL;
>> @@ -2162,6 +2162,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>> if (WARN_ON(!sdev || !req))
>> return -EINVAL;
>>
>> + sport = &sdev->port[port_num - 1];
>> it_iu_len = be32_to_cpu(req->req_it_iu_len);
>>
>
> Please remove the (!sdev || !req) check instead of making the above
> change. It's easy to show that both pointers are always valid.
OK, I will send a v2 with this change.
Thanks
>
> Thanks,
>
> Bart.
> .
>
next prev parent reply other threads:[~2020-06-16 0:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 9:12 [PATCH] IB/srpt: Fix a potential null pointer dereference Jing Xiangfeng
2020-06-15 9:12 ` Jing Xiangfeng
2020-06-15 13:37 ` Bart Van Assche
2020-06-15 13:37 ` Bart Van Assche
2020-06-16 0:51 ` Jing Xiangfeng [this message]
2020-06-16 0:51 ` Jing Xiangfeng
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=5EE8178C.9090005@huawei.com \
--to=jingxiangfeng@huawei.com \
--cc=bvanassche@acm.org \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--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.