]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Resolve unhandled exception in 45892/head
authorNikhil Kshirsagar <nkshirsagar@gmail.com>
Tue, 22 Mar 2022 05:04:23 +0000 (10:34 +0530)
committerNikhil Kshirsagar <nkshirsagar@gmail.com>
Wed, 13 Apr 2022 09:40:17 +0000 (15:10 +0530)
__generate_command_map()

If improper json data is passed to rados, it can
end up crashing the mon. This fix will catch the
exception if thrown by __generate_command_map()
and avoid the mon getting terminated due to an
uncaught exception.

Fixes: https://tracker.ceph.com/issues/54558
Signed-off-by: Nikhil Kshirsagar <nkshirsagar@gmail.com>
(cherry picked from commit 1109e62f6a3c0a7e06a088c4b833c8ecec51f791)

src/mon/Monitor.cc

index d647316e9e5c119b1b83e4c2b1923d932f95e622..1e3eda6156883acc758e91af78860da83e7b20e4 100644 (file)
@@ -3424,7 +3424,15 @@ void Monitor::handle_command(MonOpRequestRef op)
 
   // validate user's permissions for requested command
   map<string,string> param_str_map;
-  _generate_command_map(cmdmap, param_str_map);
+
+  // Catch bad_cmd_get exception if _generate_command_map() throws it
+  try {
+    _generate_command_map(cmdmap, param_str_map);
+  }
+  catch(bad_cmd_get& e) {
+    reply_command(op, -EINVAL, e.what(), 0);
+  }
+
   if (!_allowed_command(session, service, prefix, cmdmap,
                         param_str_map, mon_cmd)) {
     dout(1) << __func__ << " access denied" << dendl;