History

Merge tag 'fsnotify_for_v6.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull fsnotify fixes from Jan Kara: "Fixes for an inotify deadlock and a data race in fsnotify" * tag 'fsnotify_for_v6.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: inotify: Fix possible deadlock in fsnotify_destroy_mark fsnotify: Avoid data race between fsnotify_recalc_mask() and fsnotify_object_watched()

Linus Torvalds committed 2 years ago

Commit e02f08e2 parents 4770119 cad3f4a8 files · +25 −34Browse files

Showing the changes to include (1 of 8 files). Show all

Unified · Split

include/linux/fsnotify_backend.h+3−7
@@ -217,7 +217,6 @@ struct fsnotify_group { · 216 unmodified lines
217 217
218#define FSNOTIFY_GROUP_USER 0x01 /* user allocated group */218#define FSNOTIFY_GROUP_USER 0x01 /* user allocated group */
219#define FSNOTIFY_GROUP_DUPS 0x02 /* allow multiple marks per object */219#define FSNOTIFY_GROUP_DUPS 0x02 /* allow multiple marks per object */
220#define FSNOTIFY_GROUP_NOFS 0x04 /* group lock is not direct reclaim safe */
221 int flags;220 int flags;
222 unsigned int owner_flags; /* stored flags of mark_mutex owner */221 unsigned int owner_flags; /* stored flags of mark_mutex owner */
223 222
@@ -268,22 +267,19 @@ struct fsnotify_group { · 44 unmodified lines
268static inline void fsnotify_group_lock(struct fsnotify_group *group)267static inline void fsnotify_group_lock(struct fsnotify_group *group)
269{268{
270 mutex_lock(&group->mark_mutex);269 mutex_lock(&group->mark_mutex);
271 if (group->flags & FSNOTIFY_GROUP_NOFS)270 group->owner_flags = memalloc_nofs_save();
272 group->owner_flags = memalloc_nofs_save();
273}271}
274 272
275static inline void fsnotify_group_unlock(struct fsnotify_group *group)273static inline void fsnotify_group_unlock(struct fsnotify_group *group)
276{274{
277 if (group->flags & FSNOTIFY_GROUP_NOFS)275 memalloc_nofs_restore(group->owner_flags);
278 memalloc_nofs_restore(group->owner_flags);
279 mutex_unlock(&group->mark_mutex);276 mutex_unlock(&group->mark_mutex);
280}277}
281 278
282static inline void fsnotify_group_assert_locked(struct fsnotify_group *group)279static inline void fsnotify_group_assert_locked(struct fsnotify_group *group)
283{280{
284 WARN_ON_ONCE(!mutex_is_locked(&group->mark_mutex));281 WARN_ON_ONCE(!mutex_is_locked(&group->mark_mutex));
285 if (group->flags & FSNOTIFY_GROUP_NOFS)282 WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS));
286 WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS));
287}283}
288 284
289/* When calling fsnotify tell it if the data is a path or inode */285/* When calling fsnotify tell it if the data is a path or inode */