linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@linux.vnet.ibm.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Pavel Emelyanov <xemul@virtuozzo.com>,
	Hillf Danton <hillf.zj@alibaba-inc.com>
Subject: Re: [PATCH 1/3] userfaultfd: non-cooperative: fix fork fctx->new memleak
Date: Fri,  3 Mar 2017 13:09:26 +0200	[thread overview]
Message-ID: <1488539366-22846-1-git-send-email-rppt@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170302173738.18994-2-aarcange@redhat.com>

> From: Mike Rapoport <rppt@linux.vnet.ibm.com>
> 
> We have a memleak in the ->new ctx if the uffd of the parent is closed
> before the fork event is read, nothing frees the new context.
> 
> Reported-by: Andrea Arcangeli <aarcange@redhat.com>

I think
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
would be appropriate here.

> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
> ---
>  fs/userfaultfd.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> index d2f15a6..5087a69 100644
> --- a/fs/userfaultfd.c
> +++ b/fs/userfaultfd.c
> @@ -548,6 +548,15 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
>  		if (ACCESS_ONCE(ctx->released) ||
>  		    fatal_signal_pending(current)) {
>  			__remove_wait_queue(&ctx->event_wqh, &ewq->wq);
> +			if (ewq->msg.event == UFFD_EVENT_FORK) {
> +				struct userfaultfd_ctx *new;
> +
> +				new = (struct userfaultfd_ctx *)
> +					(unsigned long)
> +					ewq->msg.arg.reserved.reserved1;
> +
> +				userfaultfd_ctx_put(new);
> +			}
>  			break;
>  		}

--
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>

  reply	other threads:[~2017-03-03 11:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-02 17:37 [PATCH 0/3] userfaultfd v4.11 updates Andrea Arcangeli
2017-03-02 17:37 ` [PATCH 1/3] userfaultfd: non-cooperative: fix fork fctx->new memleak Andrea Arcangeli
2017-03-03 11:09   ` Mike Rapoport [this message]
2017-09-28  9:26   ` Sasha Levin
2017-09-28 10:16     ` Andrea Arcangeli
2017-03-02 17:37 ` [PATCH 2/3] userfaultfd: non-cooperative: userfaultfd_remove revalidate vma in MADV_DONTNEED Andrea Arcangeli
2017-03-03 19:48   ` Mike Rapoport
2017-03-02 17:37 ` [PATCH 3/3] userfaultfd: selftest: vm: allow to build in vm/ directory Andrea Arcangeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1488539366-22846-1-git-send-email-rppt@linux.vnet.ibm.com \
    --to=rppt@linux.vnet.ibm.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dgilbert@redhat.com \
    --cc=hillf.zj@alibaba-inc.com \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=xemul@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).