Skip to content

mds: cephx path restriction incorrectly rejects snapshots of deleted directory#58419

Merged
batrick merged 3 commits intoceph:mainfrom
batrick:i66828
Aug 27, 2024
Merged

mds: cephx path restriction incorrectly rejects snapshots of deleted directory#58419
batrick merged 3 commits intoceph:mainfrom
batrick:i66828

Conversation

@batrick
Copy link
Member

@batrick batrick commented Jul 4, 2024

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

batrick added 3 commits July 3, 2024 22:02
A snapped unlinked directory is moved to the stray directory. Files in that
directory will not have correct stray_prior_path set because the snapshot was
naturally taken before the file is unlinked.

Use the parent directory's stray_prior_path for cephx path access controls.

Fixes: https://tracker.ceph.com/issues/66828
Signed-off-by: Patrick Donnelly <[email protected]>
@github-actions github-actions bot added the tests label Jul 4, 2024
@batrick batrick requested a review from a team July 4, 2024 02:21
@batrick
Copy link
Member Author

batrick commented Jul 4, 2024

jenkins test make check arm64

Copy link
Contributor

@mchangir mchangir left a comment

Choose a reason for hiding this comment

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

LGTM

# should be
# 2024-07-04T02:11:26.990+0000 7f6b14e71640 20 Session check_access: [inode 0x10000000002 [2,2] ~mds0/stray2/10000000001/file ...] caller_uid=1141 caller_gid=1141 caller_gid_list=[1000,1141]
# 2024-07-04T02:11:26.990+0000 7f6b14e71640 20 Session check_access stray_prior_path /dir1/dir2
# 2024-07-04T02:11:26.990+0000 7f6b14e71640 10 MDSAuthCap is_capable inode(path /dir1/dir2 owner 1141:1141 mode 0100644) by caller 1141:1141 mask 1 new 0:0 cap: MDSAuthCaps[allow rws fsname=cephfs path="/dir1"]
Copy link
Member

Choose a reason for hiding this comment

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

What's up with these log-lines-as-comments?

Copy link
Member Author

Choose a reason for hiding this comment

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

just documenting what to look for in the logs.

*/
if (gpdiri->is_stray()) {
/* just check access on the parent dir */
path = pdiri->get_projected_inode()->stray_prior_path;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think I quite understand the claim

Files in that directory will not have correct stray_prior_path set because the snapshot was naturally taken before the file is unlinked.

We still have to unlink the file; why doesn't that set the stray_prior_path correctly?

Just as importantly, are we sure we're correct to grab permissions by iterating up directories like this? Can't we check_access on a directory inode and then go up to its parent and get permission denied, even if had access to the actual directory we were trying to operate on?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I quite understand the claim

Files in that directory will not have correct stray_prior_path set because the snapshot was naturally taken before the file is unlinked.

We still have to unlink the file; why doesn't that set the stray_prior_path correctly?

stray_prior_path is part of the inode_t which is projected and set when the inode is unlinked. A snapshot of that inode would not have visibility of that since it's in a future project of the inode. (And we can't use it even if we force looking at it since the inode may have been renamed elsewhere since the snapshot.)

Just as importantly, are we sure we're correct to grab permissions by iterating up directories like this?

Well, we need the stray_prior_path so that's what we have to do. But, it's not completely correct and maybe can't be with existing information, consider:

mkdir a
touch a/file
mkdir .snap/one
mv a b
rm -rf b # a's stray_prior_path is now "/b"
ls .snap/one/a/file # uses stray_prior_path "/b" but should be "/a"

Tracking the stray_prior_path correctly in this situation is difficult since we'd need to record the path changes during rename. I don't think it's worth the trouble when we're talking about access control on a read-only snapshot.

Can't we check_access on a directory inode and then go up to its parent and get permission denied, even if had access to the actual directory we were trying to operate on?

No. Because this change only affects access control to non-directories. An unlinked directory inode's parent is always a stray directory. That is handled on line 1055 above.

@batrick
Copy link
Member Author

batrick commented Aug 13, 2024

@batrick
Copy link
Member Author

batrick commented Aug 15, 2024

@rsacherer
Copy link

Hello,

is this ready to be merged or is there still work to be done?

Thank you
Raimund

@vshankar
Copy link
Contributor

Hello,

is this ready to be merged or is there still work to be done?

Thank you Raimund

It's under testing by Patrick. Once the fs suite run is reviewed for failures, the change will get merged.

@rsacherer
Copy link

Thank you!

@batrick batrick merged commit 64e2bd3 into ceph:main Aug 27, 2024
@batrick batrick deleted the i66828 branch August 27, 2024 17:11
@batrick
Copy link
Member Author

batrick commented Aug 27, 2024

pritha-srivastava pushed a commit to pritha-srivastava/ceph that referenced this pull request Aug 28, 2024
* refs/pull/58419/head:
	mds: generate correct path for unlinked snapped files
	qa: add test for cephx path check on unlinked snapped dir tree
	mds: add debugging for stray_prior_path

Reviewed-by: Milind Changire <[email protected]>
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.

5 participants