checkpoint-restore / criu

Checkpoint/Restore tool
criu.org
Other
2.79k stars 565 forks source link

Why are st_mode restored only for memfd, socket, and reg-file, but not for pipe, evenetfd...? #2281

Open cuiyunhui-1 opened 9 months ago

cuiyunhui-1 commented 9 months ago

@emmir

cuiyunhui-1 commented 9 months ago

@osctobe

avagin commented 9 months ago

I am not sure that I understand the question. What is st_mode in this context? Where do we restore it for memfd, socket, reg-files?

cuiyunhui-1 commented 9 months ago

I am not sure that I understand the question. What is st_mode in this context? Where do we restore it for memfd, socket, reg-files?

static int memfd_open_inode_nocache(struct memfd_restore_inode *inode) { ...

fd = memfd_create(mie->name, flags);

if (restore_memfd_shmem_content(fd, mie->shmid, mie->size))
    goto out;

if (mie->has_mode)
    ret = cr_fchperm(fd, mie->uid, mie->gid, mie->mode);
else
    ret = cr_fchown(fd, mie->uid, mie->gid);

...

}

What I want to know is why CRIU doesn’t uniformly perform st_mode on all fd types. rebuild(restore), but only st_mode for sk-unix, memfd, reg-file recovery,?

cuiyunhui-1 commented 9 months ago

@avagin

avagin commented 9 months ago

What I want to know is why CRIU doesn’t uniformly perform st_mode on all fd types.

You are right, we may need to restore mode, uid, gid for mentioned. However, we have to decide whether we need to do that for each file type separately. For example, there is no need to do this for eventfd since, in the kernel, all eventfd instances are linked to the same anonymous inode.: https://elixir.bootlin.com/linux/latest/source/fs/eventfd.c#L418 https://elixir.bootlin.com/linux/latest/source/fs/anon_inodes.c#L147 https://elixir.bootlin.com/linux/latest/source/fs/anon_inodes.c#L97

Secondly, for certain file types, it is less critical since users typically do not reopen them through file systems.

cuiyunhui-1 commented 9 months ago

@avagin okay,thank you!

github-actions[bot] commented 8 months ago

A friendly reminder that this issue had no activity for 30 days.