diff options
author | Jan Kara <jack@suse.cz> | 2017-10-31 05:09:25 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2017-10-31 12:54:56 -0400 |
commit | 9cf90cef362d44b2f3fcdb7d0694849a6308b620 (patch) | |
tree | 7eac90d6bf1a97b485d6a3b7483042089d3756d7 /fs/notify | |
parent | b3a0066005821acdc0cdb092cb72587182ab583f (diff) |
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>
Diffstat (limited to 'fs/notify')
-rw-r--r-- | fs/notify/mark.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 9991f8826734..47a827975b58 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c | |||
@@ -599,9 +599,11 @@ int fsnotify_add_mark_locked(struct fsnotify_mark *mark, struct inode *inode, | |||
599 | 599 | ||
600 | return ret; | 600 | return ret; |
601 | err: | 601 | err: |
602 | spin_lock(&mark->lock); | ||
602 | mark->flags &= ~(FSNOTIFY_MARK_FLAG_ALIVE | | 603 | mark->flags &= ~(FSNOTIFY_MARK_FLAG_ALIVE | |
603 | FSNOTIFY_MARK_FLAG_ATTACHED); | 604 | FSNOTIFY_MARK_FLAG_ATTACHED); |
604 | list_del_init(&mark->g_list); | 605 | list_del_init(&mark->g_list); |
606 | spin_unlock(&mark->lock); | ||
605 | atomic_dec(&group->num_marks); | 607 | atomic_dec(&group->num_marks); |
606 | 608 | ||
607 | fsnotify_put_mark(mark); | 609 | fsnotify_put_mark(mark); |