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

powerman: correct potential segfault #201

Merged
merged 4 commits into from
Sep 10, 2024
Merged

Conversation

chu11
Copy link
Member

@chu11 chu11 commented Sep 9, 2024

Problem: In _process_setresult() if the plug name is not found in the inputted arglist, it can result in a segfault. This can occur when power operations on dependent targets (e.g. the parent of node needs to be powered on) have errors, leading to an unexpected host having a "power result".

Check that arg is non-NULL before trying to dereference it.

Fixes #197


side note, alternately those types of unexpected error messages could be removed from redfishpower. I elected to leave those error messages. I figure for telemetry output and debugging, it can still be useful to output "severe error messages" (i.e. http error) on parents

Problem: Some old comments suggest looking "above" for code definitions.
But that is out of date.

Remove the "above" text and update comment.
Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

LGTM! Nice catch

@chu11
Copy link
Member Author

chu11 commented Sep 10, 2024

argh ... i spoke too soon, this actually does remove the segfault but doesn't quite do what is expected. I realized I could reproduce this using the --test-failed-hosts option and powerman doesn't output what it should.

Problem: In _process_setresult() if the plug name is not found
in the inputted arglist, it can result in a segfault.  This
can occur when power operations on dependent targets (e.g. the
parent of node needs to be powered on) have errors, leading to
an unexpected host having a "power result".

Check that arg is non-NULL before trying to dereference it.

Fixes chaos#197
Problem: If an error occurs on a parent, the error should not
be output.  It should only be output on the descendants that
depend on the parent.

Check the output_result flag before outputting error messages.
Problem: There are no tests for the special case where a parent
results in a error and leads to a dependency error with
the setresult statement.

Add coverage via t0037-cray-ex.t.
@chu11
Copy link
Member Author

chu11 commented Sep 10, 2024

ok, added 1) a fix in redfishpower that outputs an error message only for the intended target, not the parent B) added a test. Confirmed the test resulted in the segfault on master, fixed in this branch.

@mergify mergify bot merged commit ba0abce into chaos:master Sep 10, 2024
8 checks passed
@chu11 chu11 deleted the issue197_segfault branch September 11, 2024 18:04
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.

powermand: segfault
2 participants