-
Notifications
You must be signed in to change notification settings - Fork 203
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
Problem reading the FS using rust code #1422
Comments
@democ98 Thanks for the issue report!
I'm a bit confused -- shouldn't you expect the non-existence of the deleted file?
In your case, it looks like you're trying to modify (allowed) files from the host. However, Gramine doesn't share FS state with the host (i.e., the files in mounted directories are only expected to be modified by Gramine processes) so the issue is kind of by-design. |
Thank you very much for your answer!could you please explain why it is designed like this? Or is there any documentation to explain why FS is not synchronous? thanks! @kailun-qin |
Replies to @kailun-qin:
@kailun-qin I wouldn't call your explanation correct. Technically, allowed files can be modified by other processes other than Gramine process. There should be nothing in Gramine that would prevent such scenarios. (But Kailun's note is correct for trusted files and encrypted/protected files -- these are not supposed to be modified by the host.) Replies to @democ98:
I don't know what syscall(s) are invoked in the Rust's The root cause is that Gramine caches file dentries and inodes (the former is like "where in the directory hierarchy the file with this filename is stored" and the latter is like "what are the properties of this file"). This caching plays its role in the gramine/libos/src/fs/libos_fs_util.c Lines 59 to 86 in 0684091
If you look closely at this function's implementation, you will see that at no point in time Gramine queries the host FS, to learn if there's anything new about the file's inode. Gramine memorized all the required details about the file properties, and hands them out to the application (your Rust program) from its cache. Now that I think of it, this indeed has an undesirable side effect of not knowing about the actual file status. In your Rust case, the file was deleted, but Gramine only noticed it when it tried to open the file (which of course requires to query the host FS). @kailun-qin @mkow Do we want to fix this behavior? It should be actually pretty simple: e.g. perform a dummy |
Ah yes, I understand. Perhaps I made some confusions, I was NOT talking about can or can't (for different types of FS mounts), but mostly Gramine's current design that doesn't expect such modifications w/o Gramine's notice.
It should try
Make sense to me. |
Description of the problem
Description of the problem:
I put the rust program into the docker container upgraded based on the official gramine docker container and run it with sgx. The program loops to detect whether a file under the file path
DEFAULT_FILE_SAVE_PATH
exists, andDEFAULT_FILE_SAVE_PATH
is mapped to the root directory of the host by docker on a certain pathA
, when an untrusted program on the host computer deletes a file in pathA
, my rust program running in gramine can still detect the existence of the file, but it cannot open the file ( Error No such file or directory (os error 2))Steps to reproduce
You can try to run this code, after adding a file such as "/sgx/12D3KooWQHuPnuXCqR3c5JhfsM2K6rQUKXwWdoeBuPNV3kQjj3mr.0" on the host host delete (by the way "/sgx/12D3KooWQHuPnuXCqR3c5JhfsM2K6rQUKXwWdoeBuPNV3kQ jj3mr.0" file is generated from within sgx), there will be an error,The following is the content of the manifest file.
Expected results
Actual results
Gramine commit hash
gramineproject/gramine digest:7e5b8b6111a6
The text was updated successfully, but these errors were encountered: