aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Bobrowski <repnop@google.com>2021-06-11 13:32:06 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-06-23 14:42:41 +0200
commitae1d3b989d19e4d8d4fee612a4d24ef992fcd25f (patch)
tree0d83361ebf013bd8ddaae0982f42b8c0fbdfa124
parent018685461a5b9a9a70e664ac77aef0d7415a3fd5 (diff)
downloadkernel_replicant_linux-ae1d3b989d19e4d8d4fee612a4d24ef992fcd25f.tar.gz
kernel_replicant_linux-ae1d3b989d19e4d8d4fee612a4d24ef992fcd25f.tar.bz2
kernel_replicant_linux-ae1d3b989d19e4d8d4fee612a4d24ef992fcd25f.zip
fanotify: fix copy_event_to_user() fid error clean up
[ Upstream commit f644bc449b37cc32d3ce7b36a88073873aa21bd5 ] 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: 5e469c830fdb ("fanotify: copy event fid info to user") Fixes: 44d705b0370b ("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.com Signed-off-by: Matthew Bobrowski <repnop@google.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/notify/fanotify/fanotify_user.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index dcab112e1f00..086b6bacbad1 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -378,7 +378,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
info_type, fanotify_info_name(info),
info->name_len, buf, count);
if (ret < 0)
- return ret;
+ goto out_close_fd;
buf += ret;
count -= ret;
@@ -426,7 +426,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
fanotify_event_object_fh(event),
info_type, dot, dot_len, buf, count);
if (ret < 0)
- return ret;
+ goto out_close_fd;
buf += ret;
count -= ret;