Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbdGaMWI (ORCPT ); Mon, 31 Jul 2017 08:22:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:42643 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751054AbdGaMWG (ORCPT ); Mon, 31 Jul 2017 08:22:06 -0400 Date: Mon, 31 Jul 2017 14:22:04 +0200 From: Michal Hocko To: Mike Rapoport Cc: Andrew Morton , Andrea Arcangeli , "Dr. David Alan Gilbert" , Pavel Emelyanov , linux-mm , lkml , stable@vger.kernel.org Subject: Re: [PATCH] userfaultfd_zeropage: return -ENOSPC in case mm has gone Message-ID: <20170731122204.GB4878@dhcp22.suse.cz> References: <1501136819-21857-1-git-send-email-rppt@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1501136819-21857-1-git-send-email-rppt@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1500 Lines: 46 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 > --- > > 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: email@kvack.org -- Michal Hocko SUSE Labs