public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Jann Horn <jannh@google.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Arve Hjønnevåg" <arve@android.com>, NeilBrown <neilb@suse.de>,
	"Rafael J . Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH] epoll: Fix UAF dentry name access in wakeup source setup
Date: Wed, 29 Apr 2020 03:46:48 +0100	[thread overview]
Message-ID: <20200429024648.GA23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20200429023104.131925-1-jannh@google.com>

On Wed, Apr 29, 2020 at 04:31:04AM +0200, Jann Horn wrote:

> I'm guessing this will go through akpm's tree?
> 
>  fs/eventpoll.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/eventpoll.c b/fs/eventpoll.c
> index 8c596641a72b0..5052a41670479 100644
> --- a/fs/eventpoll.c
> +++ b/fs/eventpoll.c
> @@ -1450,7 +1450,7 @@ static int reverse_path_check(void)
>  
>  static int ep_create_wakeup_source(struct epitem *epi)
>  {
> -	const char *name;
> +	struct name_snapshot name;
>  	struct wakeup_source *ws;
>  
>  	if (!epi->ep->ws) {
> @@ -1459,8 +1459,9 @@ static int ep_create_wakeup_source(struct epitem *epi)
>  			return -ENOMEM;
>  	}
>  
> -	name = epi->ffd.file->f_path.dentry->d_name.name;
> -	ws = wakeup_source_register(NULL, name);
> +	take_dentry_name_snapshot(&name, epi->ffd.file->f_path.dentry);
> +	ws = wakeup_source_register(NULL, name.name.name);
> +	release_dentry_name_snapshot(&name);

I'm not sure I like it.  Sure, it won't get freed under you that way; it still
can go absolutely stale by the time you return from wakeup_source_register().
What is it being used for?

  reply	other threads:[~2020-04-29  2:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29  2:31 [PATCH] epoll: Fix UAF dentry name access in wakeup source setup Jann Horn
2020-04-29  2:46 ` Al Viro [this message]
2020-04-29  3:30   ` Jann Horn

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=20200429024648.GA23230@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=arve@android.com \
    --cc=jannh@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=rjw@sisk.pl \
    /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