ovl: fix mount api conversion braino
Subsystems (2)
Christian Brauner
maintainerPATCH 1/1 ovl: fix mount api conversion braino
Cleanup sb->s_fs_info when ovl_fill_super() fails before setting sb->s_root. The logic is a bit convoluted but tl;dr: If sget_fc() has succeeded fc->s_fs_info will have been transferred to sb->s_fs_info. So by the time ->fill_super()/ovl_fill_super() is called fc->s_fs_info is NULL consequently fs_context->free() won't call ovl_free_fs(). If we fail before sb->s_root() is set then ->put_super() won't be called which would call ovl_free_fs(). IOW, if we fail in ->fill_super() before sb->s_root we have to clean it up.
Amir reported an issue when running xfstests overlay/037 which made me investigate and detect this.
---
---
I would just fold this into ("ovl: port to new mount api"). The patch here is mostly so we have a track record of the issue.
Passes both
sudo ./check -overlay overlay/*
sudo ./check -overlay -g overlay/union
I somehow must've missed the earlier failure of overlay/037.
--- fs/overlayfs/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/overlayfs/super.c +2 -0
@@ -1949,6 +1949,8 @@ static int ovl_fill_super(struct super_block *sb, struct fs_context *fc) out_free_oe:ovl_free_entry (oe); out_err: +ovl_free_fs (ofs); + sb->s_fs_info =NULL ;return err; }
---
base-commit: 2543e5b405156bf506d22db5fc2b04eb7cf236da
change-id: 20230616-fs-overlayfs-mount_api-fix-b1caedfaf8ed
Amir Goldstein
maintainerQuoted 13 lines · Christian Brauner
Cleanup
sb->s_fs_infowhenovl_fill_super()fails before settingsb->s_root. The logic is a bit convoluted but tl;dr: Ifsget_fc()has succeededfc->s_fs_infowill have been transferred tosb->s_fs_info. So by the time ->fill_super()/ovl_fill_super() is calledfc->s_fs_infois NULL consequentlyfs_context->free()won't callovl_free_fs(). If we fail beforesb->s_root()is set then ->put_super() won't be called which would callovl_free_fs(). IOW, if we fail in ->fill_super() beforesb->s_rootwe have to clean it up.Amir reported an issue when running xfstests overlay/037 which made me investigate and detect this.
Quoted 7 lines
Fixes fc0dc3a9b73b ("ovl: port to new mount api")Signed-off-by Christian Brauner <[email protected]>---
---
I would just fold this into ("ovl: port to new mount api"). The patch here is mostly so we have a track record of the issue.
Folder (with commit message) and applied to
https://github.com/amir73il/linux/commits/fs-overlayfs-mount_api
I've split out two prep patches, so "port to new mount api" patch is now as clean as it can be.
Quoted 7 lines
Passes both
sudo ./check -overlay overlay/*
sudo ./check -overlay -g overlay/unionI somehow must've missed the earlier failure of overlay/037.
No failures on my tests so far.
Thanks!
Amir.