From: Bart Van Assche <bvanassche@acm.org>
To: Hillf Danton <hdanton@sina.com>
Cc: Mike Christie <michael.christie@oracle.com>,
"lizhijian@fujitsu.com" <lizhijian@fujitsu.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"target-devel@vger.kernel.org" <target-devel@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: use-after-free in srpt_enable_tpg()
Date: Tue, 5 Jul 2022 09:10:31 -0700 [thread overview]
Message-ID: <2e8b080c-cda5-9224-1e46-95fb0b4f7036@acm.org> (raw)
In-Reply-To: <20220705114050.1979-1-hdanton@sina.com>
On 7/5/22 04:40, Hillf Danton wrote:
> If no compat devices can be added to ib_device with DEVICE_REGISTERED
> cleared then they can be removed without ib_device's refcount dropping
> to zero.
> Even if that is not strictly true, a new flag that marks ib device
> disabled and prevents new compact devices from being added can be added
> in bid to cut the wait for completion.
>
> Hillf
>
> +++ b/drivers/infiniband/core/device.c
> @@ -1265,6 +1265,7 @@ static void disable_device(struct ib_dev
>
> down_write(&devices_rwsem);
> xa_clear_mark(&devices, device->index, DEVICE_REGISTERED);
> + // device->disabled = true;
> up_write(&devices_rwsem);
>
> /*
> @@ -1282,17 +1283,10 @@ static void disable_device(struct ib_dev
> }
>
> ib_cq_pool_cleanup(device);
> + remove_compat_devs(device);
>
> /* Pairs with refcount_set in enable_device */
> ib_device_put(device);
> - wait_for_completion(&device->unreg_completion);
> -
> - /*
> - * compat devices must be removed after device refcount drops to zero.
> - * Otherwise init_net() may add more compatdevs after removing compat
> - * devices and before device is disabled.
> - */
> - remove_compat_devs(device);
> }
I'm not convinced the above patch is a step in the right direction nor
that it is correct. Anyway, since the RDMA maintainers know this code
better than I do I will let them comment on the above patch.
Bart.
prev parent reply other threads:[~2022-07-05 16:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-27 7:09 use-after-free in srpt_enable_tpg() lizhijian
2022-06-27 16:37 ` Bart Van Assche
2022-06-30 16:40 ` Mike Christie
2022-06-30 18:42 ` Bart Van Assche
[not found] ` <20220701015934.1105-1-hdanton@sina.com>
2022-07-02 22:26 ` Bart Van Assche
[not found] ` <20220703021119.1109-1-hdanton@sina.com>
2022-07-03 14:55 ` Bart Van Assche
[not found] ` <20220704001157.1644-1-hdanton@sina.com>
2022-07-05 4:34 ` Bart Van Assche
2022-07-05 12:39 ` Jason Gunthorpe
2022-07-27 3:24 ` lizhijian
[not found] ` <20220705114050.1979-1-hdanton@sina.com>
2022-07-05 16:10 ` Bart Van Assche [this message]
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=2e8b080c-cda5-9224-1e46-95fb0b4f7036@acm.org \
--to=bvanassche@acm.org \
--cc=hdanton@sina.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=lizhijian@fujitsu.com \
--cc=michael.christie@oracle.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;
as well as URLs for NNTP newsgroup(s).