[PATCH 2/2] erofs-utils: lib: oci: restrict `ocierofs_io_open()` to single-layer images

zhaoyifan (H) zhaoyifan28 at huawei.com
Tue Dec 16 19:31:12 AEDT 2025


On 2025/12/16 15:23, Gao Xiang wrote:


>
>
> On 2025/12/16 16:05, Yifan Zhao wrote:
>> When mounting an OCI image with `mount.erofs -t erofs.nbd` without
>> specifying either `oci.layer=` or `oci.blob=`, a segfault occurs in the
>> `ocierofs_download_blob_range() → ocierofs_find_layer_by_digest()` call
>> path due to an empty `ctx->blob_digest`.
>>
>> As mounting multi-layer OCI images is not yet supported, let's exit
>> early in `ocierofs_io_open()` with an error in this case.
>>
>> Signed-off-by: Yifan Zhao <zhaoyifan28 at huawei.com>
>> ---
>>   lib/remotes/oci.c | 19 +++++++++++++------
>>   1 file changed, 13 insertions(+), 6 deletions(-)
>>
>> diff --git a/lib/remotes/oci.c b/lib/remotes/oci.c
>> index d5afd6a..ce7a1a5 100644
>> --- a/lib/remotes/oci.c
>> +++ b/lib/remotes/oci.c
>> @@ -1479,16 +1479,18 @@ int ocierofs_io_open(struct erofs_vfile 
>> *vfile, const struct ocierofs_config *cf
>>           return -ENOMEM;
>>         err = ocierofs_init(ctx, cfg);
>> -    if (err) {
>> -        free(ctx);
>> -        return err;
>> +    if (err)
>> +        goto out;
>> +
>> +    if (!ctx->blob_digest) {
>> +        err = -EINVAL;
>
> Is it possible to add a dedicated error message for this case?

Note: Apologies — this was originally sent directly to the maintainer by 
mistake and is now being resent to the list for visibility and review.


Hi Xiang,

Acknowledged. However, when netlink is unavailable, this logic runs in 
both `erofsmount_startnbd` and `erofsmount_startnbd_nl`,

causing duplicate error output. A refactor may be warranted later, but 
for now, let's just add the error print.


Thanks,

Yifan Zhao

>
> Thanks,
> Gao Xiang


More information about the Linux-erofs mailing list