[PATCH FOLD] ovl: fix mount api conversion braino

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Fixes: fc0dc3a9b73b ("ovl: port to new mount api")
Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
---

---
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(+)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index b73b14c52961..9eaff5433dc2 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -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




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux