From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0C3FC4363D for ; Mon, 5 Oct 2020 14:45:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8162207F7 for ; Mon, 5 Oct 2020 14:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601909109; bh=mFnyq0uxT6aNGNU2RGIso9hOeLqRjgPZIYTTWfIpyl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=COZHVVMaWC7E5dTwmvtl1hHBNZKvHXmNUvPF/0paxEAx2wTNhbZrG0sWaG8pDtRJr YSF7LgtErBHCCROZ6Dr6SWM3Kh2yjOq1a6gestW11Kgpa70902Zn2+fDF1QW27VAWq Kj7Vx+CIX69H3yGOA2ftA9H1QbEPJ8h1ogMmtST4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726583AbgJEOpI (ORCPT ); Mon, 5 Oct 2020 10:45:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:51880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbgJEOpH (ORCPT ); Mon, 5 Oct 2020 10:45:07 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E0F92208B6; Mon, 5 Oct 2020 14:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601909107; bh=mFnyq0uxT6aNGNU2RGIso9hOeLqRjgPZIYTTWfIpyl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TCQj1ulWus65ethmGaTPquIdfQz9M7cscM4ixcYxIdZVwXFmujrwlCp8tLgcoDCEq 9gqhLhY57su/ZBnCLd0GK/YJWk8r6wAiDujCQLhscHXhk5ng7RGn8zbWehdbtyCft8 CJ+wiqSuZuoNyN/7ReLwwJiAWRHaIeicLVX5SmsQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Al Viro , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.8 05/12] ep_create_wakeup_source(): dentry name can change under you... Date: Mon, 5 Oct 2020 10:44:53 -0400 Message-Id: <20201005144501.2527477-5-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201005144501.2527477-1-sashal@kernel.org> References: <20201005144501.2527477-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Al Viro [ Upstream commit 3701cb59d892b88d569427586f01491552f377b1 ] or get freed, for that matter, if it's a long (separately stored) name. Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/eventpoll.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 16313180e4c16..4df61129566d4 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1448,7 +1448,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) { @@ -1457,8 +1457,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; -- 2.25.1