This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
- From: Florian Weimer <fweimer at redhat dot com>
- To: Mark Wielaard <mjw at redhat dot com>, Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- Cc: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, Josh Stone <jistone at redhat dot com>
- Date: Wed, 22 Apr 2015 11:18:42 +0200
- Subject: Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
- Authentication-results: sourceware.org; auth=none
- References: <1427193579-26102-1-git-send-email-mjw at redhat dot com> <55117118 dot 1080706 at arm dot com> <20150324211541 dot GA2318 at blokker dot redhat dot com> <1429608058 dot 1938 dot 53 dot camel at bordewijk dot wildebeest dot org> <5537587D dot 5020707 at redhat dot com>
On 04/22/2015 10:14 AM, Florian Weimer wrote:
> On 04/21/2015 11:20 AM, Mark Wielaard wrote:
>> -#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless
>> +#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless
>
> I think the safer change is to use -0x80000000 as the value of the
> constant, without making it unsigned. Otherwise my previous objections
> apply.
I thought some more about this, and have changed my opinion completely.
Making the constant unsigned is less risky than making it negative
because of potential sign extension issues. It's the lesser of two evils.
The proposed patch is okay with me.
--
Florian Weimer / Red Hat Product Security