From: Jason Gunthorpe <jgg@ziepe.ca>
To: Tejun Heo <tj@kernel.org>
Cc: torvalds@linux-foundation.org, jannh@google.com,
paulmck@linux.vnet.ibm.com, bcrl@kvack.org,
viro@zeniv.linux.org.uk, kent.overstreet@gmail.com,
security@kernel.org, linux-kernel@vger.kernel.org,
kernel-team@fb.com, Mike Marciniszyn <mike.marciniszyn@intel.com>,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH 3/8] RDMAVT: Fix synchronization around percpu_ref
Date: Thu, 15 Mar 2018 16:24:28 -0600 [thread overview]
Message-ID: <20180315222428.GE27537@ziepe.ca> (raw)
In-Reply-To: <20180314194515.1661824-3-tj@kernel.org>
On Wed, Mar 14, 2018 at 12:45:10PM -0700, Tejun Heo wrote:
> rvt_mregion uses percpu_ref for reference counting and RCU to protect
> accesses from lkey_table. When a rvt_mregion needs to be freed, it
> first gets unregistered from lkey_table and then rvt_check_refs() is
> called to wait for in-flight usages before the rvt_mregion is freed.
>
> rvt_check_refs() seems to have a couple issues.
>
> * It has a fast exit path which tests percpu_ref_is_zero(). However,
> a percpu_ref reading zero doesn't mean that the object can be
> released. In fact, the ->release() callback might not even have
> started executing yet. Proceeding with freeing can lead to
> use-after-free.
>
> * lkey_table is RCU protected but there is no RCU grace period in the
> free path. percpu_ref uses RCU internally but it's sched-RCU whose
> grace periods are different from regular RCU. Also, it generally
> isn't a good idea to depend on internal behaviors like this.
>
> To address the above issues, this patch removes the fast exit and adds
> an explicit synchronize_rcu().
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Acked-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
> Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
> Cc: linux-rdma@vger.kernel.org
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> drivers/infiniband/sw/rdmavt/mr.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
Applied to rdma for-next
Thanks,
Jason
prev parent reply other threads:[~2018-03-15 22:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180314194205.1651587-1-tj@kernel.org>
[not found] ` <20180314194515.1661824-1-tj@kernel.org>
2018-03-14 19:45 ` [PATCH 3/8] RDMAVT: Fix synchronization around percpu_ref Tejun Heo
2018-03-15 22:24 ` Jason Gunthorpe [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=20180315222428.GE27537@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=bcrl@kvack.org \
--cc=jannh@google.com \
--cc=kent.overstreet@gmail.com \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mike.marciniszyn@intel.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=security@kernel.org \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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).