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: Guard against malformed bucket URLs #47025

Merged
merged 2 commits into from Jul 17, 2022
Merged

Conversation

adamemerson
Copy link
Contributor

@adamemerson adamemerson commented Jul 8, 2022

Misplaced colons can result in radosgw thinking is has a bucket URL
but with no bucket name, leading to a crash later on.

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

Contribution Guidelines

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

@cbodley
Copy link
Contributor

cbodley commented Jul 8, 2022

@adamemerson can you clarify where exactly the crash happens? is it really inside of rgw::ARN::ARN(rgw_bucket const&)?

@adamemerson
Copy link
Contributor Author

@adamemerson can you clarify where exactly the crash happens? is it really inside of rgw::ARN::ARN(rgw_bucket const&)?

No, in its parameter list.

With the invalid bucket URL, where there was a colon followed something terminating the bucket parse, s->bucket in ARN(s->bucket->get_key())) would end up being null.

@adamemerson
Copy link
Contributor Author

I'm guessing the crash got introduced in 99f7c4a when req_state::bucket went from being an rgw_bucket object to a unique_ptr .

Copy link
Contributor

@cbodley cbodley left a comment

Choose a reason for hiding this comment

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

thanks @adamemerson, that makes sense! i like your fix, but i'd also like to see an explicit null check. the top-level overload of verify_bucket_permission() looks like a good place:

 bool verify_bucket_permission(const DoutPrefixProvider* dpp, struct req_state * const s, const uint64_t op)
 {
+  if (rgw::sal::Bucket::empty(s->bucket)) {
+    return false; // request is missing a bucket name
+  }
   perm_state_from_req_state ps(s);
 
   return verify_bucket_permission(dpp,
                                   &ps,
                                   s->bucket->get_key(),

cc @dang

src/rgw/rgw_rest_s3.cc Outdated Show resolved Hide resolved
@ivancich ivancich added the wip-eric-testing-1 for ivancich testing label Jul 14, 2022
`unique_ptr` overload should take by reference.

Both should be const.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Misplaced colons can result in radosgw thinking is has a bucket URL
but with no bucket name, leading to a crash later on.

Fixes: https://tracker.ceph.com/issues/55765
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
@adamemerson
Copy link
Contributor Author

@cbodley Took out the top level check since s3tests wouldn't even initialize with it there.

@cbodley
Copy link
Contributor

cbodley commented Jul 15, 2022

cc @ivancich, there was a force-push after you labeled this for testing

@ivancich ivancich removed the wip-eric-testing-1 for ivancich testing label Jul 16, 2022
@adamemerson
Copy link
Contributor Author

@adamemerson adamemerson merged commit dcc92e0 into ceph:main Jul 17, 2022
@adamemerson adamemerson deleted the wip-55765 branch September 15, 2022 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants