[PATCH] resolv: Fix a few unaligned accesses to fields in HEADER

Florian Weimer fweimer@redhat.com
Tue Dec 12 08:28:44 GMT 2023


* Ludwig Rydberg:

> After refactoring the alloca usage in 40c0add7d4 ("resolve: Remove
> __res_context_query alloca usage") a few unaligned accesses to HEADER
> fields surfaced. These unaligned accesses led to problems when running
> the resolv test suite on sparc32-linux (leon) as many tests failed due to
> SIGBUS crashes.
>
> The issue(s) occured during T_QUERY_A_AND_AAAA queries as the second query
> now can start on an unaligned address (previously it was explicitly aligned).
>
> With this patch the unaligned accesses are now fixed by using the
> UHEADER instead to ensure the fields are accessed with byte
> loads/stores.
>
> The patch has been verfied by running the resolv test suite on sparc32
> and x86_64.
>
> Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com>
> Signed-off-by: Andreas Larsson <andreas@gaisler.com>
> ---
>  resolv/res_mkquery.c      | 6 +++---
>  resolv/res_queriesmatch.c | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)

Looks reasonable to me.  I will do some tests (although not on
strict-alignment targets, admittedly) and install it.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian



More information about the Libc-alpha mailing list