Home GnuPG

fips: Use ELF header to find hmac file offset

Description

fips: Use ELF header to find hmac file offset

* src/fips.c [ENABLE_HMAC_BINARY_CHECK] (hmac256_check): Use ELF headers
  to locate the file offset for the HMAC in addition to information from
  the loader

The previous method of locating the offset of the .rodata1 section in
the ELF file on disk used information obtained from the loader. This
computed the address of the value in memory at runtime, but the offset
in the file can be different. Specifically, the old code computed
a value relative to ElfW(Phdr).p_vaddr, but the offset in the file is
relative to ElfW(Phdr).p_offset. These values can differ, so the
computed address at runtime must be translated into a file offset
relative to p_offset.

This is largely cosmetic, since the text section that should contain the
HMAC usually has both p_vaddr and p_offset set to 0.

  • Signed-off-by: Clemens Lang <cllang@redhat.com>

Details

Provenance
Clemens Lang via Gcrypt-devel <gcrypt-devel@lists.gnupg.org>Authored on Feb 14 2022, 6:49 PM
gniibeCommitted on Feb 15 2022, 10:45 AM
Parents
rCbff9f1b02464: build: Fix m4/gpg-error.m4.
Branches
Unknown
Tags
Unknown

Event Timeline

gniibe committed rCbeb5d6df5c57: fips: Use ELF header to find hmac file offset (authored by Clemens Lang via Gcrypt-devel <gcrypt-devel@lists.gnupg.org>).Feb 15 2022, 10:45 AM