rgw: cumulatively fix 6 AWS SigV4 request failure cases#54856
rgw: cumulatively fix 6 AWS SigV4 request failure cases#54856
Conversation
cbodley
left a comment
There was a problem hiding this comment.
looking good, the parsing changes make sense
a3b1509 to
987a64c
Compare
f42fe45 to
fd143ea
Compare
|
@cbodley this should be ready for re-review |
fd143ea to
f838970
Compare
7433507 to
ad18207
Compare
|
jenkins test windows |
|
something broke the windows build mid-morning. it's complaining about an invalid boost submodule hash. this PR doesn't touch boost. |
ad18207 to
b35b925
Compare
| inline void put_prop(const std::string_view k, const std::string_view v) { | ||
| /* assume the caller will mangle the key name, if required */ | ||
| auto& map = const_cast<env_map_t&>(s->info.env->get_map()); |
There was a problem hiding this comment.
i tend to view const_cast as a code smell, since it's usually just a shortcut to avoid propagating const correctly. it's necessary here because a) we only get access to const req_state* in the constructor, and b) RGWEnv only exposes a const-qualified get_map()
since put_prop() is only called during AWSv4ComplMulti::complete() now, could we extend the Completer interface to take a non-const RGWEnv& env there so we can call env.set(k, v) instead?
that way we preserve the original intent for the Completer to have const-only access to the input req_state, while
the complete(RGWEnv& env) signature hopefully makes it clear that it may add trailing headers
There was a problem hiding this comment.
I think the current dance around hiding things from Completer is kind of daft, to be honest. I'd prefer not to make further backflips here. Notice that the code I submitted does not widen Completer at all, only AWSv4ComplMulti, which has a reason to modify the req_state.
There was a problem hiding this comment.
(at the same time, there's clearly no good justification for unwinding the the haskellish style of this entire subsystem--that said, what I'm trying to say is, yes, there's a clear inconsistency--but having a special call to modify the req_state is the code smell, imo.)
b35b925 to
2c0539c
Compare
|
I added logic to throw an exception if we would exceed trailer_buf_size-1 bytes of trailer, using ERR_LIMIT_EXCEEDED as the error code |
|
jenkins test windows |
2c0539c to
abc0f2c
Compare
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
apologies, i had forgotten about these conflicts when i merged #55250 |
These changes address checksum header identification and signing algorithm selection, including checksum trailer verification for signed- and unsigned-payload cases. These changes address all the actual S3 request failures I have so far been able to reproduce, with and without content checksums and/or new trailing checksum headers, and with and without SSL. Fixes: https://tracker.ceph.com/issues/63153 Specifically, it fixes the request failures that motivated the initial tracker filing. It extracts but does not validate new client content checksums if present. Validation and management of new S3 content-checksum headers will follow in a subsequent change. Signed-off-by: Matt Benjamin <mbenjamin@redhat.com> squashed commits: * wip chunk meta parsing--seem to have first AWSv4ComplMulti::ChunkMeta::create_next sort of parsing * use constexpr sarlen(...) for static array lengths throughout rgw_auth_s3.cc * link AWSv4CompleMulti::ChunkMeta to its enclosing completer * capture original content-length header before AWSv4ComplMulti overwrites it * mostly extract the trailer * fix misordered content-length, experiment w/exbuf * save leftover bytes between calls to AWSv4ComplMulti::recv_chunk() * propagate data_offset_in_stream from AWSv4ComplMulti::recv_chunk() * clean up trailer section extract * trailer section cleanup and introduce extract_helper * unrolled checksum extract--fixup * fix sv_trailer end pos, and cleanup * add proplist interface to rgw::auth::Completer and AWSv4ComplMulti * spliterate trailers * check completer props * redefine prop_map to point into already-allocated trailer_vec * hax: thread a counter onto AWSv4ComplMulti recv_body() and recv_chunk path * fix apparent bug where due to reads less than chunk_size induce a final, zero-length read that was skipped before forcing recognition of the last chunk in the stream * check only for a trailing checksum named in x-amz-trailer * don't try to match signatures when no signature provided (because streaming unsigned) * oops, fix content_length decl * fix recognition of next chunk envelope in unsigned aws-chunk case * clean up AWSv4CompMulti flags and correctly detect aws unsigned chunked * rework checksum-trailer extraction and introduce AWSv4ComplMulti::calc_v4_trailing_signature * thread const struct req_state* into AWSv4ComplMulti * large cleanup of trailer parsing, no regression * fix trailer signature calculation--checks * correctly generate final chunk hmac * typo in comment * verify trailing signature when expected (using expected final chunk signature) * move trailer_vec back onto recv_body()'s stack * remove strange completer comment * remove last_frag (now points into parsing_buf) * remove implied dependency on content_length * move trailer recognition to AWSv4ComplMulti::complete() * remove now-unused is_last_chunk() predicate * remove unused ChunkMeta::completer * responses to review comments * when trailer is sig expected, fail (only) if none present or if it does not match calculated * remove stale parse_content_length(...) decl * remove now-unused AWSv4ComplMulti::content_length * fix extract_helper end search position as in mut_extract_helper * change "\n" reserve term in get_canon_amz_hdrs() part of the sum (review) and initialize length to 0 * remove debugging code Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This can be run by hand with:
./mvnw clean package
./mvnw test -Dtest=PutObjects
The following properties are sourced from the environment:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
RGW_HTTP_ENDPOINT_URL
RGW_HTTPS_ENDPOINT_URL
Then adds:
qa/workunits/rgw: add test driver script for maven suite
Launch it fromn cls.yaml, as with test_librgw_file.h.
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
1. correctly match signature of 0-length chunk 2. initialize lf_bytes Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
The junit5 suite in fact chooses selects transport security (SSL) strictly from the endpoint URL. The test_awssdkv4_sig.sh (or its caller?) only needs to export RGW_HTTP_ENDPOINT_URL appropriately to get one or the other. Fix several mistakes in refactoring caught by Ali Maredia. Print AccessKey, SecretKey and EndpointURL on startup Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
f5b053c to
6f1fde8
Compare
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
Signed-off-by: Ali Maredia <amaredia@redhat.com>
Signed-off-by: Ali Maredia <amaredia@redhat.com>
6f1fde8 to
ccbb1f5
Compare
cbodley
left a comment
There was a problem hiding this comment.
looks great if it's passing tests
|
|
jenkins test make check |
|
|
jenkins test make check |
|
passed qa in https://pulpito.ceph.com/cbodley-2024-02-15_03:24:02-rgw-wip-accept-new-awssigv4-distro-default-smithi/ verified that java test are running in teuthology.log:
|
|
For cross-reference, this likely fixes an issue in some Go S3 client: minio/minio-go#1235. That one is about 0-byte chunk-signature for empty object. |
These changes address checksum header identification and signing
algorithm selection, including checksum trailer verification
for signed- and unsigned-payload cases.
These changes address all the actual S3 request failures I have
so far been able to reproduce, with and without content checksums
and/or new trailing checksum headers, and with and without
SSL.
Fixes: https://tracker.ceph.com/issues/63153
Specifically, it fixes the request failures that motivated the
initial tracker filing. It extracts but does not validate new client content
checksums if present. Validation and management of new
S3 content-checksum headers will follow in a subsequent change.
squashed commits:
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e