Oleg Nesterov 46d0b24c5e userfaultfd_release: always remove uffd flags and clear vm_userfaultfd_ctx
userfaultfd_release() should clear vm_flags/vm_userfaultfd_ctx even if
mm->core_state != NULL.

Otherwise a page fault can see userfaultfd_missing() == T and use an
already freed userfaultfd_ctx.

Link: http://lkml.kernel.org/r/20190820160237.GB4983@redhat.com
Fixes: 04f5866e41fb ("coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping")
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
Tested-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Jann Horn <jannh@google.com>
Cc: Jason Gunthorpe <jgg@mellanox.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-24 19:48:42 -07:00
..
2019-08-18 09:51:48 -07:00
2019-07-12 17:37:53 -07:00
2019-07-12 16:54:37 -07:00
2019-07-30 13:15:39 -07:00
2019-08-09 16:56:12 +01:00
2019-07-25 11:05:11 +02:00
2019-07-03 17:52:09 -04:00
2019-06-21 09:58:42 -07:00
\n
2019-07-10 20:27:07 -07:00
\n
2019-07-10 20:09:17 -07:00
\n
2019-07-10 20:27:07 -07:00
2019-08-15 11:09:16 -06:00
2019-07-15 21:20:52 -07:00
2019-05-21 08:23:41 +01:00
2019-04-08 18:21:02 -05:00
2019-03-08 14:48:40 -08:00
2019-07-12 16:54:37 -07:00
2019-07-10 21:22:43 -07:00
2019-02-07 16:38:35 +01:00
2019-07-31 12:22:32 -04:00