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

Save the debug and error logs in mok-variables #726

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

vathpela
Copy link
Contributor

This changes our debug and error logging to save the entire logs into mok-variables as "shim-dbg.txt" and "shim-log.txt".

@vathpela vathpela added this to the shim 16 milestone Feb 19, 2025
@vathpela vathpela requested a review from jsetje February 19, 2025 18:12
@vathpela
Copy link
Contributor Author

The result here is you get something like:
[root@wdk23 ~]# hexdump -C /sys/firmware/efi/mok-variables/shim-dbg.txt | head 00000000 73 00 68 00 69 00 6d 00 2e 00 63 00 3a 00 31 00 |s.h.i.m...c.:.1.| 00000010 39 00 38 00 33 00 3a 00 65 00 66 00 69 00 5f 00 |9.8.3.:.e.f.i._.| 00000020 6d 00 61 00 69 00 6e 00 28 00 29 00 20 00 76 00 |m.a.i.n.(.). .v.| 00000030 65 00 6e 00 64 00 6f 00 72 00 5f 00 61 00 75 00 |e.n.d.o.r._.a.u.| 00000040 74 00 68 00 6f 00 72 00 69 00 7a 00 65 00 64 00 |t.h.o.r.i.z.e.d.| 00000050 3a 00 30 00 78 00 39 00 33 00 30 00 39 00 37 00 |:.0.x.9.3.0.9.7.| 00000060 30 00 31 00 30 00 20 00 76 00 65 00 6e 00 64 00 |0.1.0. .v.e.n.d.| 00000070 6f 00 72 00 5f 00 61 00 75 00 74 00 68 00 6f 00 |o.r._.a.u.t.h.o.| 00000080 72 00 69 00 7a 00 65 00 64 00 5f 00 73 00 69 00 |r.i.z.e.d._.s.i.| 00000090 7a 00 65 00 3a 00 30 00 0d 00 0a 00 00 00 73 00 |z.e.:.0.......s.| [root@wdk23 ~]#
which is far from perfect but pretty usable with something like:
[root@wdk23 ~]# iconv -f UCS2 -t UTF8 /sys/firmware/efi/mok-variables/shim-dbg.txt | tr -d '\0' | head shim.c:1983:efi_main() vendor_authorized:0x93097010 vendor_authorized_size:0 shim.c:1985:efi_main() vendor_deauthorized:0x93097010 vendor_deauthorized_size:0 sbat.c:492:set_sbat_uefi_variable() Default sbat policy: automatic sbat.c:553:set_sbat_uefi_variable() shim SBAT reparse before application sbat.c:339:parse_sbat_var() SBAT variable entries: sbat.c:344:parse_sbat_var() sbat, 1, 2021030218 pe.c:376:verify_sbat_section() SBAT section data

This fixes some minor errors with the testing of how ALIGN() and similar
are defined, and makes an explicit "ALIGN_UP()" macro to complement the
existing ALIGN_DOWN() macro.

Signed-off-by: Peter Jones <pjones@redhat.com>
This moves decls for errlog.c into errlog.h

Signed-off-by: Peter Jones <pjones@redhat.com>
This changes our debug and error logging to save the entire logs into
mok-variables as "shim-dbg.txt" and "shim-log.txt".

Signed-off-by: Peter Jones <pjones@redhat.com>
Previously when there were no load options, this would go in the debug
log:

  load-options.c:313:parse_load_options() full load options:
  include/hexdump.h:92:vhexdumpf() hexdump of a NULL pointer!

This changes it to say:

  load-options.c:315:parse_load_options() LoadOptions is empty

Signed-off-by: Peter Jones <pjones@redhat.com>
Copy link
Collaborator

@jsetje jsetje left a comment

Choose a reason for hiding this comment

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

I would change 4096 on line 149 of errlog.c to PAGE_SIZE, even if it will probably always be 4k. Otherwise this looks.

CHAR16 *new_debug_log;

new_alloc_sz += buf_sz;
new_alloc_sz = ALIGN_UP(new_alloc_sz, 4096);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be PAGE_SIZE

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