Skip to contentSkip to conversation

ovl: Fix kernel panic while mounting overlayfs

PATCH Applied hujianyang 2 participants 2 messages Jan 6, 2015 – Jan 8, 2015

Subsystems (2)
lore
Share & tools
lore

hujianyang

author
#0 lore raw

PATCH 1/1 ovl: Fix kernel panic while mounting overlayfs

The function ovl_fill_super() in recently multi-layer support version will incorrectly return 0 at error handling path and then cause kernel panic.

This failure can be reproduced by mounting a overlayfs with upperdir and workdir in different mounts.

And also, If the memory allocation of *lower_mnt* fail, this function may return an zero either.

This patch fix this problem by setting *err* to proper error number before jumping to error handling path.

---
 fs/overlayfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/overlayfs/super.c +2 -0
index 84f3144..d50e3ed 100644
@@ -836,6 +836,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 		if (err)
 			goto out_put_upperpath;
 
+		err = -EINVAL;
 		if (upperpath.mnt != workpath.mnt) {
 			pr_err("overlayfs: workdir and upperdir must reside under the same mount\n");
 			goto out_put_workpath;
@@ -894,6 +895,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
 		}
 	}
 
+	err = -ENOMEM;
 	ufs->lower_mnt = kcalloc(numlower, sizeof(struct vfsmount *), GFP_KERNEL);
 	if (ufs->lower_mnt == NULL)
 		goto out_put_workdir;
Signature · 1 line
1.6.0.2
maintainer Applied
#1 lore raw
Quoted 3 lines · hujianyang

The function ovl_fill_super() in recently multi-layer support version will incorrectly return 0 at error handling path and then cause kernel panic.

Applied.

Thanks,
Miklos