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

fscrypt on CephFS does not recognize locked directories upon remount #399

Open
ossarchitect opened this issue Jan 4, 2024 · 7 comments
Open

Comments

@ossarchitect
Copy link

ossarchitect commented Jan 4, 2024

This issue is present in Ubuntu 23.10 with Kernel 6.6.7 from mainline. (6.6+ is required for fscrypt support on CephFS). fscrypt is installed via apt.
What I am doing:

  • sudo mount -t ceph [email protected]=/ /mnt
  • cd /mnt/fscrypt setup
  • mkdir cryptdir
  • fscrypt encrypt cryptdir
  • The result here is correct, I get "cryptdir is now encrypted, unlocked and ready to use."
    At this point I can fscrypt lock and unlock the directory
    When the directory is locked, the files inside are encrypted, with encrypted filenames. When it is unlocked. the files are decrypted.
  • sudo umount /mnt
  • sudo mount -t ceph [email protected]=/ /mnt
  • fscrypt unlock cryptdir
    Result: [ERROR] fscrypt unlock: file or directory cryptdir is not encrypted
    The files and directories inside the directory are encrypted, but fscrypt does not recognize that they are.
    I tried locking the directory before umount and leaving it unlocked before umount. Neither works.
    I tried to find a solution online, but came up empty.

Am I missing something or is this a bug? And if it is the latter, do I need to file this with the kernel team for the CephFS driver, too?

@ebiggers
Copy link
Collaborator

ebiggers commented Jan 4, 2024

This should work, and it does work on other filesystems. Please report this to the CephFS developers.

@ossarchitect
Copy link
Author

Will do, thanks!

@ossarchitect
Copy link
Author

I opened https://tracker.ceph.com/issues/63939 for this.

@ossarchitect
Copy link
Author

ossarchitect commented Jan 4, 2024

In connection with the testing I frequently get the following error:
$ fscrypt encrypt
[ERROR] fscrypt encrypt: : readdirent : No buffer space available

This is particularly evident when trying to manipulate the formerly encrypted directory (lock/unlock/encrypt) that is marked as not encrypted after the remount.

@ossarchitect
Copy link
Author

Interestingly the issue with 'is not encrypted' does not seem to be limited to umount and remount:

root@ubuntu:/mnt# mkdir test4
root@ubuntu:/mnt# fscrypt encrypt test4
Should we create a new protector? [y/N]
Enter custom passphrase for protector "thecrypta":
"test4" is now encrypted, unlocked, and ready for use.
root@ubuntu:/mnt# vi test4/testfile
root@ubuntu:/mnt# ls test4
testfile
root@ubuntu:/mnt# fscrypt lock test4
"test4" is now locked.
root@ubuntu:/mnt# ls test4
I1eTGrt5j2K08BlIdpUs++w4tFnJtes5JuY7n1,gja4
root@ubuntu:/mnt# fscrypt unlock test4
[ERROR] fscrypt unlock: file or directory "test4" is not encrypted
root@ubuntu:/mnt#

For some reason the metadata read does not seem to work right. the error 'is not encrypted' is in metadata/policy.go in the function GetPolicy.
It is triggered whem getPolicyIoctl gets the error unix.ENODATA
So I infer the policy is not written properly on CephFS

@ossarchitect
Copy link
Author

Update: the problem appears to be writing into the encrypted (unlocked) CephFS directory.
Locking and unlocking of an encrypted empty directory works
Locking of an encrypted directory with a file written in it does work (or at least does not produce an error)
Unlocking of an encrypted directory with a file written in it does not.
I get the error message "[ERROR] fscrypt unlock: file or directory "crypt" is not encrypted"

@ossarchitect
Copy link
Author

Upgrade of the Ceph cluster to 18.2.1 (Reef) did not change the behavior.

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

No branches or pull requests

2 participants