Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cuiyunhui-1 opened this issue Oct 9, 2023 · 8 comments

Comments

@cuiyunhui-1
Copy link

cuiyunhui-1 commented Oct 9, 2023

No description provided.

@cuiyunhui-1

This comment was marked as resolved.

@cuiyunhui-1

This comment was marked as resolved.

@avagin
Copy link
Member

avagin commented Oct 10, 2023

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
Copy link
Author

cuiyunhui-1 commented Oct 10, 2023

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

This comment was marked as resolved.

@avagin
Copy link
Member

avagin commented Oct 11, 2023

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
Copy link
Author

@avagin okay,thank you!

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants