public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "danglin at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/30750] New: Unaligned accesses in resolver
Date: Sun, 13 Aug 2023 17:52:20 +0000	[thread overview]
Message-ID: <bug-30750-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=30750

            Bug ID: 30750
           Summary: Unaligned accesses in resolver
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: danglin at gcc dot gnu.org
                CC: deller at gmx dot de, drepper.fsp at gmail dot com
  Target Milestone: ---
              Host: hppa*-*-linux*
            Target: hppa*-*-linux*
             Build: hppa*-*-linux*

Created attachment 15053
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15053&action=edit
Fix for unaligned accesses in resolver

Helge wrote recently:

Hi Dave,

I'm sure you have seen such messages in dmesg as well:
[ 5073.977098] exim4(11935): unaligned access to 0xf7ebadcd at ip 0xf5f7e307
(iir 0xd481043)
[ 5074.134880] exim4(11935): unaligned access to 0xf7ebadcd at ip 0xf5f7e1cf
(iir 0xee8104d)

I got annoyed by it, and tried to find the root cause:

Runing: prctl --unaligned=signal gdb /usr/sbin/exim4

points to glibc:

Program received signal SIGBUS, Bus error.
__GI___libc_res_queriesmatch (buf1=0xf7e29e70 "}\031\001", eom1=0xf7e29e91 "",
buf2=0xf7e28e09 "}\031\205\200",
    eom2=0xf7e29209 "\342\220\310\367\342\221\324") at res_queriesmatch.c:105
105     res_queriesmatch.c: No such file or directory.
(gdb) bt
#0  __GI___libc_res_queriesmatch (buf1=0xf7e29e70 "}\031\001", eom1=0xf7e29e91
"", buf2=0xf7e28e09 "}\031\205\200",
    eom2=0xf7e29209 "\342\220\310\367\342\221\324") at res_queriesmatch.c:105
#1  0xf5f81380 in send_dg (ansp2_malloced=0x0, resplen2=0x0, anssizp2=0x0,
ansp2=0x0, anscp=0xf7e2938c, gotsomewhere=<synthetic pointer>,
    v_circuit=<synthetic pointer>, ns=<optimized out>, terrno=0xf7e2a088,
anssizp=0xf7e29fc4, ansp=0xf7e29fc8, buflen2=0, buf2=0x0, buflen=33,
    buf=0xf7e29e70 "}\031\001", statp=0xf5fefab0 <_res>) at res_send.c:1204
#2  __GI___res_context_send (ctx=<optimized out>, buf=<optimized out>,
buflen=<optimized out>, buf2=0x0, buflen2=<optimized out>, ans=<optimized out>,
    anssiz=<optimized out>, ansp=<optimized out>, ansp2=<optimized out>,
nansp2=<optimized out>, resplen2=<optimized out>, ansp2_malloced=<optimized
out>)
    at res_send.c:373
#3  0xf5f7e600 in __GI___res_context_query (ctx=0xf7e29e70, name=0x20035
<acl_ratelimit+2344> "\301?Q#V\340", class=-1062726654, type=-167838588,
    answer=<optimized out>, anslen=<optimized out>, answerp=<optimized out>,
answerp2=<optimized out>, nanswerp2=<optimized out>, resplen2=<optimized out>,
    answerp2_malloced=<optimized out>) at res_query.c:221
#4  0x00000000 in ?? ()

In glibc's ./resolv/res_queriesmatch.c:

 /* Note that we initially do not convert QDCOUNT to the host byte
     order.  We can compare it with the second buffer's QDCOUNT
     value without doing this.  */
  int qdcount = ((HEADER *) buf1)->qdcount;
  if (qdcount != ((HEADER *) buf2)->qdcount)

so, buf2 is unaligned and that breaks.

Can we do something about it?

Checking the tests in resolv, I found one more place where unaligned accesses
occur on hppa.

I'm testing the attached patch.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-08-13 17:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-13 17:52 danglin at gcc dot gnu.org [this message]
2023-08-14  1:35 ` [Bug libc/30750] " sam at gentoo dot org
2023-08-14  1:45 ` sam at gentoo dot org
2023-08-14  1:45 ` [Bug network/30750] " sam at gentoo dot org
2023-08-15 19:55 ` deller at gmx dot de
2023-09-13 11:15 ` danglin at gcc dot gnu.org
2023-09-13 13:44 ` fweimer at redhat dot com
2023-11-01 17:00 ` matoro_bugzilla_glibc at matoro dot tk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-30750-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).