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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250423102446.GF3659@twin.jikos.cz>
Date: Wed, 23 Apr 2025 12:24:46 +0200
From: David Sterba <dsterba@...e.cz>
To: Daniel Vacek <neelx@...e.com>
Cc: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
	David Sterba <dsterba@...e.com>, Nick Terrell <terrelln@...com>,
	linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: harden parsing of compress mount option

On Wed, Apr 23, 2025 at 09:33:28AM +0200, Daniel Vacek wrote:
> Btrfs happily but incorrectly accepts the `-o compress=zlib+foo` and similar
> options with any random suffix. Let's handle that correctly.
> 
> Signed-off-by: Daniel Vacek <neelx@...e.com>
> ---
>  fs/btrfs/super.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 40709e2a44fce..f7e064b8c6d88 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -354,7 +354,10 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  			btrfs_set_opt(ctx->mount_opt, COMPRESS);
>  			btrfs_clear_opt(ctx->mount_opt, NODATACOW);
>  			btrfs_clear_opt(ctx->mount_opt, NODATASUM);
> -		} else if (strncmp(param->string, "zlib", 4) == 0) {
> +		} else if (strncmp(param->string, "zlib", 4) == 0 &&
> +				(param->string[4] == ':' ||
> +				 param->string[4] == ',' ||

Can there be ',' in the string? The option parser splits the options at
exactly that so it won't be part of the string, so just ':' or 0.

> +				 param->string[4] == '\0')) {
>  			ctx->compress_type = BTRFS_COMPRESS_ZLIB;
>  			ctx->compress_level =
>  				btrfs_compress_str2level(BTRFS_COMPRESS_ZLIB,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ