]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: do not abort when user passed bad parameters to set metadata
authorDunrong Huang <riegamaths@gmail.com>
Mon, 28 Dec 2015 10:14:22 +0000 (18:14 +0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 25 Mar 2016 18:45:38 +0000 (19:45 +0100)
Fixes: #14190
when user passes bad parameter(e.g. pass "null" to bool parameter), the ceph_json.cc::decode_json_obj()
will raise a exception with type of JSONDecoder::err(). If we do not catch this exception, the radosgw
server will abort.

$ curl -X PUT http://ceph1:9090/admin/metadata?user&format=json -d 'data = { "mtime": "null"}'

terminate called after throwing an instance of 'JSONDecoder::err'
*** Caught signal (Aborted) **
 in thread 7ff982f55700
 ceph version 10.0.1-787-gc485d29 (c485d29a53f6a2c1a3b561c54632dbac1c4e9473)
 1: (ceph::BackTrace::BackTrace(int)+0x2d) [0x7ffa814db8c5]
 2: (()+0x8fbfb7) [0x7ffa814dafb7]
 3: (()+0xf100) [0x7ffa758a6100]
 4: (gsignal()+0x37) [0x7ffa748e05f7]
 5: (abort()+0x148) [0x7ffa748e1ce8]
 6: (__gnu_cxx::__verbose_terminate_handler()+0x165) [0x7ffa751e49b5]
 7: (()+0x5e926) [0x7ffa751e2926]
 8: (()+0x5e953) [0x7ffa751e2953]
 9: (()+0x5eb73) [0x7ffa751e2b73]
 10: (bool JSONDecoder::decode_json<long>(char const*, long&, JSONObj*, bool)+0x28c) [0x7ffa8135920a]
 11: (RGWMetadataManager::put(std::string&, ceph::buffer::list&, RGWMetadataHandler::sync_type_t, obj_version*)+0x173) [0x7ffa81468029]
 12: (RGWOp_Metadata_Put::execute()+0x172) [0x7ffa81308dcc]
 13: (()+0x7532d2) [0x7ffa813322d2]
 14: (RGWFCGXProcess::handle_request(RGWRequest*)+0x90) [0x7ffa813328a4]

Reported-by: Coffee Chou <coffee.zyr@gmail.com>
Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
(cherry picked from commit 83503239c81573232429a5fe98381f1a8f1357e9)

Conflicts:
src/rgw/rgw_user.cc
            hammer version uses RGWUserInfo instead of RGWUserCompleteInfo

src/rgw/rgw_bucket.cc
src/rgw/rgw_metadata.cc
src/rgw/rgw_user.cc

index 5d2af38ea6fb1995cb68647913797402f2c5fca9..4dc1dbad5c6b20a623cdd1c78005c77840752cfc 100644 (file)
@@ -1552,7 +1552,11 @@ public:
   int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
           time_t mtime, JSONObj *obj, sync_type_t sync_type) {
     RGWBucketEntryPoint be, old_be;
-    decode_json_obj(be, obj);
+    try {
+      decode_json_obj(be, obj);
+    } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+    }
 
     time_t orig_mtime;
     map<string, bufferlist> attrs;
@@ -1712,7 +1716,11 @@ public:
   int put(RGWRados *store, string& oid, RGWObjVersionTracker& objv_tracker,
           time_t mtime, JSONObj *obj, sync_type_t sync_type) {
     RGWBucketCompleteInfo bci, old_bci;
-    decode_json_obj(bci, obj);
+    try {
+      decode_json_obj(bci, obj);
+    } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+    }
 
     time_t orig_mtime;
     RGWObjectCtx obj_ctx(store);
index ece9ebf224e47ce1340f99bf1a1b42d4e1e64606..e42290a80a93e9dbdba5bfaa791cd647ff6717b2 100644 (file)
@@ -355,9 +355,13 @@ int RGWMetadataManager::put(string& metadata_key, bufferlist& bl,
 
   time_t mtime = 0;
 
-  JSONDecoder::decode_json("key", metadata_key, &parser);
-  JSONDecoder::decode_json("ver", *objv, &parser);
-  JSONDecoder::decode_json("mtime", mtime, &parser);
+  try {
+    JSONDecoder::decode_json("key", metadata_key, &parser);
+    JSONDecoder::decode_json("ver", *objv, &parser);
+    JSONDecoder::decode_json("mtime", mtime, &parser);
+  } catch (JSONDecoder::err& e) {
+    return -EINVAL;
+  }
 
   JSONObj *jo = parser.find_obj("data");
   if (!jo) {
index 1e122df063b74d5a619515d1a049db6545b575f8..125a7ab97fdd025ca1cfb3e46513f6ad5fe0c039 100644 (file)
@@ -2428,7 +2428,11 @@ public:
           time_t mtime, JSONObj *obj, sync_type_t sync_mode) {
     RGWUserInfo info;
 
-    decode_json_obj(info, obj);
+    try {
+      decode_json_obj(info, obj);
+    } catch (JSONDecoder::err& e) {
+      return -EINVAL;
+    }
 
     RGWUserInfo old_info;
     time_t orig_mtime;