History

fs: limit filesystem stacking depth

Add a simple read-only counter to super_block that indicates how deep this is in the stack of filesystems. Previously ecryptfs was the only stackable filesystem and it explicitly disallowed multiple layers of itself. Overlayfs, however, can be stacked recursively and also may be stacked on top of ecryptfs or vice versa. To limit the kernel stack usage we must limit the depth of the filesystem stack. Initially the limit is set to 2.

Miklos Szeredi committed 12 years ago

Commit 69c433e1 parent 7c37fbd3 files · +27 −0Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/fs.h+11−0
@@ -261,6 +261,12 @@ struct iattr { · 260 unmodified lines
261261 */
262262 #include <linux/quota.h>
263263
264+/*
265+ * Maximum number of layers of fs stack. Needs to be limited to
266+ * prevent kernel stack overflow
267+ */
268+#define FILESYSTEM_MAX_STACK_DEPTH 2
269+
264270 /**
265271 * enum positive_aop_returns - aop return codes with specific semantics
266272 *
@@ -1273,6 +1279,11 @@ struct super_block { · 1006 unmodified lines
12731279 struct list_lru s_dentry_lru ____cacheline_aligned_in_smp;
12741280 struct list_lru s_inode_lru ____cacheline_aligned_in_smp;
12751281 struct rcu_head rcu;
1282+
1283+ /*
1284+ * Indicates how deep in a filesystem stack this SB is
1285+ */
1286+ int s_stack_depth;
12761287 };
12771288
12781289 extern struct timespec current_fs_time(struct super_block *sb);