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

rgw: swift: tempurl fixes for ceph #47723

Merged
merged 4 commits into from Jan 31, 2024

Conversation

mdw-at-linuxbox
Copy link
Contributor

rgw: swift: tempurl fixes for ceph

This is a set of 3 commits to update the swift tempurl (and formpost) logic to support sha256 and sha512 signatures. These fixes should make it possible for the tempest tests to pass.

This is intended to fix: https://tracker.ceph.com/issues/56564

@@ -41,6 +41,110 @@

using namespace std;

template <class H, bool O>
Copy link
Contributor

Choose a reason for hiding this comment

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

a comment clarifying what the H and O template parameters mean would be helpful--I mean obviously H is for HMAC. It took me a long time to find the H actually used at the bottom of the stack of templates. But it seems reasonable. I speculate below that it would be clearer if we were able to somehow remove the untemplated versions, that support multiple digest sizes in all their methods...

size_t pos = x.find(':');
if (pos == x.npos || pos <= 0) {
switch(x.length()) {
case CEPH_CRYPTO_HMACSHA1_DIGESTSIZE*2:
Copy link
Contributor

Choose a reason for hiding this comment

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

why hasn't the template split removed the need for the switch statement? i.e., you've templated out the HMAC and (um, O) parameters in descendant template types. Could the ancestor types become abstract, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The switch statement here is part of the logic that decides at run-time which of the 6 different forms of template logic it should realize. All the template logic happens strictly at compile-time, it can't replace the ultimate need to do grody old-fashioned run-time string parsing, which is what's happening here.
There are however 2 things I didn't do in this direction: firrstly, there are 2 copies of get_sig_helper, one for tempurl and one for formpost. It could be trivially one templated function, or less trivially, integrated into some other base class. There's no runtime advantage to this, and it makes include files a bit more messy.
The other thing is the template classes RGWFormPost::SignatureHelper_x and TempURLSignature::SignatureHelper_x, these both mainly contain thunks for calc() and is_equal_to(). Slightly more clever class logic might eliminate the need for those, but I kept ending up with worse kludges chasing that down.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the use of templates, sorry I seemed to be over reading here; I would rather we'd landed this in 22, rather than risking it getting stuck

@cbodley cbodley changed the title Wip master tempurl rgw: swift: tempurl fixes for ceph Aug 22, 2022
Comment on lines 214 to 215
}; /* TempURLEngine::SignatureHelper */
class TempURLEngine::SignatureHelper {
Copy link
Contributor

Choose a reason for hiding this comment

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

}; /* TempURLSignatureT */

@@ -82,7 +82,7 @@ void TempURLEngine::get_owner_info(const DoutPrefixProvider* dpp, const req_stat
const string& bucket_name = s->init_state.url_bucket;

/* TempURL requires that bucket and object names are specified. */
if (bucket_name.empty() || s->object->empty()) {
if (bucket_name.empty() || !s->object || s->object->empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

rgw::sal::Object::empty(s->object) seems to be the canonical way to check for both nullness and emptiness

Copy link
Contributor

Choose a reason for hiding this comment

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

that's a useful observation, but I find this logic clear--the big risk would be missing part of the logic that is being fixed

virtual bool is_equal_to(const std::string& rhs) {
return false;
};
static SignatureHelper* get_sig_helper(std::string_view x);
Copy link
Contributor

Choose a reason for hiding this comment

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

please use std::unique_ptr as the return type for factory functions. otherwise it's not immediately obvious whether the caller is responsible for cleanup, or whether to use delete vs. free()

unique_ptr also means that the caller doesn't need to sprinkle deletes in all of the destructors and error paths


TempURLEngine::SignatureHelper* TempURLEngine::SignatureHelper::get_sig_helper(std::string_view x) {
size_t pos = x.find(':');
if (pos == x.npos || pos <= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

pos is unsigned, but when pos == 0 that means x starts with a colon - is that ever a valid input?

maybe we should drop the || pos <= 0 part here, so that x.substr(0,pos) below gives us an empty string and guarantees we return BadSignatureHelper?

Copy link
Contributor

Choose a reason for hiding this comment

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

is there any actual bug here?

@github-actions
Copy link

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

opnfv-github pushed a commit to opnfv/functest that referenced this pull request Mar 6, 2023
Functest uses Ceph in gate which doesn't support
sha256 as default.

Please see:
 - https://review.opendev.org/c/openstack/tempest/+/832771
 - https://tracker.ceph.com/issues/56564
 - ceph/ceph#47723

Change-Id: I3e98301feca4b68b1f9ebb4a6b20feb505b2dd01
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
opnfv-github pushed a commit to opnfv/functest that referenced this pull request Mar 6, 2023
Functest uses Ceph in gate which doesn't support
sha256 as default.

Please see:
 - https://review.opendev.org/c/openstack/tempest/+/832771
 - https://tracker.ceph.com/issues/56564
 - ceph/ceph#47723

Change-Id: I3e98301feca4b68b1f9ebb4a6b20feb505b2dd01
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 507cdba)
opnfv-github pushed a commit to opnfv/functest that referenced this pull request Mar 6, 2023
Functest uses Ceph in gate which doesn't support
sha256 as default.

Please see:
 - https://review.opendev.org/c/openstack/tempest/+/832771
 - https://tracker.ceph.com/issues/56564
 - ceph/ceph#47723

Change-Id: I3e98301feca4b68b1f9ebb4a6b20feb505b2dd01
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit 507cdba)
@cbodley
Copy link
Contributor

cbodley commented Mar 31, 2023

bump

@cbodley
Copy link
Contributor

cbodley commented Apr 20, 2023

bump

1 similar comment
@cbodley
Copy link
Contributor

cbodley commented Jun 15, 2023

bump

@mattbenjamin
Copy link
Contributor

flagged for discussion in "marcus task backlog"

@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 Aug 14, 2023
@mattbenjamin
Copy link
Contributor

@mdw-at-linuxbox what is the status of this work?

@mdw-at-linuxbox
Copy link
Contributor Author

I just force-pushed an updated copy of this. Builds [in fc37], haven't done any other testing. Apparently isn't building in github. sigh...

@mdw-at-linuxbox
Copy link
Contributor Author

I pushed out an updated version that was also buildable in el9. Sadly, github was mean and threw away my comment saying that I had done so. Or at least, I thought it was buildable, not sure why "make check" failed again.

@cbodley
Copy link
Contributor

cbodley commented Sep 13, 2023

jenkins test make check

@cbodley
Copy link
Contributor

cbodley commented Sep 13, 2023

src/test/rgw/test_rgw_iam_policy.cc
In file included from src/test/rgw/test_rgw_iam_policy.cc:27:
In file included from src/rgw/rgw_auth_registry.h:14:
src/rgw/rgw_swift_auth.h:310:20: error: default initialization of an object of const type 'const uint32_t' (aka 'const unsigned int')
constexpr uint32_t signature_hash_size;
                   ^
                                       = 0
src/rgw/rgw_swift_auth.h:332:16: error: default initialization of an object of const type 'const uint32_t' (aka 'const unsigned int')
const uint32_t signature_hash_name_size;
               ^
                                        = 0
2 errors generated.

@cbodley
Copy link
Contributor

cbodley commented Sep 28, 2023

^ ping @mdw-at-linuxbox

@cbodley
Copy link
Contributor

cbodley commented Oct 12, 2023

bump

1 similar comment
@cbodley
Copy link
Contributor

cbodley commented Dec 8, 2023

bump

@mattbenjamin
Copy link
Contributor

@mdw-at-linuxbox you have been revisiting this, correct?

swift tempurl (and formpost) now suport sha256 and sha512.
hmacsha256 was there, adding hmacsha512 to round out the collection.

Fixes: https://tracker.ceph.com/issues/56564
Signed-off-by: Marcus Watts <mwatts@redhat.com>
In openstack swift, formpost and tempurl share the same signature
logic, so both now support sha1 / sha256 / sha512.  Here are changes
to ceph's formpost logic to match what swift does.  Most of the
guts of the signature logic are moved from .h to .cc because
this logic is only useful to the actual formpost code.

Fixes: https://tracker.ceph.com/issues/56564
Signed-off-by: Marcus Watts <mwatts@redhat.com>
@mdw-at-linuxbox
Copy link
Contributor Author

I've pushed a new version. I believe the problem Casey cited above was some unrelated problem in the base. The new version is simply the same commits rebased to the latest "main". It built for me on fc37 and el9, and also built without issue at ceph-ci https://shaman.ceph.com/builds/ceph/mdw-master-tempurl-6/ I have not done any other testing on this

@cbodley
Copy link
Contributor

cbodley commented Jan 17, 2024

thanks @mdw-at-linuxbox

It built for me on fc37 and el9, and also built without issue at ceph-ci https://shaman.ceph.com/builds/ceph/mdw-master-tempurl-6/ I have not done any other testing on this

still hitting those errors in 'make check'. unlike shaman, these builds use clang

The latest openstack swift logic supports sha256 and sha512 checksums
for tempurl and formpost, which can be either hexadecimal or
hashname:base64.  This adds logic to inspect the incoming signature
for type and to internally construct the same hash to compare.

Also:: fixes an incidental crash if a malformed swift path does not
contain an object name.

Fixes: https://tracker.ceph.com/issues/56564
Signed-off-by: Marcus Watts <mwatts@redhat.com>
@mdw-at-linuxbox
Copy link
Contributor Author

I've pushed a version that builds correctly with clang. Also built on ceph-ci here, https://shaman.ceph.com/builds/ceph/mdw-master-tempurl-7/

@cbodley
Copy link
Contributor

cbodley commented Jan 25, 2024

from qa/suites/rgw/tempest/tasks/tempest.yaml

        # TODO(tobias-urdin): Use sha256 when supported in RadosGW
        tempurl_digest_hashlib: sha1

we'll need to change this to get test coverage

Signed-off-by: Casey Bodley <cbodley@redhat.com>
@cbodley
Copy link
Contributor

cbodley commented Jan 26, 2024

jenkins test make check

@cbodley
Copy link
Contributor

cbodley commented Jan 26, 2024

jenkins test windows

@cbodley
Copy link
Contributor

cbodley commented Jan 26, 2024

@mdw-at-linuxbox
Copy link
Contributor Author

I'm having trouble figuring out why "make check" fails here. From the leg messgaes linked above, it appears it couldn't load a cls library, which sugests some kind of link problem.

I haven't been able to reproduce that problem, mostly because I don't know how to get "make check" to run just the piece I care about, and the whole thing, as best I can tell, takes hours to run. So far, I think I understand the unrelated environment problems that made my setup give up after 90 minutes, well before the failure reported above.

So am I looking at an "expected" problem, that I should ignore, or is this behavior I've introduced and need to solve?

@cbodley
Copy link
Contributor

cbodley commented Jan 31, 2024

jenkins test make check

@cbodley cbodley merged commit 8e554bf into ceph:main Jan 31, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants