Skip to contentSkip to conversation

New Defects reported by Coverity Scan for ceph

DISCUSSION [email protected] 3 participants 3 messages Dec 21, 2017

lore
Share & tools
lore
#0 lore raw

Hi,

Please find the latest report on new defect(s) introduced to ceph found with Coverity Scan.

3 new defect(s) introduced to ceph found with Coverity Scan.
11 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)

** CID 1426746: Null pointer dereferences (REVERSE_INULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1270 in MDBalancer::dump_loads(ceph::Formatter *)()

________________________________________________________________________________________________________
*** CID 1426746: Null pointer dereferences (REVERSE_INULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1270 in MDBalancer::dump_loads(ceph::Formatter *)() 1264
1265 f->open_array_section("dirfrags");
1266 while (!dfs.empty()) {
1267 CDir *dir = dfs.front();
1268 dfs.pop_front();
1269

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1426746: Null pointer dereferences (REVERSE_INULL)
Null-checking "f" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

1270 if (f) {

1271           f->open_object_section("dir");
1272           dir->dump_load(f, now, decayrate);
1273           f->close_section();

1274 }
1275

** CID 1426747: Null pointer dereferences (FORWARD_NULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1290 in MDBalancer::dump_loads(ceph::Formatter *)()

________________________________________________________________________________________________________
*** CID 1426747: Null pointer dereferences (FORWARD_NULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1290 in MDBalancer::dump_loads(ceph::Formatter *)()

1284     	if (subdir->pop_nested.meta_load() < .001)
1285     	  continue;
1286     	dfs.push_back(subdir);

1287 }
1288 }
1289 }

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1426747: Null pointer dereferences (FORWARD_NULL)
Passing null pointer "f" to "close_section", which dereferences it. (The dereference happens because this is a virtual function call.)

1290 f->close_section(); // dirfrags array
1291
1292 f->open_object_section("mds_load");
1293 {
1294
1295 auto dump_mds_load = [this, f, now](mds_load_t& load) {

** CID 1426748: Uninitialized members (UNINIT_CTOR) /home/brad/working/src/ceph/src/osd/ECBackend.h: 511 in ECBackend::Op::Op()()

________________________________________________________________________________________________________
*** CID 1426748: Uninitialized members (UNINIT_CTOR) /home/brad/working/src/ceph/src/osd/ECBackend.h: 511 in ECBackend::Op::Op()() 505

506         /// Callbacks
507         Context *on_local_applied_sync = nullptr;
508         Context *on_all_applied = nullptr;
509         Context *on_all_commit = nullptr;

510

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1426748: Uninitialized members (UNINIT_CTOR)
Non-static class member "tid" is not initialized in this constructor nor in any functions that it calls.

511 Op() {}
512 Op(ceph_tid_t t, std::function<void(void)>&& cb)
513 : tid(t), on_write(cb) { }
514 ~Op() {
515 delete on_local_applied_sync;
516 delete on_all_applied;

________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A-2BWcWUl-2F-2BfV0V05UPxvVjWch-2Bd2MGckcRaGCnxtQO9E3gxlB2GxVsWFENryh7bC5hIb-2FQBVM85YLQ-3D-3D_2sw0G7ICm9mxCh1lYW1t9y1lfDrIerWzLwB67LZ-2Bn8EZdAaNMzjj2ZRPbkDolmkD-2Bsw3Hr011ofOuYtMXk6reD-2BdSKexT7q2Lt0OAh2jGrzg5SQMuoaqwHui6R1Zr4V9s2n1khNXR-2FUeSt-2FeK-2B8v7UHTFIirasRrOH0JyfLd8WCYYi5sLFX2EAqp5kTELhe3kZHHMhtNJs7ZBbbIoEKfYvFJxz-2FLyjjWgmpPsj9xT30-3D

To manage Coverity Scan email notifications for "[email protected]", click https://u2389337.ct.sendgrid.net/wf/click?upn=08onrYu34A-2BWcWUl-2F-2BfV0V05UPxvVjWch-2Bd2MGckcRbVDbis712qZDP-2FA8y06Nq4Bco8jcmzhh7FSyvoR0E3-2BDgRcBCQ6OuthHBtaTCGNq9OVG2ZVnjrgThgf5hX3GVEkIxvBX-2BorwRZfOftSp7HPfCifRGGak1MlgNFVd3IIPA-3D_2sw0G7ICm9mxCh1lYW1t9y1lfDrIerWzLwB67LZ-2Bn8EZdAaNMzjj2ZRPbkDolmkD-2Bsw3Hr011ofOuYtMXk6rePtmPVLUO0YE0KkkhvPsamW9f4ux9mKJ6oIQSTiuTnvSysxvaxtXyro961jYTmEV3Oe8sHZyvIhTe43-2FO7AgOe6JpQ6-2BED8iIth7JGE7yjz1-2ByVpjkES0rcqDlDhDaRFpbhpoNxZUgFSCw7hA7ntjrM-3D

#1 lore raw
Quoted 28 lines · On Thursday 21 December 2017 07:24 AM, [email protected] wrote:

Hi,

Please find the latest report on new defect(s) introduced to ceph found with Coverity Scan.

3 new defect(s) introduced to ceph found with Coverity Scan.
11 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)

** CID 1426746: Null pointer dereferences (REVERSE_INULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1270 in MDBalancer::dump_loads(ceph::Formatter *)()

________________________________________________________________________________________________________
*** CID 1426746: Null pointer dereferences (REVERSE_INULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1270 in MDBalancer::dump_loads(ceph::Formatter *)() 1264
1265 f->open_array_section("dirfrags");
1266 while (!dfs.empty()) {
1267 CDir *dir = dfs.front();
1268 dfs.pop_front();
1269

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1426746: Null pointer dereferences (REVERSE_INULL)
Null-checking "f" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

1270 if (f) {

Quoted 8 lines
1271           f->open_object_section("dir");
1272           dir->dump_load(f, now, decayrate);
1273           f->close_section();

1274 }
1275

** CID 1426747: Null pointer dereferences (FORWARD_NULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1290 in MDBalancer::dump_loads(ceph::Formatter *)()

There is a possibility that f might be NULL. But it is not NULL.

Please see:
https://github.com/ceph/ceph/blob/f33ab7e03a13e18c8c883284033d511f1b43df12/src/mds/MDSDaemon.cc#L135

Quoted 22 lines

________________________________________________________________________________________________________
*** CID 1426747: Null pointer dereferences (FORWARD_NULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1290 in MDBalancer::dump_loads(ceph::Formatter *)()

1284     	if (subdir->pop_nested.meta_load() < .001)
1285     	  continue;
1286     	dfs.push_back(subdir);

1287 }
1288 }
1289 }

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1426747: Null pointer dereferences (FORWARD_NULL)
Passing null pointer "f" to "close_section", which dereferences it. (The dereference happens because this is a virtual function call.)

1290 f->close_section(); // dirfrags array
1291
1292 f->open_object_section("mds_load");
1293 {
1294
1295 auto dump_mds_load = [this, f, now](mds_load_t& load) {

** CID 1426748: Uninitialized members (UNINIT_CTOR) /home/brad/working/src/ceph/src/osd/ECBackend.h: 511 in ECBackend::Op::Op()()

#2 lore raw
Quoted 35 lines · Jos Collin
Quoted 32 lines · On Thursday 21 December 2017 07:24 AM, [email protected] wrote:

Hi,

Please find the latest report on new defect(s) introduced to ceph found with Coverity Scan.

3 new defect(s) introduced to ceph found with Coverity Scan. 11 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 3 of 3 defect(s)

** CID 1426746: Null pointer dereferences (REVERSE_INULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1270 in MDBalancer::dump_loads(ceph::Formatter *)()

________________________________________________________________________________________________________
*** CID 1426746: Null pointer dereferences (REVERSE_INULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1270 in MDBalancer::dump_loads(ceph::Formatter *)()
1264
1265 f->open_array_section("dirfrags");
1266 while (!dfs.empty()) {
1267 CDir *dir = dfs.front();
1268 dfs.pop_front();
1269

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

CID 1426746: Null pointer dereferences (REVERSE_INULL) Null-checking "f" suggests that it may be null, but it has already
been dereferenced on all paths leading to the check.

1270 if (f) {

This check for f being null is redundant since if it were null we would have segfaulted on line 1263 or 1265.

I'd suggest it can be removed. We could put an assert put at the start of the function if necessary/desirable to check the Formatter argument being passed in but I haven't looked into it that deeply and I'm not sure that's necessary. I'd also suggest taking a look at similar functions that take a "Formatter" argument and see how they handle the possibility of the Formatter being null.

Quoted 49 lines
Quoted 9 lines
1271           f->open_object_section("dir");
1272           dir->dump_load(f, now, decayrate);
1273           f->close_section();

1274 }
1275

** CID 1426747: Null pointer dereferences (FORWARD_NULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1290 in MDBalancer::dump_loads(ceph::Formatter *)()

There is a possibility that f might be NULL. But it is not NULL.

Please see:
https://github.com/ceph/ceph/blob/f33ab7e03a13e18c8c883284033d511f1b43df12/src/mds/MDSDaemon.cc#L135

Quoted 25 lines

________________________________________________________________________________________________________
*** CID 1426747: Null pointer dereferences (FORWARD_NULL) /home/brad/working/src/ceph/src/mds/MDBalancer.cc: 1290 in MDBalancer::dump_loads(ceph::Formatter *)()
1284 if (subdir->pop_nested.meta_load() < .001)
1285 continue;
1286 dfs.push_back(subdir);
1287 }
1288 }
1289 }

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

CID 1426747: Null pointer dereferences (FORWARD_NULL) Passing null pointer "f" to "close_section", which dereferences
it. (The dereference happens because this is a virtual function call.)

1290 f->close_section(); // dirfrags array
1291
1292 f->open_object_section("mds_load");
1293 {
1294
1295 auto dump_mds_load = [this, f, now](mds_load_t& load) {

Quoted 3 lines

** CID 1426748: Uninitialized members (UNINIT_CTOR) /home/brad/working/src/ceph/src/osd/ECBackend.h: 511 in ECBackend::Op::Op()()

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Cheers,
Brad