Skip to contentSkip to conversation

ovl: fix mount api conversion braino

PATCH In review Christian Brauner 2 participants 2 messages Jun 16, 2023

Subsystems (2)
lore
Share & tools
lore

Christian Brauner

author maintainer
#0 lore raw

PATCH 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.

Fixes fc0dc3a9b73b ("ovl: port to new mount api")

---

---
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
index b73b14c52961..9eaff5433dc2 100644
@@ -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

maintainer
#1 lore raw
Quoted 13 lines · Christian Brauner

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.

Quoted 7 lines
Fixes fc0dc3a9b73b ("ovl: port to new mount api")

---

---
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/union

I somehow must've missed the earlier failure of overlay/037.

No failures on my tests so far.

Thanks!
Amir.