[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#472269: libc6: res_query makes assumptions about the alignment of the answer argument



Package: libc6
Followup-For: Bug #472269

Dear Maintainer,

I believe this bug is fixed upstream by the following commit:

commit 05dec22d7be722987ff07aebf9690f6078b3c4e9 (HEAD -> master, origin/master,
origin/HEAD)
Author: John David Anglin <danglin@gcc.gnu.org>
Date:   Tue Mar 22 17:35:54 2022 +0000

    resolv: Fix unaligned accesses to fields in HEADER struct

    The structure HEADER is normally aligned to a word boundary but
    sometimes it needs to be accessed when aligned on a byte boundary.
    This change defines a new typedef, UHEADER, with alignment 1.
    It is used to ensure the fields are accessed with byte loads and
    stores when necessary.

    V4: Change to res_mkquery.c deleted.  Small whitespace fix.

    V5: Move UHEADER typedef to resolv/resolv-internal.h.  Replace all
    HEADER usage with UHEADER in resolv/res_send.c.

    Signed-off-by: John David Anglin <dave.anglin@bell.net>
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

This bug is fixed in debian 2.33 by the patch
any/submitted-resolv-unaligned.diff.  It turns out the following
hunk can be removed:

diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c
index 5bc5b41531..9b82c82157 100644
--- a/resolv/res_mkquery.c
+++ b/resolv/res_mkquery.c
@@ -193,6 +193,15 @@ context_mkquery_common (struct resolv_context *ctx,
   return result;
 }
 
+/* The structure HEADER is normally aligned to a word boundary and its
+   fields are accessed using word loads and stores.  We need to access
+   this structure when it is aligned on a byte boundary.  This can cause
+   problems on machines with strict alignment.  So, we create a new
+   typedef to reduce its alignment to one.  This ensures the fields are
+   accessed with byte loads and stores.  */
+typedef HEADER __attribute__ ((__aligned__(1))) UHEADER;
+#define HEADER UHEADER
+
 /* Form all types of queries.  Returns the size of the result or -1 on
    error.
 
Regards,
Dave Anglin

-- System Information:
Debian Release: bookworm/sid
  APT prefers buildd-unstable
  APT policy: (500, 'buildd-unstable'), (500, 'unstable')
Architecture: hppa (parisc64)

Kernel: Linux 5.16.16+ (SMP w/4 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libc6 depends on:
ii  libgcc-s4  12-20220319-1

Versions of packages libc6 recommends:
ii  libidn2-0  2.3.2-2

Versions of packages libc6 suggests:
ii  debconf [debconf-2.0]  1.5.79
ii  glibc-doc              2.33-7
ii  libc-l10n              2.33-7
ii  libnss-nis             3.1-4
ii  libnss-nisplus         1.3-4
ii  locales                2.33-7

-- debconf information excluded


Reply to: