Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1697740 > unrolled thread

[PATCH] userfaultfd_zeropage: return -ENOSPC in case mm has gone

Started byMike Rapoport <rppt@linux.vnet.ibm.com>
First post2017-07-27 08:30 +0200
Last post2017-07-31 14:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] userfaultfd_zeropage: return -ENOSPC in case mm has gone Mike Rapoport <rppt@linux.vnet.ibm.com> - 2017-07-27 08:30 +0200
    Re: [PATCH] userfaultfd_zeropage: return -ENOSPC in case mm has gone Michal Hocko <mhocko@kernel.org> - 2017-07-31 14:30 +0200

#1697740 — [PATCH] userfaultfd_zeropage: return -ENOSPC in case mm has gone

FromMike Rapoport <rppt@linux.vnet.ibm.com>
Date2017-07-27 08:30 +0200
Subject[PATCH] userfaultfd_zeropage: return -ENOSPC in case mm has gone
Message-ID<u7Kt4-2Ab-7@gated-at.bofh.it>
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.


Cc: stable@vger.kernel.org
Fixes: 96333187ab162 ("userfaultfd_copy: return -ENOSPC in case mm has gone")

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---

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,
 				     uffdio_zeropage.range.len);
 		mmput(ctx->mm);
+	} else {
+		return -ENOSPC;
 	}
 	if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage)))
 		return -EFAULT;
-- 
2.7.4

[toc] | [next] | [standalone]


#1699991

FromMichal Hocko <mhocko@kernel.org>
Date2017-07-31 14:30 +0200
Message-ID<u9hZF-6eS-13@gated-at.bofh.it>
In reply to#1697740
On Thu 27-07-17 09:26:59, Mike Rapoport wrote:
> 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.

Normally we tend to return ESRCH in such case. ENOSPC sounds rather
confusing...
 
> Cc: stable@vger.kernel.org
> Fixes: 96333187ab162 ("userfaultfd_copy: return -ENOSPC in case mm has gone")
> 
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> ---
> 
> 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,
>  				     uffdio_zeropage.range.len);
>  		mmput(ctx->mm);
> +	} else {
> +		return -ENOSPC;
>  	}
>  	if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage)))
>  		return -EFAULT;
> -- 
> 2.7.4
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web