]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ep_create_wakeup_source(): dentry name can change under you...
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 24 Sep 2020 23:41:58 +0000 (19:41 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Oct 2020 06:01:31 +0000 (08:01 +0200)
commit 3701cb59d892b88d569427586f01491552f377b1 upstream.

or get freed, for that matter, if it's a long (separately stored)
name.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/eventpoll.c

index 333bb8f9ed0e8d05722f5e8c3965c348ba36a4d1..339453ac834cc7f49dc9139a60581295c8f7e0d4 100644 (file)
@@ -1453,7 +1453,7 @@ static int reverse_path_check(void)
 
 static int ep_create_wakeup_source(struct epitem *epi)
 {
-       const char *name;
+       struct name_snapshot n;
        struct wakeup_source *ws;
 
        if (!epi->ep->ws) {
@@ -1462,8 +1462,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(&n, epi->ffd.file->f_path.dentry);
+       ws = wakeup_source_register(NULL, n.name.name);
+       release_dentry_name_snapshot(&n);
 
        if (!ws)
                return -ENOMEM;