Skip to contentSkip to conversation

ovl: detect overlapping layers with nested lower overlayfs

PATCH New Amir Goldstein 1 participant 1 message Jul 26, 2019 Overlay filesystem

lore
Share & tools
lore

Amir Goldstein

author maintainer
#0 lore raw

PATCH 1/1 ovl: detect overlapping layers with nested lower overlayfs

We want to avoid overlay layers lookup finding the same underlying directory inode in different layers of the overlay, so we try to detect overlapping layers on mount and on lookup.

But if lookup in overlay lower layer which is another overlayfs instance, we could end up finding the same underlying directory in the nested overlayfs underlying layers.

To avoid that, when looking for traps that were setup to find layer root inodes, also look for traps in the nested lower overlayfs layers if such lower layers exist.

---

Miklos,

I know you objected to this sort of layer violation in the past (circa nested xino) and I know you care very little for nested overlay setups, but I'd still like to keep syzbot happy and let it find the real bugs.

So I'm just putting this fix out here for your consideration. Have any better ideas?

Tests are available on my xfstests ovl-fixes branch [1].

Thanks,
Amir.

[1] https://github.com/amir73il/xfstests/commits/ovl-fixes

 fs/overlayfs/namei.c     |  2 +-
 fs/overlayfs/overlayfs.h | 11 +++++++
 fs/overlayfs/super.c     | 68 ++++++++++++++++++++++++++++++++++------
 3 files changed, 70 insertions(+), 11 deletions(-)
fs/overlayfs/namei.c +1 -1
index e9717c2f7d45..edd9d7b38a2d 100644
@@ -242,7 +242,7 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
 		if (!d->metacopy || d->last)
 			goto out;
 	} else {
-		if (ovl_lookup_trap_inode(d->sb, this)) {
+		if (ovl_check_traps(d->sb, d->sb->s_fs_info, this)) {
 			/* Caught in a trap of overlapping layers */
 			err = -ELOOP;
 			goto out_err;
fs/overlayfs/overlayfs.h +11 -0
index 6934bcf030f0..9289ba1d48cd 100644
@@ -430,3 +430,14 @@ int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
 
 /* export.c */
 extern const struct export_operations ovl_export_operations;
+
+/* super.c */
+bool ovl_check_traps(struct super_block *sb, struct ovl_fs *ofs,
+		     struct dentry *dir);
+
+extern struct file_system_type ovl_fs_type;
+
+static inline bool ovl_is_overlay_fs(struct super_block *sb)
+{
+	return sb->s_type == &ovl_fs_type;
+}
fs/overlayfs/super.c +58 -10

130 lines not on this page · raw message

Signature · 1 line
2.17.1