From: Al Viro Date: Thu, 24 Sep 2020 23:41:58 +0000 (-0400) Subject: ep_create_wakeup_source(): dentry name can change under you... X-Git-Tag: v4.14.201~42 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a3915080e95da5257c541bbc39fa4007076d8fa3;p=users%2Fdwmw2%2Flinux.git ep_create_wakeup_source(): dentry name can change under you... commit 3701cb59d892b88d569427586f01491552f377b1 upstream. or get freed, for that matter, if it's a long (separately stored) name. Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 634baff806945..c9feb119aa473 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1389,7 +1389,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) { @@ -1398,8 +1398,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(name); + take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry); + ws = wakeup_source_register(n.name); + release_dentry_name_snapshot(&n); if (!ws) return -ENOMEM;