[lkml]   [2017]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] userfaultfd_zeropage: 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.

Fixes: 96333187ab162 ("userfaultfd_copy: return -ENOSPC in case mm has gone")

Signed-off-by: Mike Rapoport <>

Unfortunately, I've overlooked userfaultfd_zeropage when I updated
userfaultd_copy :(

fs/userfaultfd.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index cadcd12a3d35..2d8c2d848668 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1643,6 +1643,8 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx,
ret = mfill_zeropage(ctx->mm, uffdio_zeropage.range.start,
+ } else {
+ return -ENOSPC;
if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage)))
return -EFAULT;
 \ /
  Last update: 2017-07-27 08:27    [W:0.069 / U:5.676 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site