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: <1b0ce59a-30a7-46e3-9c63-72c3f8d44b77@linux.alibaba.com>
Date: Tue, 25 Mar 2025 09:37:39 +0800
From: Gao Xiang <hsiangkao@...ux.alibaba.com>
To: Sheng Yong <shengyong2021@...il.com>
Cc: linux-kernel@...r.kernel.org, Sheng Yong <shengyong1@...omi.com>,
 Wang Shuai <wangshuai12@...omi.com>, Gao Xiang <xiang@...nel.org>,
 Chao Yu <chao@...nel.org>, Yue Hu <zbestahu@...il.com>,
 Jeffle Xu <jefflexu@...ux.alibaba.com>, Sandeep Dhavale
 <dhavale@...gle.com>, linux-erofs mailing list <linux-erofs@...ts.ozlabs.org>
Subject: Re: [RFC PATCH] erofs: add start offset for file-backed mount

Hi Yong!

On 2025/3/24 10:28, Sheng Yong wrote:
> From: Sheng Yong <shengyong1@...omi.com>
> 
> When attempting to use an archive file, such as APEX on android,
> as a file-backed mount source, it fails because EROFS image within
> the archive file does not start at offset 0. As a result, a loop
> device is still needed to attach the image file at an appropriate
> offset first.
> 
> To address this issue, this patch parses the `source' parameter in
> EROFS to accept a start offset for the file-backed mount. The format
> is `/path/to/archive_file:offs', where `offs' represents the start
> offset. EROFS will add this offset before performing read requests.
> 
> Signed-off-by: Sheng Yong <shengyong1@...omi.com>
> Signed-off-by: Wang Shuai <wangshuai12@...omi.com>

Sorry for late reply. Yeah, that is a great feature.

> ---

...

> @@ -411,6 +412,31 @@ static bool erofs_fc_set_dax_mode(struct fs_context *fc, unsigned int mode)
>   #endif
>   }
>   
> +static loff_t erofs_fc_parse_source(struct fs_context *fc,
> +				    struct fs_parameter *param)
> +{
> +	const char *devname = param->string;
> +	const char *fofs_start __maybe_unused;
> +	loff_t fofs = 0;
> +
> +	if (!devname || !*devname)
> +		return invalfc(fc, "Empty source");
> +
> +#ifdef CONFIG_EROFS_FS_BACKED_BY_FILE
> +	fofs_start = strchr(devname, ':');
> +	if (!fofs_start)
> +		goto out;
> +	if (kstrtoll(fofs_start + 1, 0, &fofs) < 0)
> +		return invalfc(fc, "Invalid filebacked offset %s", fofs_start);
> +	fc->source = kstrndup(devname, fofs_start - devname, GFP_KERNEL);
> +	return fofs;
> +out:
> +#endif
> +	fc->source = devname;
> +	param->string = NULL;
> +	return fofs;
> +}

Could we just add a new mount option for this, and apply this feature
for both file-backed mounts and bdev-based mounts?

Twist source option is not quite clean on my side.



> +
>   static int erofs_fc_parse_param(struct fs_context *fc,
>   				struct fs_parameter *param)
>   {
> @@ -507,6 +533,11 @@ static int erofs_fc_parse_param(struct fs_context *fc,
>   		errorfc(fc, "%s option not supported", erofs_fs_parameters[opt].name);
>   #endif
>   		break;
> +	case Opt_source:
> +		sbi->dif0.fofs = erofs_fc_parse_source(fc, param);
> +		if (sbi->dif0.fofs < 0)
> +			return -EINVAL;
> +		break;
>   	}
>   	return 0;
>   }
> @@ -697,6 +728,10 @@ static int erofs_fc_get_tree(struct fs_context *fc)
>   		file = filp_open(fc->source, O_RDONLY | O_LARGEFILE, 0);
>   		if (IS_ERR(file))
>   			return PTR_ERR(file);
> +		if (sbi->dif0.fofs + PAGE_SIZE >= i_size_read(file_inode(file))) {
> +			fput(file);
> +			return invalf(fc, "Start offset too large");
> +		}

I guess we need to verify the offset is block-aligned too.

Thanks,
Gao Xiang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ