[Devel] [PATCH rh7] ext4: fix file allocation check in ext4_open_balloon

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Wed Nov 11 09:56:05 PST 2015


Function alloc_file() doesn't return NULL. It returns error pointer.
File structure allocation may fail before file->f_ep_links is initialized,
which may lead to crash in eventpoll_release_file().

https://jira.sw.ru/browse/PSBM-41222

Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
 fs/ext4/ioctl.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index d94aa19..05af494 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -234,9 +234,10 @@ static int ext4_open_balloon(struct super_block *sb, struct vfsmount *mnt)
 			&ext4_file_operations);
 	if (mode & FMODE_WRITE)
 		mnt_drop_write(path.mnt);
-	err = -ENOMEM;
-	if (filp == NULL)
+	if (IS_ERR(filp)) {
+		err = PTR_ERR(filp);
 		goto err_filp;
+	}
 
 	filp->f_flags |= O_LARGEFILE;
 	fd_install(fd, filp);



More information about the Devel mailing list