public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] resolv: Fix tests by aligning hand crafted queries
Date: Tue, 28 Sep 2021 18:00:04 +0200	[thread overview]
Message-ID: <87ilykadx7.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <4da1fbe0-e1ac-09c2-de8b-2179344cf59b@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Tue, 28 Sep 2021 11:36:02 -0300")

* Adhemerval Zanella via Libc-alpha:

> On 14/06/2021 20:40, Stafford Horne via Libc-alpha wrote:
>> When testing OpenRISC I get a bus error in res_send.  This is due to the
>> buf being cast to a (HEADER *) and trying the res_send code trying to read
>> different bits of the HEADER struct including 16-bit id etc.
>> 
>> On OpenRISC reads of 16-bits and 32-bits from structures need to be 2
>> byte and 4 byte aligned, respectively.
>> 
>> To fix this we can align the hand crafted queries.
>
>
> But the res_send() interface does specify that buffer is an 'unsigned char',
> so I think the problem is in fact send_vc() (any any other code that consume
> the buffer) where the cast is in fact undefined.  I am not sure why it has
> not show any issue on architecture that trap on unaligned access, may guess
> is the stack buffer alignment is the same as the HEADER.
>
> The issue is resolv code seems to abuse this...

Right, there is a separate bug for this:

  Misaligned access in res_query.c HEADER struct
  <https://sourceware.org/bugzilla/show_bug.cgi?id=20243>

I really want to fix this, but each time I get side-tracked by other
cleanups that appear to be necessary for this. 8-(

Thanks,
Florian


  reply	other threads:[~2021-09-28 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 23:40 Stafford Horne
2021-09-27 20:43 ` Stafford Horne
2021-09-28 14:36 ` Adhemerval Zanella
2021-09-28 16:00   ` Florian Weimer [this message]
2021-10-06 20:53     ` Stafford Horne

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=87ilykadx7.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@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).