public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: liweihang <liweihang@huawei.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: "dledford@redhat.com" <dledford@redhat.com>,
	"jgg@nvidia.com" <jgg@nvidia.com>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Linuxarm <linuxarm@huawei.com>
Subject: Re: [PATCH for-next] RDMA/core: Check invalid QP state for ib_modify_qp_is_ok()
Date: Mon, 22 Mar 2021 03:29:09 +0000	[thread overview]
Message-ID: <53ff6a59a9a74443bca58bcaee6292bb@huawei.com> (raw)
In-Reply-To: YFXBprYFmFgHu9Z8@unreal

On 2021/3/20 17:34, Leon Romanovsky wrote:
> On Fri, Mar 19, 2021 at 05:02:25PM +0800, Weihang Li wrote:
>> From: Xi Wang <wangxi11@huawei.com>
>>
>> Out-of-bounds may occur in 'qp_state_table' when the caller passing wrong
>> QP state value.
> 
> How is it possible? Do you have call stack to support it?
> 
> Thanks
> 

ib_modify_qp_is_ok() is exported, I think any kernel modules can pass in
invalid QP state. Should we check it in such case?

Thanks
Weihang

>>
>> Signed-off-by: Xi Wang <wangxi11@huawei.com>
>> Signed-off-by: Weihang Li <liweihang@huawei.com>
>> ---
>>  drivers/infiniband/core/verbs.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
>> index 28464c5..66ba4e6 100644
>> --- a/drivers/infiniband/core/verbs.c
>> +++ b/drivers/infiniband/core/verbs.c
>> @@ -1613,6 +1613,10 @@ bool ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
>>  	    cur_state != IB_QPS_SQD && cur_state != IB_QPS_SQE)
>>  		return false;
>>  
>> +	if (cur_state >= ARRAY_SIZE(qp_state_table) ||
>> +	    next_state >= ARRAY_SIZE(qp_state_table[0]))
>> +		return false;
>> +
>>  	if (!qp_state_table[cur_state][next_state].valid)
>>  		return false;
>>  
>> -- 
>> 2.8.1
>>


  reply	other threads:[~2021-03-22  3:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19  9:02 [PATCH for-next] RDMA/core: Check invalid QP state for ib_modify_qp_is_ok() Weihang Li
2021-03-20  9:34 ` Leon Romanovsky
2021-03-22  3:29   ` liweihang [this message]
2021-03-22  5:47     ` Leon Romanovsky
2021-03-22  6:21       ` liweihang
2021-03-22  7:11       ` liweihang
2021-03-22  7:28         ` Leon Romanovsky
2021-03-22  7:55           ` liweihang

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=53ff6a59a9a74443bca58bcaee6292bb@huawei.com \
    --to=liweihang@huawei.com \
    --cc=dledford@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    /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