Skip to content

Fix Regressions caught by CodeQL and Coverity #14573

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

Closed
wants to merge 2 commits into from

Conversation

ryao
Copy link
Contributor

@ryao ryao commented Mar 4, 2023

Motivation and Context

A few recently merged patches introduced regressions.

4c5fec0 introduced a regression caught by Coverity.

dc5c800 introduced a regression caught by CodeQL in a development branch where I am tuning a more aggressive CodeQL configuration than the one we run on pull requests.

Description

The individual patches have descriptions, but in summary, we switch from ASSERT3U() to ASSERT3S() in one and add a missing loop counter increment in another.

How Has This Been Tested?

The buildbot can test it.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@ryao ryao requested a review from amotin March 4, 2023 23:52
@ryao
Copy link
Contributor Author

ryao commented Mar 4, 2023

@amotin You might want to re-do your performance evaluation of dc5c800 with this fix in place.

@mcmilk Please review the commit touching your SHA2 work.

@ryao
Copy link
Contributor Author

ryao commented Mar 5, 2023

I just changed the title of one of the commits. The commit is otherwise identical to the earlier version.

ASSERT3U(algotype, >=, SHA256_MECH_INFO_TYPE);
ASSERT3U(algotype, <=, SHA512_256_MECH_INFO_TYPE);
ASSERT3S(algotype, >=, SHA256_MECH_INFO_TYPE);
ASSERT3S(algotype, <=, SHA512_256_MECH_INFO_TYPE);

Copy link
Contributor

Choose a reason for hiding this comment

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

@ryao - Oh yes, you are right.

ryao added 2 commits March 5, 2023 21:02
The recent 4c5fec0 commit caused
Coverity to report that ASSERT3U(algotype, >=, SHA256_MECH_INFO_TYPE);
is always true. That is because the signed algotype and signed
SHA256_MECH_INFO_TYPE values were cast to unsigned types. To fix this,
we switch the assertions to use ASSERT3S(), which retains the signedness
of the original values for the comparison.

Reported-by: Coverity (CID-1535300)
Signed-off-by: Richard Yao <[email protected]>
dc5c800 was recently merged to prefetch
up to 128 deadlists. Unfortunately, a loop was missing an increment,
such that it will prefetch all deadlists. The performance properties of
that patch probably should be re-evaluated.

This was caught by CodeQL's cpp/constant-comparison check in an
experimental branch where I am testing the security-and-extended
queries. It complained about the `i < 128` part of the loop condition
always evaluating to the same thing. The standard CodeQL configuration
we use missed this because it does not include that check.

Signed-off-by: Richard Yao <[email protected]>
@ryao
Copy link
Contributor Author

ryao commented Mar 6, 2023

I changed a commit title and repushed.

@ryao
Copy link
Contributor Author

ryao commented Mar 6, 2023

@behlendorf The zloop failure is a pre-existing issue. I opened #14583 with a fix for it. As for the Fedora issue, I suspect it is a pre-existing issue too, but the telemetry is not good enough for me to see why.

@ryao
Copy link
Contributor Author

ryao commented Mar 6, 2023

The Fedora buildbot failure is #14584.

@behlendorf behlendorf closed this in 8846139 Mar 6, 2023
behlendorf pushed a commit that referenced this pull request Mar 6, 2023
dc5c800 was recently merged to prefetch
up to 128 deadlists. Unfortunately, a loop was missing an increment,
such that it will prefetch all deadlists. The performance properties of
that patch probably should be re-evaluated.

This was caught by CodeQL's cpp/constant-comparison check in an
experimental branch where I am testing the security-and-extended
queries. It complained about the `i < 128` part of the loop condition
always evaluating to the same thing. The standard CodeQL configuration
we use missed this because it does not include that check.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #14573
behlendorf pushed a commit that referenced this pull request Mar 7, 2023
dc5c800 was recently merged to prefetch
up to 128 deadlists. Unfortunately, a loop was missing an increment,
such that it will prefetch all deadlists. The performance properties of
that patch probably should be re-evaluated.

This was caught by CodeQL's cpp/constant-comparison check in an
experimental branch where I am testing the security-and-extended
queries. It complained about the `i < 128` part of the loop condition
always evaluating to the same thing. The standard CodeQL configuration
we use missed this because it does not include that check.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #14573
rkojedzinszky pushed a commit to rkojedzinszky/zfs that referenced this pull request Mar 7, 2023
dc5c800 was recently merged to prefetch
up to 128 deadlists. Unfortunately, a loop was missing an increment,
such that it will prefetch all deadlists. The performance properties of
that patch probably should be re-evaluated.

This was caught by CodeQL's cpp/constant-comparison check in an
experimental branch where I am testing the security-and-extended
queries. It complained about the `i < 128` part of the loop condition
always evaluating to the same thing. The standard CodeQL configuration
we use missed this because it does not include that check.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#14573
behlendorf pushed a commit that referenced this pull request Mar 7, 2023
dc5c800 was recently merged to prefetch
up to 128 deadlists. Unfortunately, a loop was missing an increment,
such that it will prefetch all deadlists. The performance properties of
that patch probably should be re-evaluated.

This was caught by CodeQL's cpp/constant-comparison check in an
experimental branch where I am testing the security-and-extended
queries. It complained about the `i < 128` part of the loop condition
always evaluating to the same thing. The standard CodeQL configuration
we use missed this because it does not include that check.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #14573
mcmilk pushed a commit to mcmilk/zfs that referenced this pull request Mar 13, 2023
The recent 4c5fec0 commit caused
Coverity to report that ASSERT3U(algotype, >=, SHA256_MECH_INFO_TYPE);
is always true. That is because the signed algotype and signed
SHA256_MECH_INFO_TYPE values were cast to unsigned types. To fix this,
we switch the assertions to use ASSERT3S(), which retains the signedness
of the original values for the comparison.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Reported-by: Coverity (CID-1535300)
Closes openzfs#14573
mcmilk pushed a commit to mcmilk/zfs that referenced this pull request Mar 13, 2023
dc5c800 was recently merged to prefetch
up to 128 deadlists. Unfortunately, a loop was missing an increment,
such that it will prefetch all deadlists. The performance properties of
that patch probably should be re-evaluated.

This was caught by CodeQL's cpp/constant-comparison check in an
experimental branch where I am testing the security-and-extended
queries. It complained about the `i < 128` part of the loop condition
always evaluating to the same thing. The standard CodeQL configuration
we use missed this because it does not include that check.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#14573
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Mar 16, 2023
The recent 4c5fec0 commit caused
Coverity to report that ASSERT3U(algotype, >=, SHA256_MECH_INFO_TYPE);
is always true. That is because the signed algotype and signed
SHA256_MECH_INFO_TYPE values were cast to unsigned types. To fix this,
we switch the assertions to use ASSERT3S(), which retains the signedness
of the original values for the comparison.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Reported-by: Coverity (CID-1535300)
Closes openzfs#14573
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Mar 16, 2023
dc5c800 was recently merged to prefetch
up to 128 deadlists. Unfortunately, a loop was missing an increment,
such that it will prefetch all deadlists. The performance properties of
that patch probably should be re-evaluated.

This was caught by CodeQL's cpp/constant-comparison check in an
experimental branch where I am testing the security-and-extended
queries. It complained about the `i < 128` part of the loop condition
always evaluating to the same thing. The standard CodeQL configuration
we use missed this because it does not include that check.

Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#14573
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants