From 65dc9ad6eeba69faee15c704fae426f31bfb9ada Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 15 Nov 2023 16:24:47 -0500 Subject: [PATCH] rgw: object lock uses 64-bit encoding for RetainUntilDate the default encoding of ceph::real_time truncates seconds to uint32_t, so stores the wrong timestamp for object lock enforcement Fixes: https://tracker.ceph.com/issues/63537 Signed-off-by: Casey Bodley (cherry picked from commit 1fd4309fbbebf0d3e67aa2800d5fb3c7de19dcc7) --- PendingReleaseNotes | 8 ++++++++ src/rgw/rgw_object_lock.h | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 03520c97b5e91..043ecb35ea112 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -47,6 +47,14 @@ affected and to clean them up accordingly. * mgr/snap-schedule: For clusters with multiple CephFS file systems, all the snap-schedule commands now expect the '--fs' argument. +* RGW: Fixed a S3 Object Lock bug with PutObjectRetention requests that specify + a RetainUntilDate after the year 2106. This date was truncated to 32 bits when + stored, so a much earlier date was used for object lock enforcement. This does + not effect PutBucketObjectLockConfiguration where a duration is given in Days. + The RetainUntilDate encoding is fixed for new PutObjectRetention requests, but + cannot repair the dates of existing object locks. Such objects can be identified + with a HeadObject request based on the x-amz-object-lock-retain-until-date + response header. >=18.0.0 diff --git a/src/rgw/rgw_object_lock.h b/src/rgw/rgw_object_lock.h index 27c73feaec92b..9392c7eadcbcf 100644 --- a/src/rgw/rgw_object_lock.h +++ b/src/rgw/rgw_object_lock.h @@ -170,16 +170,20 @@ public: } void encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); + ENCODE_START(2, 1, bl); encode(mode, bl); encode(retain_until_date, bl); + ceph::round_trip_encode(retain_until_date, bl); ENCODE_FINISH(bl); } void decode(bufferlist::const_iterator& bl) { - DECODE_START(1, bl); + DECODE_START(2, bl); decode(mode, bl); decode(retain_until_date, bl); + if (struct_v >= 2) { + ceph::round_trip_decode(retain_until_date, bl); + } DECODE_FINISH(bl); } -- 2.39.5