]> git.ipfire.org Git - thirdparty/elfutils.git/commit
libelf: More checking of valid sh_addralign values.
authorMark Wielaard <mjw@redhat.com>
Tue, 12 May 2015 13:28:06 +0000 (15:28 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 18 May 2015 13:48:04 +0000 (15:48 +0200)
commitc0748eff8473b0caa6d51812aa31349bf1dce042
tree4003c3e75a165dd6e17b75b7b16b47051a85bcbb
parent458027d294ac6e8a8678d9fd0f96759d7196ae2b
libelf: More checking of valid sh_addralign values.

There were two issues with bogus sh_addralign values. First we would only
check the individual Elf_Data d_align values were powerof2. But not the
actual shdr addralign value. This would cause an issue if the shdr addralign
was bigger than all of the individual d_align values. Then we could write
out a bogus (! powerof2) shdr addralign value for the sections. Secondly
when reading in the Elf_Data we would set the d_align value to the value
of the shdr addralign value. But we would not check it was valid at all.
In practice there are ELF files with incorrect sh_addralign values (they
are a powerof2, but aren't aligned to the ELF image offset). We would try
to fix that up in elf_update by adding extra padding. But this could bloat
the ELF image a lot for large alignment values. So for too large alignments
that are bigger than the offset in the ELF file clamp them to the offset
value. This could lead us to reject to write out the data again when the
offset was not a powerof2. But this will only happen for aligment values
bigger than 64. Which are uncommon in practice.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libelf/ChangeLog
libelf/elf32_updatenull.c
libelf/elf_getdata.c