Message ID | 1427193579-26102-1-git-send-email-mjw@redhat.com |
---|---|
State | Superseded |
Headers |
Received: (qmail 55179 invoked by alias); 24 Mar 2015 10:39:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 55159 invoked by uid 89); 24 Mar 2015 10:39:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: gnu.wildebeest.org From: Mark Wielaard <mjw@redhat.com> To: libc-alpha@sourceware.org Cc: Josh Stone <jistone@redhat.com>, Mark Wielaard <mjw@redhat.com> Subject: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour. Date: Tue, 24 Mar 2015 11:39:39 +0100 Message-Id: <1427193579-26102-1-git-send-email-mjw@redhat.com> X-Spam-Score: -2.9 (--) |
Commit Message
Mark Wielaard
March 24, 2015, 10:39 a.m. UTC
Any use of SHF_EXCLUDE in code that tries to check it against sh_flags will trigger undefined behaviour because it is defined as a 31 bit shift against an signed integer. Fix by explicitly using an unsigned int. --- ChangeLog | 4 ++++ elf/elf.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
Comments
On 24/03/15 10:39, Mark Wielaard wrote: > Any use of SHF_EXCLUDE in code that tries to check it against sh_flags > will trigger undefined behaviour because it is defined as a 31 bit shift > against an signed integer. Fix by explicitly using an unsigned int. there is another proposed patch for this https://sourceware.org/ml/libc-alpha/2015-03/msg00287.html > ChangeLog | 4 ++++ > elf/elf.h | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > i think changelog entries are supposed to be submitted separately
On 24 Mar 2015 14:13, Szabolcs Nagy wrote: > On 24/03/15 10:39, Mark Wielaard wrote: > > Any use of SHF_EXCLUDE in code that tries to check it against sh_flags > > will trigger undefined behaviour because it is defined as a 31 bit shift > > against an signed integer. Fix by explicitly using an unsigned int. > > there is another proposed patch for this > > https://sourceware.org/ml/libc-alpha/2015-03/msg00287.html > > > ChangeLog | 4 ++++ > > elf/elf.h | 2 +- > > 2 files changed, 5 insertions(+), 1 deletion(-) > > > > i think changelog entries are supposed to be submitted separately nope ... should be same commit -mike
* Mike Frysinger: > On 24 Mar 2015 14:13, Szabolcs Nagy wrote: >> On 24/03/15 10:39, Mark Wielaard wrote: >> > Any use of SHF_EXCLUDE in code that tries to check it against sh_flags >> > will trigger undefined behaviour because it is defined as a 31 bit shift >> > against an signed integer. Fix by explicitly using an unsigned int. >> >> there is another proposed patch for this >> >> https://sourceware.org/ml/libc-alpha/2015-03/msg00287.html >> >> > ChangeLog | 4 ++++ >> > elf/elf.h | 2 +- >> > 2 files changed, 5 insertions(+), 1 deletion(-) >> > >> >> i think changelog entries are supposed to be submitted separately > > nope ... should be same commit There used be an expectation that the ChangeLog update was not to be submitted as part of the patch, but as a separate item in the patch submission (not as a diff hunk, not with + prefix). Has this changed? It would certainly make things simpler for me. :)
On 24 Mar 2015 20:53, Florian Weimer wrote: > * Mike Frysinger: > > On 24 Mar 2015 14:13, Szabolcs Nagy wrote: > >> On 24/03/15 10:39, Mark Wielaard wrote: > >> > Any use of SHF_EXCLUDE in code that tries to check it against sh_flags > >> > will trigger undefined behaviour because it is defined as a 31 bit shift > >> > against an signed integer. Fix by explicitly using an unsigned int. > >> > >> there is another proposed patch for this > >> > >> https://sourceware.org/ml/libc-alpha/2015-03/msg00287.html > >> > >> > ChangeLog | 4 ++++ > >> > elf/elf.h | 2 +- > >> > 2 files changed, 5 insertions(+), 1 deletion(-) > >> > >> i think changelog entries are supposed to be submitted separately > > > > nope ... should be same commit > > There used be an expectation that the ChangeLog update was not to be > submitted as part of the patch, but as a separate item in the patch > submission (not as a diff hunk, not with + prefix). > > Has this changed? It would certainly make things simpler for me. :) i don't know what the preference is, but i don't mind either -mike
On Tue, Mar 24, 2015 at 11:39:39AM +0100, Mark Wielaard wrote: > Any use of SHF_EXCLUDE in code that tries to check it against sh_flags > will trigger undefined behaviour because it is defined as a 31 bit shift > against an signed integer. Fix by explicitly using an unsigned int. > --- > ChangeLog | 4 ++++ > elf/elf.h | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > I looked that Florian acked this at patchwork thread. Florian, could you also commit it or do we need more discussion?
On Wed, 2015-05-13 at 12:27 +0200, Ondřej Bílka wrote: > On Tue, Mar 24, 2015 at 11:39:39AM +0100, Mark Wielaard wrote: > > Any use of SHF_EXCLUDE in code that tries to check it against sh_flags > > will trigger undefined behaviour because it is defined as a 31 bit shift > > against an signed integer. Fix by explicitly using an unsigned int. > > --- > > ChangeLog | 4 ++++ > > elf/elf.h | 2 +- > > 2 files changed, 5 insertions(+), 1 deletion(-) > > > I looked that Florian acked this at patchwork thread. Florian, could you also > commit it or do we need more discussion? It is already in as commit fb4041, see: https://sourceware.org/ml/libc-alpha/2015-04/msg00359.html
On Wed, May 13, 2015 at 12:46:26PM +0200, Mark Wielaard wrote: > On Wed, 2015-05-13 at 12:27 +0200, Ondřej Bílka wrote: > > On Tue, Mar 24, 2015 at 11:39:39AM +0100, Mark Wielaard wrote: > > > Any use of SHF_EXCLUDE in code that tries to check it against sh_flags > > > will trigger undefined behaviour because it is defined as a 31 bit shift > > > against an signed integer. Fix by explicitly using an unsigned int. > > > --- > > > ChangeLog | 4 ++++ > > > elf/elf.h | 2 +- > > > 2 files changed, 5 insertions(+), 1 deletion(-) > > > > > I looked that Florian acked this at patchwork thread. Florian, could you also > > commit it or do we need more discussion? > > It is already in as commit fb4041, see: > https://sourceware.org/ml/libc-alpha/2015-04/msg00359.html thanks. marked that also at patchwork.
On 05/13/2015 06:56 AM, Ondřej Bílka wrote: > On Wed, May 13, 2015 at 12:46:26PM +0200, Mark Wielaard wrote: >> On Wed, 2015-05-13 at 12:27 +0200, Ondřej Bílka wrote: >>> On Tue, Mar 24, 2015 at 11:39:39AM +0100, Mark Wielaard wrote: >>>> Any use of SHF_EXCLUDE in code that tries to check it against sh_flags >>>> will trigger undefined behaviour because it is defined as a 31 bit shift >>>> against an signed integer. Fix by explicitly using an unsigned int. >>>> --- >>>> ChangeLog | 4 ++++ >>>> elf/elf.h | 2 +- >>>> 2 files changed, 5 insertions(+), 1 deletion(-) >>>> >>> I looked that Florian acked this at patchwork thread. Florian, could you also >>> commit it or do we need more discussion? >> >> It is already in as commit fb4041, see: >> https://sourceware.org/ml/libc-alpha/2015-04/msg00359.html > > thanks. marked that also at patchwork. > Ondrej, Thanks for the patchwork cleanup! c.
diff --git a/ChangeLog b/ChangeLog index b0a17b0..bdf899f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-03-24 Mark Wielaard <mjw@redhat.com> + + * elf/elf.h (SHF_EXCLUDE): Use unsigned 1 for shift. + 2015-03-23 Roland McGrath <roland@hack.frob.com> * libio/iofdopen.c: Move FD_FLAGS declaration into its first use, diff --git a/elf/elf.h b/elf/elf.h index 496f08d..960a3c3 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -371,7 +371,7 @@ typedef struct #define SHF_MASKPROC 0xf0000000 /* Processor-specific */ #define SHF_ORDERED (1 << 30) /* Special ordering requirement (Solaris). */ -#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless +#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless referenced or allocated (Solaris).*/ /* Section group handling. */