From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 F0E6B272E53; Thu, 20 Aug 2026 16:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787243856; cv=none; b=njflVbJveL7ri+DeSRjWTwRVrGt9WtI6fQLohyXh/tqsLmoNTSYPMNxTWp30PrGGL/PQMO5O47i+NsHB5O0G8GUVB+DPVsGxFhPhFtqVdsjXocbDq7fzPdhho7PYG/0TY+eIyx8uR2r7HmGGmCK58s8pfjI429AY4DHNdykyTwM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787243856; c=relaxed/simple; bh=ioi4SMfaZvpPb9ez+vBb4ivHCNHKTs+MPDml2NYu3tg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mWqvIWLosnfTcfKk3MPMFHVKNPPvDjCVPpETnasy7wVMRpibW8O0fxwoF0Ir4SUnYiTdpcebofpnwEsUKHZ/6R0DYR5Xk/NMHtUA1WT6N93N49H4dzAMs1ZPemy/tA5f66z+ONDwNtF81llmg3xilrSbFmj3DaUHLsGXlUxbVPo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=a9JjZZyw; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="a9JjZZyw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 576761F000E9; Thu, 20 Aug 2026 16:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787243854; bh=2B9qCwydrC8qzG3sAbLMZfuZC8RnW5GDU1c6x9yAMm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a9JjZZywBCIwFaFqUicSrNE/WEtq2LQxxpoKGtLmbIm0l4r0LEd2wlkebHcs1GQBj CwdWxvI0JdxBQhHqWyTVEtZbzBfpB8KJrbeSZDcFGekf9zQcYpaXkoDP7p2F144Pd6 Vgs9xfNQ9IadJfQBd296k/e4hCidRMCnLNz2GUPc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Linus Torvalds , Amir Goldstein , Jan Kara , Sasha Levin Subject: [PATCH 5.15 237/272] fsnotify: opt-in for permission events at file open time Date: Thu, 20 Aug 2026 16:57:01 +0200 Message-ID: <20260820145238.727131730@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145231.229664293@linuxfoundation.org> References: <20260820145231.229664293@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein [ Upstream commit a94204f4d48e28a711b7ed10399f749286c433e3 ] Legacy inotify/fanotify listeners can add watches for events on inode, parent or mount and expect to get events (e.g. FS_MODIFY) on files that were already open at the time of setting up the watches. fanotify permission events are typically used by Anti-malware sofware, that is watching the entire mount and it is not common to have more that one Anti-malware engine installed on a system. To reduce the overhead of the fsnotify_file_perm() hooks on every file access, relax the semantics of the legacy FAN_ACCESS_PERM event to generate events only if there were *any* permission event listeners on the filesystem at the time that the file was opened. The new semantic is implemented by extending the FMODE_NONOTIFY bit into two FMODE_NONOTIFY_* bits, that are used to store a mode for which of the events types to report. This is going to apply to the new fanotify pre-content events in order to reduce the cost of the new pre-content event vfs hooks. [Thanks to Bert Karwatzki for reporting a bug in this code with CONFIG_FANOTIFY_ACCESS_PERMISSIONS disabled] Suggested-by: Linus Torvalds Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wj8L=mtcRTi=NECHMGfZQgXOp_uix1YVh04fEmrKaMnXA@mail.gmail.com/ Signed-off-by: Amir Goldstein Signed-off-by: Jan Kara Link: https://patch.msgid.link/5ea5f8e283d1edb55aa79c35187bfe344056af14.1731684329.git.josef@toxicpanda.com Stable-dep-of: db1856ea9196 ("binfmt_misc: restore write access when removing an entry") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- include/linux/fs.h | 6 ++++++ 1 file changed, 6 insertions(+) --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -181,6 +181,12 @@ typedef int (dio_iodone_t)(struct kiocb #define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000) /* + * fsnotify pre-content events do not exist in this kernel, so a file is never + * watched by a pre-content event listener. + */ +#define FMODE_FSNOTIFY_HSM(mode) 0 + +/* * Attribute flags. These should be or-ed together to figure out what * has been changed! */