From 1109e62f6a3c0a7e06a088c4b833c8ecec51f791 Mon Sep 17 00:00:00 2001 From: Nikhil Kshirsagar Date: Tue, 22 Mar 2022 10:34:23 +0530 Subject: [PATCH] mon: Resolve unhandled exception in __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 --- src/mon/Monitor.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index d1e54d36c7bfa..ca4ccb9fecf3f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3424,7 +3424,15 @@ void Monitor::handle_command(MonOpRequestRef op) // validate user's permissions for requested command map 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; -- 2.39.5