Hi Mark, LGTM.
Aaron On Sat, Nov 7, 2026 at 4:53 PM Mark Wielaard <[email protected]> wrote: > > Elf_Data with d_align of zero passed the alignment check. But an > alignment of zero would cause the padding calculation to be wrong > (resulting in a zero offset). Clamp d_align of zero to one before the > alignment check, the same way sh_addralign of zero is already handled. > > Commit c0748eff8473 ("libelf: More checking of valid sh_addralign > values.") fixed a similar issue in elf_getdata. Commit 7369e7d9f171 > ("elf_newdata: Make sure to set d_type to ELF_T_BYTE and d_align to > one") tried to fix this same issue by making sure elf_newdata set > d_align to one by default. > > * libelf/elf32_updatenull.c (update_null): Clamp data->d_align > of zero to one before the powerof2 check. > > Signed-off-by: Mark Wielaard <[email protected]> > --- > libelf/elf32_updatenull.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c > index 57239ee4ac90..a0a9c3bf3afe 100644 > --- a/libelf/elf32_updatenull.c > +++ b/libelf/elf32_updatenull.c > @@ -308,6 +308,10 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int > *change_bop, size_t shnum) > return -1; > } > > + /* An alignment of zero would cause the padding > + calculation to be wrong. */ > + if (data->d_align == 0) > + data->d_align = 1; > if (unlikely (! powerof2 (data->d_align))) > { > __libelf_seterrno (ELF_E_INVALID_ALIGN); > -- > 2.56.0 >
