linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: dledford@redhat.com, linux-rdma@vger.kernel.org,
	Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>,
	stable@vger.kernel.org, linux-mm@kvack.org,
	Ira Weiny <ira.weiny@intel.com>
Subject: Re: [PATCH for-rc v4] IB/hfi1: Ensure correct mm is used at all times
Date: Wed, 25 Nov 2020 14:15:42 -0500	[thread overview]
Message-ID: <cc07055a-b221-359f-7f2c-052a81007499@cornelisnetworks.com> (raw)
In-Reply-To: <20201125150224.GO5487@ziepe.ca>

On 11/25/2020 10:02 AM, Jason Gunthorpe wrote:
> On Mon, Nov 23, 2020 at 11:50:24AM -0500, Dennis Dalessandro wrote:
>> @@ -133,8 +121,16 @@ void hfi1_mmu_rb_unregister(struct mmu_rb_handler *handler)
>>   	unsigned long flags;
>>   	struct list_head del_list;
>>   
>> +	/*
>> +	 * do_exit() calls exit_mm() before exit_files() which would call close
>> +	 * and end up in here. If there is no mm, then its a kernel thread and
>> +	 * we need to let it continue the removal.
>> +	 */
>> +	if (current->mm && (handler->mn.mm != current->mm))
>> +		return;
>> +
>>   	/* Unregister first so we don't get any more notifications. */
>> -	mmu_notifier_unregister(&handler->mn, handler->mm);
>> +	mmu_notifier_unregister(&handler->mn, handler->mn.mm);
> 
> This logic cannot be right.. The only caller does:
> 
> 		if (pq->handler)
> 			hfi1_mmu_rb_unregister(pq->handler);
> [..]
> 		kfree(pq);
> 
> So this is leaking the mmu_notifier registration if the user manages
> to trigger hfi1_user_sdma_free_queues() from another process.
> 
> Since hfi1_user_sdma_free_queues() is called from close() it doesn't
> look OK.
> 
> When the object that creates the notifier is destroyed the notifier
> should be deleted unconditionally.
> 
> Only accesses to a VA should be qualified to ensure that a notifier is
> registered on current->mm before touching the VA.

Ah yes. I think this just all goes away then. The context init and pq 
allocation is what triggers the registration, whenever we tear it down 
it should do the de-registration. v5 coming up after running tests.

-Denny



      reply	other threads:[~2020-11-25 19:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 16:50 Dennis Dalessandro
2020-11-25 15:02 ` Jason Gunthorpe
2020-11-25 19:15   ` Dennis Dalessandro [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=cc07055a-b221-359f-7f2c-052a81007499@cornelisnetworks.com \
    --to=dennis.dalessandro@cornelisnetworks.com \
    --cc=dledford@redhat.com \
    --cc=ira.weiny@intel.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mike.marciniszyn@cornelisnetworks.com \
    --cc=stable@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