]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
hostfs: fix memory handling in follow_link()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 25 Mar 2021 18:12:34 +0000 (14:12 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 May 2021 07:53:33 +0000 (09:53 +0200)
commitb4ee9221990464ff19675c3ad5bcaea1f9dbad83
tree5927690c41faab1fe75564b8f5095f764b7d1645
parenta34517545fb0ded49d6a77288768a7c3ac7d6aa4
hostfs: fix memory handling in follow_link()

BugLink: https://bugs.launchpad.net/bugs/1926368
[ Upstream commit 7f6c411c9b50cfab41cc798e003eff27608c7016 ]

1) argument should not be freed in any case - the caller already has
it as ->s_fs_info (and uses it a lot afterwards)
2) allocate readlink buffer with kmalloc() - the caller has no way
to tell if it's got that (on absolute symlink) or a result of
kasprintf().  Sure, for SLAB and SLUB kfree() works on results of
kmem_cache_alloc(), but that's not documented anywhere, might change
in the future *and* is already not true for SLOB.

Fixes: 52b209f7b848 ("get rid of hostfs_read_inode()")
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/hostfs/hostfs_kern.c