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: reject encrypted object COPY before supported #20739

Merged
merged 1 commit into from Mar 13, 2018

Conversation

Jeegn-Chen
Copy link
Contributor

@Jeegn-Chen
Copy link
Contributor Author

@mattbenjamin Could you take a look?

}
RGWObjManifest manifest;
bufferlist::iterator miter = attr_iter2->second.begin();
decode(manifest, miter);
Copy link
Contributor

Choose a reason for hiding this comment

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

how about:

  RGWObjManifest manifest;
  try {
    bufferlist::iterator miter = attr_iter2->second.begin();
    decode(manifest, miter);
  } catch (buffer::error& err) {
    ldout(cct, 0) << "ERROR: couldn't decode manifest" << dendl;
    return false;
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

iirc, some buffer operators are among the only Ceph interfaces that throw c++ exceptions, so this is probably sensible

Copy link
Contributor

@mattbenjamin mattbenjamin left a comment

Choose a reason for hiding this comment

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

I'm not 100% familiar with the context, but conceptually, if we cannot address the underlying issue, failing clearly is preferable; others will probably have strong opinions about that :)

if (attr_iter2 == attrs.end() || attr_iter2->second.length() == 0) {
return false;
}
RGWObjManifest manifest;
Copy link
Contributor

Choose a reason for hiding this comment

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

so the decoded manifest is local to rgw_s3_is_multipart_encrypted? that's probably ok, but I wonder if having the manifest...manifest at a higher level is helpful, longer run?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 it looks like RGWRados::copy_obj() already has access to a decoded version of the manifest in astate->manifest?

@cbodley
Copy link
Contributor

cbodley commented Mar 7, 2018

if the source object is encrypted with sse-c, we should be requiring the x-amz-copy-source​-server-side​-encryption​-customer-* headers to decrypt it, and then re-encrypt it based on the x-amz-server-side​-encryption​-customer-* headers if provided (see 'Copy operation' at https://docs.aws.amazon.com/AmazonS3/latest/dev/ServerSideEncryptionCustomerKeys.html)

i think the safest thing to do for now is reject COPY operations with 400 Bad Request if the source object has any RGW_ATTR_CRYPT_MODE at all (whether it's multipart or not), until we actually implement this stuff - i opened an issue to track this in http://tracker.ceph.com/issues/23264

@Jeegn-Chen Jeegn-Chen force-pushed the wip-reject-sse-mpcp branch 2 times, most recently from e802e3b to c5a2645 Compare March 9, 2018 07:48
@Jeegn-Chen Jeegn-Chen changed the title rgw: return failure when unable to copy encrypted multipart objects rgw: fail encrypted objects' COPY before supported Mar 9, 2018
@Jeegn-Chen
Copy link
Contributor Author

Updated according to comments
@cbodley @mattbenjamin @fangyuxiangGL

@@ -8097,6 +8107,13 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
if (ret < 0) {
return ret;
}
if (rgw_s3_is_encrypted(src_attrs)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this could just be if (src_atts.count(RGW_ATTR_CRYPT_MODE)) and we wouldn't need the extra member function

// Current encryption implemenation rely on the part sequence in manifest
// but current copy operation will result in part sequence change
// To Do: need more comprehensive design to support this kind of copy operation
ldout(cct, 0) << "ERROR: failed to copy encrypted multipart object " << src_obj << dendl;
Copy link
Contributor

Choose a reason for hiding this comment

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

the log message and comment still refer to multipart objects, but this code path applies to non-multipart objects too

// but current copy operation will result in part sequence change
// To Do: need more comprehensive design to support this kind of copy operation
ldout(cct, 0) << "ERROR: failed to copy encrypted multipart object " << src_obj << dendl;
return -ERR_INVALID_REQUEST;
Copy link
Member

Choose a reason for hiding this comment

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

I'd vote for a 501, -ERR_NOT_IMPLEMENTED error code unless it really is a invalid request

@Jeegn-Chen Jeegn-Chen changed the title rgw: fail encrypted objects' COPY before supported rgw: reject encrypted object COPY before supported Mar 10, 2018
@Jeegn-Chen
Copy link
Contributor Author

Updated according to comments @cbodley @theanalyst

if (src_attrs.count(RGW_ATTR_CRYPT_MODE)) {
// Current implementation does not follow S3 spec and even
// may result in data corruption silently when copying
// multipart objects accorss pools. So reject COPY operations
Copy link
Contributor

Choose a reason for hiding this comment

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

trivail one, 'accorss'

Current implementation does not follow S3 spec and even
may result in data corruption silently when copying
multipart objects accorss pools. So reject COPY operations
on encrypted objects before it is fully functional.

Fixes: http://tracker.ceph.com/issues/23232
Signed-off-by: Jeegn Chen <jeegnchen@gmail.com>
@yuriw
Copy link
Contributor

yuriw commented Mar 12, 2018

@yuriw yuriw merged commit 82d828b into ceph:master Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants