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

Re: [Xen-devel] stdbool.h -nostdinc XSA-55 trouble

>>> On 08.08.13 at 18:12, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
> (adding Ian J who did most of XSA-55)
> On Thu, 2013-08-08 at 16:47 +0100, Patrick Welche wrote:
>> On Thu, Aug 08, 2013 at 04:30:06PM +0100, Jan Beulich wrote:
>> > No, according to my checking, the --prefix configure option
>> > listed does not correlate with the directory where the header
>> > is found.
>> Yes - I think our emails crossed...
>> The underlying problem is:
>> Linux:   /usr/lib/gcc/i?86-linux-gnu/n.m/include/stdbool.h
>> NetBSD:  /usr/include/stdbool.h
> The hypervisor side, which is where --nostdinc is used, has it's own
> bool_t in asm/types.h. Perhaps libelf (which is supposed to compile for
> both user and hypervisor space) should be using
> #ifdef __XEN__
> #include <asm/types.h>
> #else
> #include <stdbool.h>
> #endif
> ?

That would make sense only if we could also do the same for
stdarg.h, but you'll note that xen/stdarg.h already works around
the same problem on NetBSD and OpenBSD. Going through the
history of xen/stdarg.h also shows that this has been a recurring
problem. It escapes me why they can't just play things the gcc
way if gcc is their compiler.

I.e. either we allow ourselves to use standard headers that are
defining only compiler determined things (in which case we could
also use stdint.h for example), or we don't use _any_ standard

> I'd be a bit concerned about the fact that Xen's bool_t is a typedef for
> char, as opposed to the compilers typedef to _Bool which has special
> meaning. It may not matter in practice but might the fact that _Bool
> canonicalises to 0 or 1 vs. 0 or !0 cause something subtle?

No, that won't work without auditing the code: Non-boolean
expression results will be converted to 0/1 by the compiler when
the lvalue's type is _Bool, but won't when it's bool_t. While that
might seem fine at the first glance as long as consumers of such
variables don't do explicit == 1 checks, this is becoming a problem
when the non-boolean result is 0 modulo 256 (since the conversion
done in the non-_Bool case is a truncation).


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.