From 733fff22bbcf2f6db95ab3991063521899a03290 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Sat, 2 Mar 2019 09:43:58 +0800 Subject: [PATCH] mon/OSDMonitor: add boundary check for pool recovery_priority See https://github.com/ceph/ceph/pull/26705 Fixes: http://tracker.ceph.com/issues/38578 Signed-off-by: xie xingguo --- qa/workunits/cephtool/test.sh | 2 ++ src/mon/OSDMonitor.cc | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index e20d61d34e9..bd01614a90f 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -2012,6 +2012,8 @@ function test_mon_osd_pool_set() ceph osd pool get $TEST_POOL_GETSET recovery_priority | grep 'recovery_priority: 5' ceph osd pool set $TEST_POOL_GETSET recovery_priority 0 ceph osd pool get $TEST_POOL_GETSET recovery_priority | expect_false grep '.' + expect_false ceph osd pool set $TEST_POOL_GETSET recovery_priority -1 + expect_false ceph osd pool set $TEST_POOL_GETSET recovery_priority 30 ceph osd pool get $TEST_POOL_GETSET recovery_op_priority | expect_false grep '.' ceph osd pool set $TEST_POOL_GETSET recovery_op_priority 5 diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 00d32272026..a24b8e8f83c 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7557,6 +7557,19 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap, << " > pg_num " << p.get_pg_num_target(); return -EINVAL; } + } else if (var == "recovery_priority") { + if (interr.length()) { + ss << "error parsing int value '" << val << "': " << interr; + return -EINVAL; + } + if (n < 0) { + ss << "pool recovery_priority can not be negative"; + return -EINVAL; + } else if (n >= 30) { + ss << "pool recovery_priority should be less than 30 due to " + << "Ceph internal implementation restrictions"; + return -EINVAL; + } } pool_opts_t::opt_desc_t desc = pool_opts_t::get_opt_desc(var);