提交 f644bc44 编写于 作者: M Matthew Bobrowski 提交者: Jan Kara

fanotify: fix copy_event_to_user() fid error clean up

Ensure that clean up is performed on the allocated file descriptor and
struct file object in the event that an error is encountered while copying
fid info objects. Currently, we return directly to the caller when an error
is experienced in the fid info copying helper, which isn't ideal given that
the listener process could be left with a dangling file descriptor in their
fdtable.

Fixes: 5e469c83 ("fanotify: copy event fid info to user")
Fixes: 44d705b0 ("fanotify: report name info for FAN_DIR_MODIFY event")
Link: https://lore.kernel.org/linux-fsdevel/YMKv1U7tNPK955ho@google.com/T/#m15361cd6399dad4396aad650de25dbf6b312288e
Link: https://lore.kernel.org/r/1ef8ae9100101eb1a91763c516c2e9a3a3b112bd.1623376346.git.repnop@google.comSigned-off-by: NMatthew Bobrowski <repnop@google.com>
Signed-off-by: NJan Kara <jack@suse.cz>
上级 614124be
...@@ -471,7 +471,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, ...@@ -471,7 +471,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
info_type, fanotify_info_name(info), info_type, fanotify_info_name(info),
info->name_len, buf, count); info->name_len, buf, count);
if (ret < 0) if (ret < 0)
return ret; goto out_close_fd;
buf += ret; buf += ret;
count -= ret; count -= ret;
...@@ -519,7 +519,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, ...@@ -519,7 +519,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
fanotify_event_object_fh(event), fanotify_event_object_fh(event),
info_type, dot, dot_len, buf, count); info_type, dot, dot_len, buf, count);
if (ret < 0) if (ret < 0)
return ret; goto out_close_fd;
buf += ret; buf += ret;
count -= ret; count -= ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册