ovl: fix random return value on mount
authorAmir Goldstein <amir73il@gmail.com>
Tue, 11 Jul 2017 12:58:35 +0000 (15:58 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Thu, 13 Jul 2017 20:06:45 +0000 (22:06 +0200)
On failure to prepare_creds(), mount fails with a random
return value, as err was last set to an integer cast of
a valid lower mnt pointer or set to 0 if inodes index feature
is enabled.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 3fe6e52f0626 ("ovl: override creds with the ones from ...")
Cc: <stable@vger.kernel.org> # v4.7
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/super.c

index 44dc2d6ffe0f077c09767320ba149eeac42ab5a5..1cf5d3538309a8d6182f4eaf3c9d9a0932f6e26e 100644 (file)
@@ -1090,6 +1090,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
        else
                sb->s_d_op = &ovl_dentry_operations;
 
+       err = -ENOMEM;
        ufs->creator_cred = cred = prepare_creds();
        if (!cred)
                goto out_put_indexdir;