lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20140328154301.c25c495a8fcfd510ba2bf019@linux-foundation.org>
Date:	Fri, 28 Mar 2014 15:43:01 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Fabian Frederick <fabf@...net.be>
Cc:	linux-kernel <linux-kernel@...r.kernel.org>,
	"fengguang.wu" <fengguang.wu@...el.com>,
	"Chen, Jet" <jet.chen@...el.com>
Subject: Re: [PATCH linux-next v2] ufs: sb mutex merge + mutex_destroy: fix

On Thu, 27 Mar 2014 23:38:31 +0100 Fabian Frederick <fabf@...net.be> wrote:

> mutex_destroy was also called when trying to mount volume in read/write
> without write support enabled.
> 
> --- a/fs/ufs/super.c
> +++ b/fs/ufs/super.c
> @@ -798,7 +798,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
>  	if (!(sb->s_flags & MS_RDONLY)) {
>  		printk("ufs was compiled with read-only support, "
>  		"can't be mounted as read-write\n");
> -		goto failed;
> +		goto failed_noreadwrite;
>  	}
>  #endif
>  	mutex_init(&sbi->mutex);
> @@ -1255,10 +1255,14 @@ magic_found:
>  	return 0;
>  
>  failed:
> +	mutex_destroy(&sbi->mutex);
> +
> +#ifndef CONFIG_UFS_FS_WRITE
> +failed_noreadwrite:
> +#endif
>  	if (ubh)
>  		ubh_brelse_uspi (uspi);
>  	kfree (uspi);
> -	mutex_destroy(&sbi->mutex);
>  	kfree(sbi);
>  	sb->s_fs_info = NULL;
>  	UFSD("EXIT (FAILED)\n");

Ugly.  Wht don't we perform the check before we've allocated anything
so we can simply return?

And it should return -EROFS, not -EINVAL.

--- a/fs/ufs/super.c~ufs-sb-mutex-merge-mutex_destroy-fix-v2-fix
+++ a/fs/ufs/super.c
@@ -785,6 +785,14 @@ static int ufs_fill_super(struct super_b
 	flags = 0;
 	
 	UFSD("ENTER\n");
+
+#ifndef CONFIG_UFS_FS_WRITE
+	if (!(sb->s_flags & MS_RDONLY)) {
+		printk("ufs was compiled with read-only support, "
+		       "can't be mounted as read-write\n");
+		return -EROFS;
+	}
+#endif
 		
 	sbi = kzalloc(sizeof(struct ufs_sb_info), GFP_KERNEL);
 	if (!sbi)
@@ -794,13 +802,6 @@ static int ufs_fill_super(struct super_b
 
 	UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY));
 	
-#ifndef CONFIG_UFS_FS_WRITE
-	if (!(sb->s_flags & MS_RDONLY)) {
-		printk("ufs was compiled with read-only support, "
-		"can't be mounted as read-write\n");
-		goto failed_noreadwrite;
-	}
-#endif
 	mutex_init(&sbi->mutex);
 	spin_lock_init(&sbi->work_lock);
 	INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs);
@@ -1256,10 +1257,6 @@ magic_found:
 
 failed:
 	mutex_destroy(&sbi->mutex);
-
-#ifndef CONFIG_UFS_FS_WRITE
-failed_noreadwrite:
-#endif
 	if (ubh)
 		ubh_brelse_uspi (uspi);
 	kfree (uspi);
_

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ