From: chunmei-liu Date: Tue, 12 Apr 2022 08:49:08 +0000 (-0700) Subject: crimson/osd: check big object size X-Git-Tag: v18.0.0~1044^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=229c3f702a0f80f3cb63e34d5b7d725fc917b3ed;p=ceph.git crimson/osd: check big object size Signed-off-by: chunmei-liu --- diff --git a/src/crimson/osd/ops_executer.h b/src/crimson/osd/ops_executer.h index 9459cb4c62b0..b81cea31a60d 100644 --- a/src/crimson/osd/ops_executer.h +++ b/src/crimson/osd/ops_executer.h @@ -47,7 +47,8 @@ class OpsExecuter : public seastar::enable_lw_shared_from_this { crimson::ct_error::permission_denied, crimson::ct_error::operation_not_supported, crimson::ct_error::input_output_error, - crimson::ct_error::value_too_large>; + crimson::ct_error::value_too_large, + crimson::ct_error::file_too_large>; using read_errorator = PGBackend::read_errorator; using write_ertr = PGBackend::write_ertr; using get_attr_errorator = PGBackend::get_attr_errorator; diff --git a/src/crimson/osd/pg_backend.cc b/src/crimson/osd/pg_backend.cc index 4c507f7ae000..df6de8522b29 100644 --- a/src/crimson/osd/pg_backend.cc +++ b/src/crimson/osd/pg_backend.cc @@ -492,7 +492,7 @@ static bool is_offset_and_length_valid( } } -PGBackend::interruptible_future<> PGBackend::write( +PGBackend::write_iertr::future<> PGBackend::write( ObjectState& os, const OSDOp& osd_op, ceph::os::Transaction& txn, @@ -503,6 +503,14 @@ PGBackend::interruptible_future<> PGBackend::write( uint64_t offset = op.extent.offset; uint64_t length = op.extent.length; bufferlist buf = osd_op.indata; + if (op.extent.length != osd_op.indata.length()) { + return crimson::ct_error::invarg::make(); + } + + if (!is_offset_and_length_valid(op.extent.offset, op.extent.length)) { + return crimson::ct_error::file_too_large::make(); + } + if (auto seq = os.oi.truncate_seq; seq != 0 && op.extent.truncate_seq < seq) { // old write, arrived after trimtrunc @@ -587,7 +595,7 @@ PGBackend::interruptible_future<> PGBackend::write_same( return seastar::now(); } -PGBackend::interruptible_future<> PGBackend::writefull( +PGBackend::write_iertr::future<> PGBackend::writefull( ObjectState& os, const OSDOp& osd_op, ceph::os::Transaction& txn, @@ -596,7 +604,10 @@ PGBackend::interruptible_future<> PGBackend::writefull( { const ceph_osd_op& op = osd_op.op; if (op.extent.length != osd_op.indata.length()) { - throw crimson::osd::invalid_argument(); + return crimson::ct_error::invarg::make(); + } + if (!is_offset_and_length_valid(op.extent.offset, op.extent.length)) { + return crimson::ct_error::file_too_large::make(); } const bool existing = maybe_create_new_object(os, txn, delta_stats); diff --git a/src/crimson/osd/pg_backend.h b/src/crimson/osd/pg_backend.h index 005fe9602750..7112247d6580 100644 --- a/src/crimson/osd/pg_backend.h +++ b/src/crimson/osd/pg_backend.h @@ -118,7 +118,8 @@ public: // TODO: switch the entire write family to errorator. using write_ertr = crimson::errorator< - crimson::ct_error::file_too_large>; + crimson::ct_error::file_too_large, + crimson::ct_error::invarg>; using write_iertr = ::crimson::interruptible::interruptible_errorator< ::crimson::osd::IOInterruptCondition, @@ -141,7 +142,7 @@ public: interruptible_future<> remove( ObjectState& os, ceph::os::Transaction& txn); - interruptible_future<> write( + write_iertr::future<> write( ObjectState& os, const OSDOp& osd_op, ceph::os::Transaction& trans, @@ -153,7 +154,7 @@ public: ceph::os::Transaction& trans, osd_op_params_t& osd_op_params, object_stat_sum_t& delta_stats); - interruptible_future<> writefull( + write_iertr::future<> writefull( ObjectState& os, const OSDOp& osd_op, ceph::os::Transaction& trans,