提交 b3a00660 编写于 作者: J Jan Kara

dnotify: Handle errors from fsnotify_add_mark_locked() in fcntl_dirnotify()

fsnotify_add_mark_locked() can fail but we do not check its return
value. This didn't matter before commit 9dd813c1 "fsnotify: Move
mark list head from object into dedicated structure" as none of possible
failures could happen for dnotify but after that commit -ENOMEM can be
returned. Handle this error properly in fcntl_dirnotify() as
otherwise we just hit BUG_ON(dn_mark->dn) in dnotify_free_mark().
Reviewed-by: NAmir Goldstein <amir73il@gmail.com>
Reported-by: syzkaller
Fixes: 9dd813c1Signed-off-by: NJan Kara <jack@suse.cz>
上级 ff5abbe7
...@@ -319,7 +319,11 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) ...@@ -319,7 +319,11 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark); dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
spin_lock(&fsn_mark->lock); spin_lock(&fsn_mark->lock);
} else { } else {
fsnotify_add_mark_locked(new_fsn_mark, inode, NULL, 0); error = fsnotify_add_mark_locked(new_fsn_mark, inode, NULL, 0);
if (error) {
mutex_unlock(&dnotify_group->mark_mutex);
goto out_err;
}
spin_lock(&new_fsn_mark->lock); spin_lock(&new_fsn_mark->lock);
fsn_mark = new_fsn_mark; fsn_mark = new_fsn_mark;
dn_mark = new_dn_mark; dn_mark = new_dn_mark;
...@@ -345,6 +349,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) ...@@ -345,6 +349,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
*/ */
if (dn_mark == new_dn_mark) if (dn_mark == new_dn_mark)
destroy = 1; destroy = 1;
error = 0;
goto out; goto out;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册