sdcardfs: limit stacking depth

Limit filesystem stacking to prevent stack overflow.

Bug: 32761463
Change-Id: I8b1462b9c0d6c7f00cf110724ffb17e7f307c51e
Signed-off-by: Andrew Chant <achant@google.com>
This commit is contained in:
Andrew Chant 2017-02-08 15:33:48 -08:00 committed by LuK1337
parent f908339dae
commit 9c3fbd74fc
1 changed files with 7 additions and 0 deletions

View File

@ -281,6 +281,13 @@ static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
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;