Skip to content

Commit f644bc4

Browse files
Matthew Bobrowskijankara
authored andcommitted
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: 5e469c8 ("fanotify: copy event fid info to user") Fixes: 44d705b ("fanotify: report name info for FAN_DIR_MODIFY event") Link: https://lore.kernel.org/linux-fsdevel/[email protected]/T/#m15361cd6399dad4396aad650de25dbf6b312288e Link: https://lore.kernel.org/r/1ef8ae9100101eb1a91763c516c2e9a3a3b112bd.1623376346.git.repnop@google.com Signed-off-by: Matthew Bobrowski <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 614124b commit f644bc4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
471471
info_type, fanotify_info_name(info),
472472
info->name_len, buf, count);
473473
if (ret < 0)
474-
return ret;
474+
goto out_close_fd;
475475

476476
buf += ret;
477477
count -= ret;
@@ -519,7 +519,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
519519
fanotify_event_object_fh(event),
520520
info_type, dot, dot_len, buf, count);
521521
if (ret < 0)
522-
return ret;
522+
goto out_close_fd;
523523

524524
buf += ret;
525525
count -= ret;

0 commit comments

Comments
 (0)