Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

[LibOS] Filesystem code needs to be rewritten #1803

Open
mkow opened this issue Sep 9, 2020 · 4 comments
Open

[LibOS] Filesystem code needs to be rewritten #1803

mkow opened this issue Sep 9, 2020 · 4 comments
Assignees

Comments

@mkow
Copy link
Member

mkow commented Sep 9, 2020

Description of the problem

Our old filesystem implementation requires complete rewrite.

  • The code is ugly and unmaintainable, especially everything around dentry structures.
  • There are tons of bugs there, each time we touch this subsystem in one place something unrelated in another place breaks.
  • Refcounting is totally broken, most likely we still have memory leaks and use-after-free bugs around there.
  • Symlinks doesn't work correctly (@boryspoplawski should remember more details, see e.g. [LibOS] Targets of links are always assumed to be under chroot #1387)
  • Mountpoints have inconsistent and not too reasonable semantics. See e.g. undefined root directory and mount semantics #1605.
  • We may need to add inode abstraction to emulate some of the Linux features correctly.

It's hard to implement any new feature for the filesystem without dealing with this issue first.

Related issues

@dimakuv
Copy link
Contributor

dimakuv commented Sep 9, 2020

I'd like to note that there is no shared and consistent view of the FS across Graphene processes. For example, a parent Graphene process and a child Graphene process will not see new/deleted files from the other process until they actually go and ask the host FS (recall that Graphene e.g. caches directory contents, so if parent listed the directory, then the child created a file in this directory, and parent lists the directory again, the parent won't see the new file).

However, implementing such a distributed view of the file system sounds quite complicated. I think we can get away with this by just purging all cached FS metadata in Graphene on each fork/exec.

@dimakuv
Copy link
Contributor

dimakuv commented Sep 9, 2020

One common source of confusion is our chroot semantics of Graphene: people have a hard time wrapping their heads around the concept of chroot jails and just want everything from the host FS to be visible/accessible inside Graphene.

I believe we should implement a "God-like" option in Graphene to bind a single mount point to host's / (something that GSC does already). This way everything is mirrored 1:1. We'll need a couple of exceptions to this rule:

  1. graphene/Runtime/ should take precedence to all other lib search directories.
  2. Stuff like /etc should probably also be possible to redirect.

Basically, we need a way to specify the root dir /, and then "augment" with Graphene-specific directories which take precedence.

@mkow
Copy link
Member Author

mkow commented Sep 9, 2020

I believe we should implement a "God-like" option in Graphene to bind a single mount point to host's /

No, I don't think we should allow this, sounds like a big footgun :) We should allow mounting all paths inside Graphene (including /), but IMO we shouldn't have an option to mount host's / to Graphene.

Ad mounting you described: IMO we should have Linux-like semantics of mounts, that you can stack them and we'll just execute the mount commands from the manifest one by one. This should allow for all possible configurations we may ever need.

@dimakuv
Copy link
Contributor

dimakuv commented Sep 23, 2021

@pwmarcz It would be good to go through the "master list of issues" again and verify which ones were already fixed/became irrelevant. After this we can close this issue.

I don't want to transfer this issue to the new Gramine repo since it's a meta-issue which is almost completely fixed at this point.

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

No branches or pull requests

3 participants