]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
udf: Fix error handling in udf_new_inode()
authorJan Kara <jack@suse.cz>
Tue, 14 Dec 2021 10:04:29 +0000 (11:04 +0100)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 10:02:59 +0000 (11:02 +0100)
BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit f05f2429eec60851b98bdde213de31dab697c01b ]

When memory allocation of iinfo or block allocation fails, already
allocated struct udf_inode_info gets freed with iput() and
udf_evict_inode() may look at inode fields which are not properly
initialized. Fix it by marking inode bad before dropping reference to it
in udf_new_inode().

Reported-by: syzbot+9ca499bb57a2b9e4c652@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/udf/ialloc.c

index 2ecf0e87660e3226018e5bfaf9580d84877a5251..b5d611cee749ca422b63dbf1db6fd15c629df3c8 100644 (file)
@@ -77,6 +77,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
                                        GFP_KERNEL);
        }
        if (!iinfo->i_data) {
+               make_bad_inode(inode);
                iput(inode);
                return ERR_PTR(-ENOMEM);
        }
@@ -86,6 +87,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
                              dinfo->i_location.partitionReferenceNum,
                              start, &err);
        if (err) {
+               make_bad_inode(inode);
                iput(inode);
                return ERR_PTR(err);
        }