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 segfault in disk space check #28

Merged
merged 3 commits into from
Mar 7, 2023
Merged

Fix segfault in disk space check #28

merged 3 commits into from
Mar 7, 2023

Conversation

micahlee
Copy link
Contributor

@micahlee micahlee commented Mar 2, 2023

Desired Outcome

The desired outcome of this PR is to resolve a segfault that occurs if the user running conjur-preflight doesn't have permission on some of the partition mount points. This manifested with the crash error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x598e71]

goroutine 7 [running]:
github.com/conjurinc/conjur-preflight/pkg/checks/disk.(*SpaceCheck).Run.func1()
        /conjur-preflight/pkg/checks/disk/space.go:26 +0xf1
created by github.com/conjurinc/conjur-preflight/pkg/checks/disk.(*SpaceCheck).Run
        /conjur-preflight/pkg/checks/disk/space.go:20 +0x6a

Implemented Changes

Previously, an error returned by the usage check was ignored, which led to attempting to read uninitialized memory, leading to the segfault. This error is now properly handled to log it and continue processing.

This PR also fixes all other instances of this class of error. These were not causing issues at the moment, but there are now no unhandled error responses in the project.

Finally, I added the necessary unit tests to include coverage of these scenarios.

Connected Issue/Story

CNJR-830

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: [insert issue ID]
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

@micahlee micahlee force-pushed the disk-space-segfault branch 5 times, most recently from cdcdb3d to 45a8755 Compare March 7, 2023 19:21
@micahlee micahlee marked this pull request as ready for review March 7, 2023 19:21
@micahlee micahlee requested a review from a team March 7, 2023 19:26
Copy link

@telday telday left a comment

Choose a reason for hiding this comment

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

LGTM

@micahlee micahlee merged commit 7f1c63b into master Mar 7, 2023
@micahlee micahlee deleted the disk-space-segfault branch March 7, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants