Skip to content

client: fix fscrypt error-path bugs - #69880

Merged
chrisphoffman merged 3 commits into
ceph:mainfrom
sunyuechi:client-fscrypt-fixes
Jul 24, 2026
Merged

chrisphoffman merged 3 commits into
ceph:mainfrom
sunyuechi:client-fscrypt-fixes

Conversation

@sunyuechi

@sunyuechi sunyuechi commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
  • mount(): the dummy-encryption path unlocked/relocked the mutex under
    client_lock directly instead of through the unique_lock, so on
    fscrypt_dummy_encryption() failure it returned without relocking and
    the lock guard's destructor double-unlocked.
  • _wrap_name(): two encryption error paths did return r (r < 0) from a
    bool function, which converts to true, so callers used the
    unencrypted name on failure.
  • fscrypt_dummy_encryption(): on add_fscrypt_key() failure it jumped to
    the err label and read the uninitialized keyid buffer to issue a key
    removal. Return the error directly; also stop overwriting the original
    error with remove_fscrypt_key()'s return on the policy-set failure path.

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

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)

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@github-actions github-actions Bot added the cephfs Ceph File System label Jul 1, 2026
@tchaikov

tchaikov commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

ok to test

@chrisphoffman chrisphoffman self-assigned this Jul 2, 2026
@chrisphoffman
chrisphoffman requested a review from a team July 2, 2026 19:16
Comment thread src/client/Client.cc Outdated
@@ -7398,7 +7400,8 @@ int Client::fscrypt_dummy_encryption() {
memcpy(key_spec.u.identifier, keyid, FSCRYPT_KEY_IDENTIFIER_SIZE);
arg.removal_status_flags = 0;
arg.key_spec = key_spec;
r = remove_fscrypt_key(&arg);
// Preserve the original failure; don't mask it with the removal result.
remove_fscrypt_key(&arg);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch on preserving the original failure. I think it's important to have a marker of sorts if remove_fscrypt_key fails. What about an error message here and another up where it attempts to set policy and error message on failure?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done. Added error messages at both case.

@sunyuechi
sunyuechi force-pushed the client-fscrypt-fixes branch from 777596e to 51bd065 Compare July 2, 2026 19:45
@tchaikov
tchaikov requested a review from chrisphoffman July 3, 2026 01:26

@chrisphoffman chrisphoffman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The added messages look good. Thanks for that!

One more thing, this will need to be backported to umbrella, can you create a tracker and update your commit message referencing it?

mount() holds client_lock through a unique_lock (cl), but the dummy
encryption path unlocked and relocked the underlying mutex directly,
bypassing cl. On fscrypt_dummy_encryption() failure it returns early
without relocking, so cl's destructor then unlocks an already-unlocked
mutex, which is undefined behavior. Only reachable when
client_fscrypt_dummy_encryption is enabled.

Unlock/relock through cl so its ownership state stays consistent.

Fixes: https://tracker.ceph.com/issues/78246
Signed-off-by: Sun Yuechi <[email protected]>
_wrap_name() returns bool, but two encryption error paths did "return r"
with r < 0, which converts to true. Callers then treated the failure as
success and used the unencrypted name. Return false instead.

Fixes: https://tracker.ceph.com/issues/78246
Signed-off-by: Sun Yuechi <[email protected]>
When add_fscrypt_key() failed it jumped to the err label, which then
read the uninitialized keyid buffer into a key specifier and issued a
key removal for it. add_fscrypt_key() only populates keyid on success,
so this read uninitialized stack memory. Return the error directly
instead, since no key was added and there is nothing to remove.

Also stop overwriting the original error with remove_fscrypt_key()'s
return value on the policy-set failure path, so the real failure is
reported to the caller.

Fixes: https://tracker.ceph.com/issues/78246
Signed-off-by: Sun Yuechi <[email protected]>
@sunyuechi
sunyuechi force-pushed the client-fscrypt-fixes branch from 51bd065 to d440950 Compare July 15, 2026 13:29
@sunyuechi

Copy link
Copy Markdown
Contributor Author

@chrisphoffman Sure, updated.

@chrisphoffman

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by choffman started 2026-07-15-15:47.

@chrisphoffman

Copy link
Copy Markdown
Contributor

jenkins test make check

@chrisphoffman
chrisphoffman merged commit f0633dc into ceph:main Jul 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cephfs Ceph File System

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants