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

mds,client: validate pool against pool ids as well as pool names #45329

Closed
wants to merge 1 commit into from

Conversation

wxypro
Copy link
Contributor

@wxypro wxypro commented Mar 10, 2022

Problem:
If the pool is a numeric string (eg. 23134), the current validation assumes
that it is a pool id and looks up the list of pool ids and fails validation
if the pool is not found amongst the list of pool ids.

Solution:
Since a string of digits can also be used as a pool name, the pool is validated
against list of pool names as well if it doesn't match any of the pool ids.

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

Signed-off-by: wangxinyu wangxinyu@inspur.com

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

@github-actions github-actions bot added the cephfs Ceph File System label Mar 10, 2022
}
pool = osdmap->lookup_pg_pool_name(tmp);
if (pool < 0) {
return -CEPHFS_ENOENT;
Copy link
Member

@lxbsz lxbsz Mar 10, 2022

Choose a reason for hiding this comment

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

Could you explain why the old code didn't work ? Did you hit any issue with that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If pool name is a positive integer and can be cast to unsigned. layout.pool is set to this pool name.
And then, use this name as id to ckeck the pool in osdmap.
If there is no pool with this id, it will return -ENOENT and no longer check as a pool name.

Copy link
Member

@lxbsz lxbsz Mar 10, 2022

Choose a reason for hiding this comment

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

If the layout.pool is set to pool name, then the pool = boost::lexical_cast<unsigned>(tmp); should throw an exception and will be catched in catch (boost::bad_lexical_cast const&), then in the catch code it was checking with the pool name.

Didn't that work for you ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If pool name is a positive integer,the name can be cast to unsigned. no exception will be thrown.

Copy link
Member

@lxbsz lxbsz Mar 10, 2022

Choose a reason for hiding this comment

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

Do you mean the pool name will be something like "23134", which only includes digit numbers, but this is not a pool id ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

Okay. Make sense. Please explain this in the commit comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm being paranoid, but what if there are 2 pools, one with the pool name as "12345" and another pool with id as 12345.

src/client/Client.cc Outdated Show resolved Hide resolved
@lxbsz lxbsz requested a review from a team March 10, 2022 08:06
Copy link
Member

@lxbsz lxbsz left a comment

Choose a reason for hiding this comment

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

LGTM.

@vshankar vshankar requested a review from a team March 17, 2022 06:43
@vshankar
Copy link
Contributor

@wxypro could you please create a tracker for this?

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.

I'd like to suggest the following change to the commit message:

client: validate pool against pool ids as well as pool names

Problem:
If the pool is a numeric string (eg. 23134), the current validation assumes
that it is a pool id and looks up the list of pool ids and fails validation
if the pool is not found amongst the list of pool ids.

Solution:
Since a string of digits can also be used as a pool name, the pool is validated
against list of pool names as well if it doesn't match any of the pool ids.

@gregsfortytwo
Copy link
Member

Jenkins test make check

@wxypro wxypro changed the title client: check as name too when client check data pool mds,client: validate pool against pool ids as well as pool names Mar 23, 2022
@vshankar
Copy link
Contributor

@wxypro ping?

Problem:
If the pool is a numeric string (eg. 23134), the current validation assumes
that it is a pool id and looks up the list of pool ids and fails validation
if the pool is not found amongst the list of pool ids.

Solution:
Since a string of digits can also be used as a pool name, the pool is validated
against list of pool names as well if it doesn't match any of the pool ids.

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

Signed-off-by: wangxinyu <wangxinyu@inspur.com>
@dparmar18
Copy link
Contributor

@wxypro Could you please go through the checklist and mark the boxes that are relevant?

try {
layout->pool_id = boost::lexical_cast<unsigned>(value);
pool = boost::lexical_cast<unsigned>(value);
if (!osdmap->have_pg_pool(pool)) {
Copy link
Member

Choose a reason for hiding this comment

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

s/osdmap->have_pg_pool(pool)/osdmap.have_pg_pool(pool)/

layout->pool_id = pool;
// ignore
}
if (pool == -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we directly move code under if block to line 5605 ? (as we are setting pool = -1 at line 5605 and checking again here)

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, we might not need the int64_t pool = -1; initialization on L5601

@djgalloway djgalloway changed the base branch from master to main May 25, 2022 20:02
@vshankar
Copy link
Contributor

vshankar commented Jun 1, 2022

@wxypro were you able to look at the comments?

@vshankar
Copy link
Contributor

@wxypro ping?

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions bot added the stale label Jan 27, 2023
@vshankar
Copy link
Contributor

vshankar commented Feb 2, 2023

@wxypro pinging again on this?

@github-actions github-actions bot removed the stale label Feb 2, 2023
@github-actions
Copy link

github-actions bot commented Apr 9, 2023

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions bot added the stale label Apr 9, 2023
@github-actions
Copy link

github-actions bot commented May 9, 2023

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions bot closed this May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cephfs Ceph File System stale
Projects
None yet
7 participants