Skip to content

Commit 0c0214d

Browse files
committed
fanotify: Fix crash in fanotify_init(2)
The rrror handling in fanotify_init(2) is buggy and overwrites 'fd' before calling put_unused_fd() leading to possible access beyond the end of fd bitmap. Fix it. Reported-by: [email protected] Fixes: ebe5596 ("fs: get rid of __FMODE_NONOTIFY kludge") Signed-off-by: Jan Kara <[email protected]>
1 parent 0357ef0 commit 0c0214d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,8 +1624,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
16241624
file = anon_inode_getfile_fmode("[fanotify]", &fanotify_fops, group,
16251625
f_flags, FMODE_NONOTIFY);
16261626
if (IS_ERR(file)) {
1627-
fd = PTR_ERR(file);
16281627
put_unused_fd(fd);
1628+
fd = PTR_ERR(file);
16291629
goto out_destroy_group;
16301630
}
16311631
fd_install(fd, file);

0 commit comments

Comments
 (0)