Skip to content

Commit 9cf90ce

Browse files
committed
fsnotify: Protect bail out path of fsnotify_add_mark_locked() properly
When fsnotify_add_mark_locked() fails it cleans up the mark it was adding. Since the mark is already visible in group's list, we should protect update of mark->flags with mark->lock. I'm not aware of any real issues this could cause (since we also hold group->mark_mutex) but better be safe and obey locking rules properly. Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent b3a0066 commit 9cf90ce

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎fs/notify/mark.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,11 @@ int fsnotify_add_mark_locked(struct fsnotify_mark *mark, struct inode *inode,
599599

600600
return ret;
601601
err:
602+
spin_lock(&mark->lock);
602603
mark->flags &= ~(FSNOTIFY_MARK_FLAG_ALIVE |
603604
FSNOTIFY_MARK_FLAG_ATTACHED);
604605
list_del_init(&mark->g_list);
606+
spin_unlock(&mark->lock);
605607
atomic_dec(&group->num_marks);
606608

607609
fsnotify_put_mark(mark);

0 commit comments

Comments
 (0)