33 lines
1.0 KiB
Diff
33 lines
1.0 KiB
Diff
From 57bc19ec472ab303209b2d96a59a619c5221594d Mon Sep 17 00:00:00 2001
|
|
From: Andrew Chant <achant@google.com>
|
|
Date: Wed, 8 Feb 2017 15:33:48 -0800
|
|
Subject: [PATCH] sdcardfs: limit stacking depth
|
|
|
|
Limit filesystem stacking to prevent stack overflow.
|
|
|
|
Bug: 32761463
|
|
Change-Id: I8b1462b9c0d6c7f00cf110724ffb17e7f307c51e
|
|
Signed-off-by: Andrew Chant <achant@google.com>
|
|
---
|
|
fs/sdcardfs/main.c | 7 +++++++
|
|
1 file changed, 7 insertions(+)
|
|
|
|
diff --git a/fs/sdcardfs/main.c b/fs/sdcardfs/main.c
|
|
index a6522286d7314..8b51a124298f4 100755
|
|
--- a/fs/sdcardfs/main.c
|
|
+++ b/fs/sdcardfs/main.c
|
|
@@ -223,6 +223,13 @@ static int sdcardfs_read_super(struct super_block *sb, const char *dev_name,
|
|
atomic_inc(&lower_sb->s_active);
|
|
sdcardfs_set_lower_super(sb, lower_sb);
|
|
|
|
+ sb->s_stack_depth = lower_sb->s_stack_depth + 1;
|
|
+ if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
|
|
+ pr_err("sdcardfs: maximum fs stacking depth exceeded\n");
|
|
+ err = -EINVAL;
|
|
+ goto out_sput;
|
|
+ }
|
|
+
|
|
/* inherit maxbytes from lower file system */
|
|
sb->s_maxbytes = lower_sb->s_maxbytes;
|
|
|