Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87cxrt97i6.fsf@gentoo.org>
Date: Tue, 24 Nov 2026 22:42:09 +0000
From: Sam James <sam@...too.org>
To: Demi Marie Obenour <demiobenour@...il.com>
Cc: oss-security@...ts.openwall.com
Subject: Re: libexpat 2.11.0 fixes three vulnerabilities

Demi Marie Obenour <demiobenour@...il.com> writes:

> On 11/23/26 6:35 PM, Sam James wrote:
>> Sebastian Pipping <sebastian@...ping.org> writes:
>> 
>>> [...]
>>>   #1495  Restore and document `-fno-strict-aliasing` for security
>>>            with both GCC and Clang >=20.
>> 
>> Why Clang >= 20? Clang has supported this flag since forever.
>> 
>>>            libexpat continues to be `-Wstrict-aliasing=3` clean and
>>>            to reject violations via CI but there are multiple known
>>>            strict aliasing violations within libexpat that despite
>>>            `-Wstrict-aliasing=3` are not detected by GCC and which
>> 
>> Note that -Wstrict-aliasing=1 is the most aggressive level [0]. Anyway,
>> in terms of detection, Clang has TypeSanitizer (-fsanitize=type) but it
>> has some issues still. Someone has proposed it for GCC now too.
>> 
>> [0] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing
>> 
>>>            are hard to impossible to resolve without a mess. These and
>> 
>> Why are they so hard to resolve here exactly? In general, just memcpy
>> and move on.
>
> In protocol handling code, it requires code like this:
>
>     memcpy(&out,
>            ((unsigned char *)ptr + struct_size * index + offsetof(type_name, field)),
>            sizeof(out));
>
> instead of:
>
>    out = ((type_name *)ptr)->fam[index].field;
>
> Or it might require:
>
> struct protocol_entry {
>     uint32_t a, b;
> };
>
> struct protocol_entry_mirror;
>
> uint32_t protocol_entry_get_a(const struct protocol_entry_mirror *m) {
>     uint32_t v;
>     static_assert(sizeof(v) == sizeof(m->a), "whoops");
>     memcpy(&v, (const unsigned char *) offsetof(struct protocol_entry, a), sizeof(v));
>     return endian_fixup(v);
> }
>

I think this assumes a specific use model which plenty of cases I've
fixed don't.

> which is unreadable (and unmaintainable) unless autogenerated.
>
> It just winds up being a mess, and for existing code it means a lot of changes
> all over the place.  Building with -fno-strict-aliasing is far, *far* simpler.

I'm aware of your views on the subject, I was wondering about..

>
> I don't know what expat uses type punning for, but I suspect that it, too, would
> need a fairly large change.

.. I was interested in the specifics here for Expat.

sam

Download attachment "signature.asc" of type "application/pgp-signature" (419 bytes)

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.