Skip to content

Comments

fuse client, fscrypt, test: Implement and create tests for S_ENCRYPTED in inode i_flags#319

Closed
salieri11 wants to merge 80 commits intochrisphoffman:wip-fscryptfrom
salieri11:wip-igolikov-fscrypt-64129
Closed

fuse client, fscrypt, test: Implement and create tests for S_ENCRYPTED in inode i_flags#319
salieri11 wants to merge 80 commits intochrisphoffman:wip-fscryptfrom
salieri11:wip-igolikov-fscrypt-64129

Conversation

@salieri11
Copy link

This PR adds test for S_ENCRYPTED bit in the i_flags field of Inode.
The test implements 2 quering methods: using FS_IOC_GETFLAGS and STATX_ATTR_ENCRYPTED

Fixes: https://tracker.ceph.com/issues/64129

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

Also send encrypted name when linking file

Signed-off-by: Yehuda Sadeh <[email protected]>
This allows accessing the correct dentry

Signed-off-by: Yehuda Sadeh <[email protected]>
 - file gets its parent fscrypt auth with new nonce
 - handle response trace: decrypt dname

Signed-off-by: Yehuda Sadeh <[email protected]>
Send back info about holes in object. When decrypting object
we shouldn't try to decrypt these.

Signed-off-by: Yehuda Sadeh <[email protected]>
Signed-off-by: Yehuda Sadeh <[email protected]>
When we're passed inode structure that doesn't have fscrypt_file
defined, don't try to override the existing one.

Signed-off-by: Yehuda Sadeh <[email protected]>
align the max size to the end of the block

Signed-off-by: Yehuda Sadeh <[email protected]>
implements that "fscrypt encrypt" functionality

Signed-off-by: Yehuda Sadeh <[email protected]>
Signed-off-by: Yehuda Sadeh <[email protected]>
Signed-off-by: Yehuda Sadeh <[email protected]>
Use encrypted name when building path for mds requests

Signed-off-by: Yehuda Sadeh <[email protected]>
When opening the snapdir, use its parent fscrypt ctx

Signed-off-by: Yehuda Sadeh <[email protected]>
Encryption params are applied dynamically from the policy. Currently
only supporting the two default encryption types.

Signed-off-by: Yehuda Sadeh <[email protected]>
Signed-off-by: Yehuda Sadeh <[email protected]>
Signed-off-by: Yehuda Sadeh <[email protected]>
Signed-off-by: Yehuda Sadeh <[email protected]>
when opening encrypted files for write, also get the read cap

Signed-off-by: Yehuda Sadeh <[email protected]>
round physical size, and update fscrypt_file to reflect requested size

Signed-off-by: Yehuda Sadeh <[email protected]>
Copy link
Owner

@chrisphoffman chrisphoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble getting this to compile.

error: narrowing conversion of ‘2148034049’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
  138 | #define FS_IOC_GETFLAGS _IOR('f', 1, long)

What environment are you testing this on that compiles?

Here's some further info that seems to be related: https://lore.kernel.org/all/[email protected]/T/

@salieri11
Copy link
Author

I'm having trouble getting this to compile.

error: narrowing conversion of ‘2148034049’ from ‘long unsigned int’ to ‘int’ [-Wnarrowing]
  138 | #define FS_IOC_GETFLAGS _IOR('f', 1, long)

What environment are you testing this on that compiles?

Here's some further info that seems to be related: https://lore.kernel.org/all/[email protected]/T/

I am building both on Ubuntu 24 (arm version), and on vossi04 (i guess its debian), with no errors, using do_cmake.sh
What is your env and how do you build the code?

Signed-off-by: Igor Golikov <[email protected]>
@chrisphoffman
Copy link
Owner

I am building both on Ubuntu 24 (arm version), and on vossi04 (i guess its debian), with no errors, using do_cmake.sh What is your env and how do you build the code?

Fedora and do_cmake as well. I'll try to take a look more at this this week.

@salieri11
Copy link
Author

I am building both on Ubuntu 24 (arm version), and on vossi04 (i guess its debian), with no errors, using do_cmake.sh What is your env and how do you build the code?

Fedora and do_cmake as well. I'll try to take a look more at this this week.
I changed it to:
#define FS_IOC_GETFLAGS _IOR('f', 1, unsigned long)
This is legit fix to use unsigned

I am building both on Ubuntu 24 (arm version), and on vossi04 (i guess its debian), with no errors, using do_cmake.sh What is your env and how do you build the code?

Fedora and do_cmake as well. I'll try to take a look more at this this week.

I changed it to
#define FS_IOC_GETFLAGS _IOR('f', 1, int32_t)
usually its good enough for these cases, just to use fixed width integer types

if (in->is_encrypted()) {
stx->stx_attributes |= STATX_ATTR_ENCRYPTED;
} else {
stx->stx_attributes &= ~STATX_ATTR_ENCRYPTED;
Copy link
Owner

@chrisphoffman chrisphoffman Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent some time looking at client code to see the case for this. Did you see a case where clear will be needed?

edit: reworded for clarity

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well not for now, but in general, I prefer to have clear semantics in such case, without assuming that the flag is clear by default (and not having some garbage that may set the flag to ENCRYPTED)

if (en) {
i_flags |= S_ENCRYPTED;
} else {
i_flags &= (~S_ENCRYPTED);
Copy link
Owner

@chrisphoffman chrisphoffman Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is clear explicitly needed? The value will either be default (showing not encrypted) or S_ENCRYPTED. It also shouldn't change should it?

edit: reworded for clarity

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above:) For better semantics and defensive code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your reasoning on this. I'm concerned that if there's "garbage" in it, we should let it show instead of hiding the issue.

I'm looking at linux kernel ioctl.c and during
fileattr_fill_flags|fileattr_fill_xflags

it sets value and doesn't worry about clearing.

Copy link
Author

@salieri11 salieri11 Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense for me now.I think that best will be to assert(false) if is_fscrypt_enabled is false but the S_ENCRYPTED bit is set, before setting the flag.. It wil let us catch the problem, instead of cleaning it.
Same for the previous comment related to. the stx->stx_attributes.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that, let's proceed with that change.

Signed-off-by: Igor Golikov <[email protected]>
Signed-off-by: Igor Golikov <[email protected]>
@chrisphoffman chrisphoffman force-pushed the wip-fscrypt branch 3 times, most recently from 6b620e1 to 33dfe4e Compare December 18, 2024 17:22
@github-actions
Copy link

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@chrisphoffman
Copy link
Owner

Merged into branch manually due to rebase cleanup work.

See commit here
ceph@6d15f1d

@chrisphoffman
Copy link
Owner

This is a test link, pasting this
https://github.com/chrisphoffman/ceph/commit/d8f6c2cfe248d3af786215eb7e567645c5655b74

without code annotation d8f6c2c

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants