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

pesigcheck: Fix crash on digest match #90

Merged
merged 1 commit into from
Jun 10, 2022
Merged

pesigcheck: Fix crash on digest match #90

merged 1 commit into from
Jun 10, 2022

Conversation

vhankala
Copy link
Contributor

@vhankala vhankala commented Jun 7, 2022

Set selected_digest when the digest is found in db or dbx.
This fixes a crash in get_digest().

Signed-off-by: Visa Hankala [email protected]

@frozencemetery
Copy link
Member

frozencemetery commented Jun 8, 2022

Thanks for the patch. It would be good to put more information on the crash you see in the commit message.

Looking more at the code, I dislike the existing practice of using a signed integer for this at all. I'd prefer a struct digest_param * that's NULL when no set - at least that way we'd get a hard crash instead of accessing -1 sometimes.

(If you'd prefer not to perform that refactoring, please let me know and I'll take care of it.)

Copy link
Member

@frozencemetery frozencemetery left a comment

Choose a reason for hiding this comment

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

(Marking reviewed as above.)

Set selected_digest when the digest is found in db or dbx.
This fixes the following crash of pesigcheck:

  Program received signal SIGSEGV, Segmentation fault.
  0x00005555555597fa in memcpy (__len=24, __src=0x31,
      __dest=0x55555558d908)
      at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
  34      return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
  (gdb) bt
  #0  0x00005555555597fa in memcpy (__len=24, __src=0x31,
      __dest=0x55555558d908)
      at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
  #1  get_digest (digest=digest@entry=0x55555558d908,
      ctx=<optimized out>, ctx=<optimized out>) at pesigcheck.c:226
  #2  0x00005555555592fd in check_signature (
      reasons=<synthetic pointer>, nreasons=<synthetic pointer>,
      ctx=0x7fffffffded0) at pesigcheck.c:262
  #3  main (argc=<optimized out>, argv=<optimized out>)
      at pesigcheck.c:512

Signed-off-by: Visa Hankala <[email protected]>
@vhankala
Copy link
Contributor Author

(If you'd prefer not to perform that refactoring, please let me know and I'll take care of it.)

I have not done that refactoring.

@frozencemetery frozencemetery merged commit 3b1031a into rhboot:main Jun 10, 2022
@vhankala vhankala deleted the pesigcheck branch June 12, 2022 08:20
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.

2 participants