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
Conversation
} | ||
pool = osdmap->lookup_pg_pool_name(tmp); | ||
if (pool < 0) { | ||
return -CEPHFS_ENOENT; |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
3392eef
to
10292f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@wxypro could you please create a tracker for this? |
There was a problem hiding this 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.
Jenkins test make check |
10292f6
to
40bc3d6
Compare
@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>
40bc3d6
to
1a94f74
Compare
@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)) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
@wxypro were you able to look at the comments? |
@wxypro ping? |
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. |
@wxypro pinging again on this? |
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. |
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! |
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
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