Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stack-buffer-overflow in EndcapPiZeroDiscriminatorAlgo #21214

Conversation

perrotta
Copy link
Contributor

@perrotta perrotta commented Nov 8, 2017

Fix stack-buffer-overflow, read of 4 bytes, EndcapPiZeroDiscriminatorAlgo::findPreshVector

This fixes the issue reported in #21173

I didn't want to modify the logic of the class/method, although I'm sure quite a lot can be done to improve it.

@davidlt

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 8, 2017

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 8, 2017

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/PR-21214/1869

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 8, 2017

A new Pull Request was created by @perrotta for master.

It involves the following packages:

RecoEcal/EgammaClusterAlgos

@perrotta, @cmsbuild, @slava77 can you please review it and eventually sign? Thanks.
@jainshilpi, @Sam-Harper, @argiro, @varuns23, @lgray this is something you requested to watch as well.
@davidlange6, @slava77 you are the release manager for this.

cms-bot commands are listed here

@perrotta
Copy link
Contributor Author

perrotta commented Nov 8, 2017

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 8, 2017

The tests are being triggered in jenkins.
https://cmssdt.cern.ch/jenkins/job/ib-any-integration/24268/console Started: 2017/11/08 13:05

vector<ESDetId>::iterator itID;
for (itID = road_2d.begin(); itID != road_2d.end(); itID++) {
LogTrace("EcalClusters") << "EndcapPiZeroDiscriminatorAlgo: findPreshVectors: ID = " << *itID ;

float E = 0.;
RecHitsMap::iterator strip_it = rechits_map->find(*itID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this my suggestion would also work:

-    if(goodPi0Strip(strip_it,last_stripID)) { // continue if strip not found in rechit_map
+    if ((strip_it != rechits_map->end()) && goodPi0Strip(strip_it,last_stripID)) { // continue if strip not found in rechit_map

If rechits_map->find(*itID); returns rechits_map->end() then call to goodPi0Strip would return false. Then you can actually delete some not needed lines. E.g., then you don't need last_stripID. That would overcomplexity here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that also works (and I have nothing against implementing it instead)

The difference is that if rechits_map->find(*itID); returns rechits_map->end(), then with it goodPi0Strip(...) wouldn't even be evaluated, thus not providing the LogTraces which are now in the code.

About the possibility of deleting not needed lines, this goes with my comment in the description of this PR: "I didn't want to modify the logic of the class/method, although I'm sure quite a lot can be done to improve it".

I think this fix addresses the issue reported by you in #21173 with the minimal modification to the code currently in CMSSW. To remove the comparison between the last element of vector road_2d and the first entry of the last element of the RecHitsMap *rechits_map (which I am also convinced as you that it is completely useless, and could be replaced by the very same check that you propose) I think one should first ask the authors of this code why they opted for such a convoluted logic instead, and make sure that there was no hidden particular case to be dealt with with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are responsible for reconstruction thus it's your call :) As long as it resolves the bug I am happy. Cleaning up the code would be nice-to-have.

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 8, 2017

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 8, 2017

Comparison job queued.

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 8, 2017

Comparison is ready
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-21214/24268/summary.html

Comparison Summary:

  • No significant changes to the logs found
  • Reco comparison results: 0 differences found in the comparisons
  • DQMHistoTests: Total files compared: 26
  • DQMHistoTests: Total histograms compared: 2903670
  • DQMHistoTests: Total failures: 1
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 2903498
  • DQMHistoTests: Total skipped: 171
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram bins added: 0.0 ( 22 files compared)
  • Checked 107 log files, 8 edm output root files, 26 DQM output files

@perrotta
Copy link
Contributor Author

perrotta commented Nov 9, 2017

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 9, 2017

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @davidlange6, @slava77, @smuzaffar (and backports should be raised in the release meeting by the corresponding L2)

@davidlt
Copy link
Contributor

davidlt commented Nov 9, 2017

@davidlange6 could you review this and merge/reject?

@davidlange6
Copy link
Contributor

merge

@cmsbuild cmsbuild merged commit 3eecb4f into cms-sw:master Nov 9, 2017
@perrotta perrotta deleted the fixStackBufferOverflowInEndcapPiZeroDiscriminatorAlgo branch November 10, 2017 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants