From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8110F146D53; Tue, 9 Jul 2024 11:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720524327; cv=none; b=DT7Q34dyVAqJrwEZRz9OQHhojC0vaAZ6eLaeUgPVgqrzhqGOQtmLcwkuUEbjqklxtlN79MrTJixTr+UzoD6kvsPiUXcDolJ7egBA/N/9qKG1NC3K/7R1QJnPF17xmBKQi42gD4A8b4Xgj7nFijgJrwBExMlU158JHKyD8OdWqCg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720524327; c=relaxed/simple; bh=ld9Kuj/HW9IS5AGmlpkCtA7witPj9MBaabOvl+EvqYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M/YBgPAwW3jrnQ8NfU6ep4lVIJPQzuINXksctfTd9TlnHfQGyaqBBf6qZ0zZQ1/0QRFwlpmETpmJAyYnqlZcG7YotthkDOQBIpTqTP7ddsFrViFgX4g5MDcybGt6O77I1DeWUp3JE4wgpBpM0iZdC5g1CyFMPG6AFjvhR99Kagg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Qutp6LYr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Qutp6LYr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07F8BC3277B; Tue, 9 Jul 2024 11:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720524327; bh=ld9Kuj/HW9IS5AGmlpkCtA7witPj9MBaabOvl+EvqYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qutp6LYrtWqptRl6a+B5Z/vV0T7R7O7vubfbmxc2TzbJdTyjWFQjYo1q9wQAapZSk vB1ljU5M5vGf7K2xM+fu3nMHpJflnRBojGegqVt/b/WVJHeMv3mRJPq2wDRMrrRYAG njGfOxRWELvyKjzWxhnuBFzDaXXlGnxI5w8Fd65Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jan Kara , Amir Goldstein , Christian Brauner Subject: [PATCH 6.9 147/197] fsnotify: Do not generate events for O_PATH file descriptors Date: Tue, 9 Jul 2024 13:10:01 +0200 Message-ID: <20240709110714.639143175@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709110708.903245467@linuxfoundation.org> References: <20240709110708.903245467@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit 702eb71fd6501b3566283f8c96d7ccc6ddd662e9 upstream. Currently we will not generate FS_OPEN events for O_PATH file descriptors but we will generate FS_CLOSE events for them. This is asymmetry is confusing. Arguably no fsnotify events should be generated for O_PATH file descriptors as they cannot be used to access or modify file content, they are just convenient handles to file objects like paths. So fix the asymmetry by stopping to generate FS_CLOSE for O_PATH file descriptors. Cc: Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20240617162303.1596-1-jack@suse.cz Reviewed-by: Amir Goldstein Signed-off-by: Christian Brauner Signed-off-by: Greg Kroah-Hartman --- include/linux/fsnotify.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -99,7 +99,13 @@ static inline int fsnotify_file(struct f { const struct path *path; - if (file->f_mode & FMODE_NONOTIFY) + /* + * FMODE_NONOTIFY are fds generated by fanotify itself which should not + * generate new events. We also don't want to generate events for + * FMODE_PATH fds (involves open & close events) as they are just + * handle creation / destruction events and not "real" file events. + */ + if (file->f_mode & (FMODE_NONOTIFY | FMODE_PATH)) return 0; path = &file->f_path;