linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: Fix kernel panic while mounting overlayfs
@ 2015-01-06  4:52 hujianyang
  2015-01-08 13:51 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: hujianyang @ 2015-01-06  4:52 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-unionfs, linux-fsdevel@vger.kernel.org

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.

Signed-off-by: hujianyang <hujianyang@huawei.com>
---
 fs/overlayfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 84f3144..d50e3ed 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -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;
-- 
1.6.0.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ovl: Fix kernel panic while mounting overlayfs
  2015-01-06  4:52 [PATCH] ovl: Fix kernel panic while mounting overlayfs hujianyang
@ 2015-01-08 13:51 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2015-01-08 13:51 UTC (permalink / raw)
  To: hujianyang; +Cc: linux-unionfs, linux-fsdevel@vger.kernel.org

On Tue, Jan 6, 2015 at 5:52 AM, hujianyang <hujianyang@huawei.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-08 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-06  4:52 [PATCH] ovl: Fix kernel panic while mounting overlayfs hujianyang
2015-01-08 13:51 ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).