[PATCH v2] erofs-utils: lib: correctly set {u,g}id in erofs_rebuild_make_root()

zhaoyifan (H) zhaoyifan28 at huawei.com
Wed Jan 14 18:58:57 AEDT 2026


On 2026/1/14 15:44, Gao Xiang wrote:

> we could support !im, I mean
>
>     struct erofs_importer_params *params = im ? im->params : NULL;

Hi Xiang,

Do we have any chance `im == NULL` in current codebase? Or is it to 
allow for future extensibility?

>
>>       struct erofs_inode *root;
>>   @@ -2384,6 +2385,8 @@ struct erofs_inode 
>> *erofs_rebuild_make_root(struct erofs_sb_info *sbi)
>>           return root;
>>       root->i_srcpath = strdup("/");
>>       root->i_mode = S_IFDIR | 0777;
>> +    root->i_uid = im->params->fixed_uid == -1 ? getuid() : 
>> im->params->fixed_uid;
>> +    root->i_gid = im->params->fixed_gid == -1 ? getgid() : 
>> im->params->fixed_gid;
>
>
>
>     root->i_uid = params && params->fixed_uid < 0 ? getuid() :
>             params->fixed_uid;

will sigfault if `params == NULL`, how about

     root->i_uid = (!params || params->fixed_uid < 0) ? getuid() :
                                params->fixed_uid;


Thanks,

Yifan

> ... 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20260114/1352ed27/attachment.htm>


More information about the Linux-erofs mailing list