[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1485542673-24387-6-git-send-email-rppt@linux.vnet.ibm.com>
Date: Fri, 27 Jan 2017 20:44:33 +0200
From: Mike Rapoport <rppt@...ux.vnet.ibm.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andrea Arcangeli <aarcange@...hat.com>,
"Dr. David Alan Gilbert" <dgilbert@...hat.com>,
Hillf Danton <hillf.zj@...baba-inc.com>,
Mike Kravetz <mike.kravetz@...cle.com>,
Pavel Emelyanov <xemul@...tuozzo.com>,
Linux-MM <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
Mike Rapoport <rppt@...ux.vnet.ibm.com>
Subject: [PATCH v2 5/5] userfaultfd_copy: return -ENOSPC in case mm has gone
In the non-cooperative userfaultfd case, the process exit may race with
outstanding mcopy_atomic called by the uffd monitor. Returning -ENOSPC
instead of -EINVAL when mm is already gone will allow uffd monitor to
distinguish this case from other error conditions.
Signed-off-by: Mike Rapoport <rppt@...ux.vnet.ibm.com>
Acked-by: Hillf Danton <hillf.zj@...baba-inc.com>
---
fs/userfaultfd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 839ffd5..6587f40 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1603,6 +1603,8 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx,
ret = mcopy_atomic(ctx->mm, uffdio_copy.dst, uffdio_copy.src,
uffdio_copy.len);
mmput(ctx->mm);
+ } else {
+ return -ENOSPC;
}
if (unlikely(put_user(ret, &user_uffdio_copy->copy)))
return -EFAULT;
--
1.9.1
Powered by blists - more mailing lists