提交 c9682d10 编写于 作者: J Jann Horn 提交者: Linus Torvalds

mm/mmu_notifier: fix mmget() assert in __mmu_interval_notifier_insert

The comment talks about having to hold mmget() (which means mm_users), but
the actual check is on mm_count (which would be mmgrab()).

Given that MMU notifiers are torn down in mmput() -> __mmput() ->
exit_mmap() -> mmu_notifier_release(), I believe that the comment is
correct and the check should be on mm->mm_users.  Fix it up accordingly.

Fixes: 99cb252f ("mm/mmu_notifier: add an interval tree notifier")
Signed-off-by: NJann Horn <jannh@google.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: NJason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Christian König <christian.koenig@amd.com
Link: https://lkml.kernel.org/r/20200901000143.207585-1-jannh@google.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 295a1730
...@@ -913,7 +913,7 @@ static int __mmu_interval_notifier_insert( ...@@ -913,7 +913,7 @@ static int __mmu_interval_notifier_insert(
return -EOVERFLOW; return -EOVERFLOW;
/* Must call with a mmget() held */ /* Must call with a mmget() held */
if (WARN_ON(atomic_read(&mm->mm_count) <= 0)) if (WARN_ON(atomic_read(&mm->mm_users) <= 0))
return -EINVAL; return -EINVAL;
/* pairs with mmdrop in mmu_interval_notifier_remove() */ /* pairs with mmdrop in mmu_interval_notifier_remove() */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册