* [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
@ 2015-03-24 10:39 Mark Wielaard
2015-03-24 14:13 ` Szabolcs Nagy
2015-05-13 10:27 ` Ondřej Bílka
0 siblings, 2 replies; 21+ messages in thread
From: Mark Wielaard @ 2015-03-24 10:39 UTC (permalink / raw)
To: libc-alpha; +Cc: Josh Stone, Mark Wielaard
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(-)
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. */
--
1.8.3.1
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 10:39 [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour Mark Wielaard
@ 2015-03-24 14:13 ` Szabolcs Nagy
2015-03-24 19:50 ` Mike Frysinger
2015-03-24 21:15 ` Mark Wielaard
2015-05-13 10:27 ` Ondřej Bílka
1 sibling, 2 replies; 21+ messages in thread
From: Szabolcs Nagy @ 2015-03-24 14:13 UTC (permalink / raw)
To: Mark Wielaard, libc-alpha; +Cc: Josh Stone
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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 14:13 ` Szabolcs Nagy
@ 2015-03-24 19:50 ` Mike Frysinger
2015-03-24 19:53 ` Florian Weimer
2015-03-24 21:15 ` Mark Wielaard
1 sibling, 1 reply; 21+ messages in thread
From: Mike Frysinger @ 2015-03-24 19:50 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: Mark Wielaard, libc-alpha, Josh Stone
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 19:50 ` Mike Frysinger
@ 2015-03-24 19:53 ` Florian Weimer
2015-03-24 21:41 ` Mike Frysinger
0 siblings, 1 reply; 21+ messages in thread
From: Florian Weimer @ 2015-03-24 19:53 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: Mark Wielaard, libc-alpha, Josh Stone
* 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. :)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 14:13 ` Szabolcs Nagy
2015-03-24 19:50 ` Mike Frysinger
@ 2015-03-24 21:15 ` Mark Wielaard
2015-03-25 21:25 ` Roland McGrath
2015-04-21 9:21 ` Mark Wielaard
1 sibling, 2 replies; 21+ messages in thread
From: Mark Wielaard @ 2015-03-24 21:15 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: libc-alpha, Josh Stone
[-- Attachment #1: Type: text/plain, Size: 1384 bytes --]
On Tue, Mar 24, 2015 at 02:13:44PM +0000, 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
I missed that one. It does seem more ambitious than what I am proposing.
It is probably a good idea to change every constant to the appropriate
unsigned type. But the testing requirements seem hard to satisfy and it
looks like that patch is stalled because of that.
Could this simpler patch that just fixes the one constant that does
have a real problem in practice when used be fixed independently?
I like building my project with gcc -fsanitize=undefined and the
usage of SHF_EXCLUDE is preventing that atm.
> > ChangeLog | 4 ++++
> > elf/elf.h | 2 +-
> > 2 files changed, 5 insertions(+), 1 deletion(-)
> >
>
> i think changelog entries are supposed to be submitted separately
OK. How about the following then?
I would appreciate it if someone could push that for me since I don't
have glibc commit access.
Thanks,
Mark
2015-03-24 Mark Wielaard <mjw@redhat.com>
* elf/elf.h (SHF_EXCLUDE): Use unsigned 1 for shift.
[-- Attachment #2: shf_exclude.patch --]
[-- Type: text/plain, Size: 500 bytes --]
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. */
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 19:53 ` Florian Weimer
@ 2015-03-24 21:41 ` Mike Frysinger
0 siblings, 0 replies; 21+ messages in thread
From: Mike Frysinger @ 2015-03-24 21:41 UTC (permalink / raw)
To: Florian Weimer; +Cc: Szabolcs Nagy, Mark Wielaard, libc-alpha, Josh Stone
[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]
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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 21:15 ` Mark Wielaard
@ 2015-03-25 21:25 ` Roland McGrath
2015-03-26 8:29 ` Mark Wielaard
2015-04-21 9:21 ` Mark Wielaard
1 sibling, 1 reply; 21+ messages in thread
From: Roland McGrath @ 2015-03-25 21:25 UTC (permalink / raw)
To: Mark Wielaard; +Cc: Szabolcs Nagy, libc-alpha, Josh Stone
Please participate in the other thread trying to figure out a testing
strategy. I think it's tractable.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-25 21:25 ` Roland McGrath
@ 2015-03-26 8:29 ` Mark Wielaard
0 siblings, 0 replies; 21+ messages in thread
From: Mark Wielaard @ 2015-03-26 8:29 UTC (permalink / raw)
To: Roland McGrath; +Cc: Szabolcs Nagy, libc-alpha, Josh Stone
On Wed, 2015-03-25 at 14:25 -0700, Roland McGrath wrote:
> Please participate in the other thread trying to figure out a testing
> strategy. I think it's tractable.
To be honest I am not as optimistic and like my simple one character
patch better. But if others are as positive as you are then I certainly
don't mind a different solution. As long as the problem gets fixed.
Cheers,
Mark
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 21:15 ` Mark Wielaard
2015-03-25 21:25 ` Roland McGrath
@ 2015-04-21 9:21 ` Mark Wielaard
2015-04-22 8:15 ` Florian Weimer
1 sibling, 1 reply; 21+ messages in thread
From: Mark Wielaard @ 2015-04-21 9:21 UTC (permalink / raw)
To: Szabolcs Nagy; +Cc: libc-alpha, Josh Stone
[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]
Hi,
On Tue, 2015-03-24 at 22:15 +0100, Mark Wielaard wrote:
> On Tue, Mar 24, 2015 at 02:13:44PM +0000, 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
>
> I missed that one. It does seem more ambitious than what I am proposing.
> It is probably a good idea to change every constant to the appropriate
> unsigned type. But the testing requirements seem hard to satisfy and it
> looks like that patch is stalled because of that.
So I participated in that other thread, but it seems a rewrite of elf.h
to use the "correct type" for each constant is not so tractable as
hoped. So it seems that patch is stalled. Since the SHF_EXCLUDE issue is
real (it keeps being reported over and over again against elfutils) and
easy to fix itself with this one character patch, could you reconsider
just applying this now?
> Could this simpler patch that just fixes the one constant that does
> have a real problem in practice when used be fixed independently?
> I like building my project with gcc -fsanitize=undefined and the
> usage of SHF_EXCLUDE is preventing that atm.
>
> > > ChangeLog | 4 ++++
> > > elf/elf.h | 2 +-
> > > 2 files changed, 5 insertions(+), 1 deletion(-)
> > >
> >
> > i think changelog entries are supposed to be submitted separately
>
> OK. How about the following then?
>
> I would appreciate it if someone could push that for me since I don't
> have glibc commit access.
> 2015-03-24 Mark Wielaard <mjw@redhat.com>
>
> * elf/elf.h (SHF_EXCLUDE): Use unsigned 1 for shift.
[-- Attachment #2: shf_exclude.patch --]
[-- Type: text/x-patch, Size: 513 bytes --]
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. */
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-21 9:21 ` Mark Wielaard
@ 2015-04-22 8:15 ` Florian Weimer
2015-04-22 8:25 ` Andreas Schwab
2015-04-22 9:18 ` Florian Weimer
0 siblings, 2 replies; 21+ messages in thread
From: Florian Weimer @ 2015-04-22 8:15 UTC (permalink / raw)
To: Mark Wielaard, Szabolcs Nagy; +Cc: libc-alpha, Josh Stone
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'm sorry it has come to this, I can empathize with your struggles to
get patches applied to glibc.
--
Florian Weimer / Red Hat Product Security
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-22 8:15 ` Florian Weimer
@ 2015-04-22 8:25 ` Andreas Schwab
2015-04-22 8:33 ` Florian Weimer
2015-04-22 9:18 ` Florian Weimer
1 sibling, 1 reply; 21+ messages in thread
From: Andreas Schwab @ 2015-04-22 8:25 UTC (permalink / raw)
To: Florian Weimer; +Cc: Mark Wielaard, Szabolcs Nagy, libc-alpha, Josh Stone
Florian Weimer <fweimer@redhat.com> writes:
> I think the safer change is to use -0x80000000 as the value of the
> constant, without making it unsigned.
-0x80000000 has unsigned type.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-22 8:25 ` Andreas Schwab
@ 2015-04-22 8:33 ` Florian Weimer
2015-04-22 8:59 ` Mark Wielaard
2015-04-22 8:59 ` Alexander Cherepanov
0 siblings, 2 replies; 21+ messages in thread
From: Florian Weimer @ 2015-04-22 8:33 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Mark Wielaard, Szabolcs Nagy, libc-alpha, Josh Stone
On 04/22/2015 10:25 AM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
>
>> I think the safer change is to use -0x80000000 as the value of the
>> constant, without making it unsigned.
>
> -0x80000000 has unsigned type.
Ugh. The joys of C.
Using a cast would rely on a GCC extension, so one has to write
(-2147483647 - 1) to get the desired value. Wow.
--
Florian Weimer / Red Hat Product Security
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-22 8:33 ` Florian Weimer
@ 2015-04-22 8:59 ` Mark Wielaard
2015-04-22 8:59 ` Alexander Cherepanov
1 sibling, 0 replies; 21+ messages in thread
From: Mark Wielaard @ 2015-04-22 8:59 UTC (permalink / raw)
To: Florian Weimer; +Cc: Andreas Schwab, Szabolcs Nagy, libc-alpha, Josh Stone
On Wed, 2015-04-22 at 10:33 +0200, Florian Weimer wrote:
> On 04/22/2015 10:25 AM, Andreas Schwab wrote:
> > Florian Weimer <fweimer@redhat.com> writes:
> >
> >> I think the safer change is to use -0x80000000 as the value of the
> >> constant, without making it unsigned.
> >
> > -0x80000000 has unsigned type.
>
> Ugh. The joys of C.
>
> Using a cast would rely on a GCC extension, so one has to write
> (-2147483647 - 1) to get the desired value. Wow.
What is your objection to having the constant unsigned?
Note that other ELF based systems like android or bsd just define the
constant as 0x80000000 (with or without UL). And the other SHF_
constants are also defined with their 0x... values in gABI. They are
flag values you combine with | or mask with &, not compare directly.
If you objection is that it isn't consistent with the other flag value
defines then my other proposal was to just define all these SHF
constants with their hex value:
https://sourceware.org/ml/libc-alpha/2015-03/msg00793.html
Cheers,
Mark
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-22 8:33 ` Florian Weimer
2015-04-22 8:59 ` Mark Wielaard
@ 2015-04-22 8:59 ` Alexander Cherepanov
1 sibling, 0 replies; 21+ messages in thread
From: Alexander Cherepanov @ 2015-04-22 8:59 UTC (permalink / raw)
To: Florian Weimer, Andreas Schwab
Cc: Mark Wielaard, Szabolcs Nagy, libc-alpha, Josh Stone
On 2015-04-22 11:33, Florian Weimer wrote:
> On 04/22/2015 10:25 AM, Andreas Schwab wrote:
>> Florian Weimer <fweimer@redhat.com> writes:
>>
>>> I think the safer change is to use -0x80000000 as the value of the
>>> constant, without making it unsigned.
>>
>> -0x80000000 has unsigned type.
>
> Ugh. The joys of C.
>
> Using a cast would rely on a GCC extension, so one has to write
> (-2147483647 - 1) to get the desired value. Wow.
Given that stdint.h is already included it's perhaps easier to just use
INT32_MIN?
I've replied about it and other issues in the previous thread but I'm
afraid I'm lost all Cc there. Here it is:
https://sourceware.org/ml/libc-alpha/2015-04/msg00257.html
--
Alexander Cherepanov
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-22 8:15 ` Florian Weimer
2015-04-22 8:25 ` Andreas Schwab
@ 2015-04-22 9:18 ` Florian Weimer
2015-04-28 8:22 ` Mark Wielaard
1 sibling, 1 reply; 21+ messages in thread
From: Florian Weimer @ 2015-04-22 9:18 UTC (permalink / raw)
To: Mark Wielaard, Szabolcs Nagy; +Cc: libc-alpha, Josh Stone
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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-22 9:18 ` Florian Weimer
@ 2015-04-28 8:22 ` Mark Wielaard
2015-04-28 12:01 ` Florian Weimer
0 siblings, 1 reply; 21+ messages in thread
From: Mark Wielaard @ 2015-04-28 8:22 UTC (permalink / raw)
To: Florian Weimer; +Cc: Szabolcs Nagy, libc-alpha, Josh Stone
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]
On Wed, 2015-04-22 at 11:18 +0200, Florian Weimer wrote:
> 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.
Thanks. I didn't see other objections. So if it is good to go in could
someone please push it for me? (I don't have glibc git push access.)
ChangeLog
* elf/elf.h (SHF_EXCLUDE): Use unsigned 1 for shift.
[-- Attachment #2: shf_exclude.patch --]
[-- Type: text/x-patch, Size: 1084 bytes --]
From 86771e8963653c306e53c07e1640914081afb30a Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Tue, 24 Mar 2015 11:32:36 +0100
Subject: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined
behaviour.
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(-)
diff --git a/elf/elf.h b/elf/elf.h
index 71492a2..39bafc2 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. */
--
1.8.3.1
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-04-28 8:22 ` Mark Wielaard
@ 2015-04-28 12:01 ` Florian Weimer
0 siblings, 0 replies; 21+ messages in thread
From: Florian Weimer @ 2015-04-28 12:01 UTC (permalink / raw)
To: Mark Wielaard; +Cc: Szabolcs Nagy, libc-alpha, Josh Stone
On 04/28/2015 10:22 AM, Mark Wielaard wrote:
> Thanks. I didn't see other objections. So if it is good to go in could
> someone please push it for me? (I don't have glibc git push access.)
>
> ChangeLog
>
> * elf/elf.h (SHF_EXCLUDE): Use unsigned 1 for shift.
>
Thanks, committed.
--
Florian Weimer / Red Hat Product Security
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-03-24 10:39 [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour Mark Wielaard
2015-03-24 14:13 ` Szabolcs Nagy
@ 2015-05-13 10:27 ` Ondřej Bílka
2015-05-13 10:46 ` Mark Wielaard
1 sibling, 1 reply; 21+ messages in thread
From: Ondřej Bílka @ 2015-05-13 10:27 UTC (permalink / raw)
To: Mark Wielaard; +Cc: libc-alpha, fweimer, Josh Stone
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?
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-05-13 10:27 ` Ondřej Bílka
@ 2015-05-13 10:46 ` Mark Wielaard
2015-05-13 10:56 ` Ondřej Bílka
0 siblings, 1 reply; 21+ messages in thread
From: Mark Wielaard @ 2015-05-13 10:46 UTC (permalink / raw)
To: Ondřej Bílka; +Cc: libc-alpha, fweimer, Josh Stone
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
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-05-13 10:46 ` Mark Wielaard
@ 2015-05-13 10:56 ` Ondřej Bílka
2015-05-14 0:43 ` Carlos O'Donell
0 siblings, 1 reply; 21+ messages in thread
From: Ondřej Bílka @ 2015-05-13 10:56 UTC (permalink / raw)
To: Mark Wielaard; +Cc: libc-alpha, fweimer, Josh Stone
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.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
2015-05-13 10:56 ` Ondřej Bílka
@ 2015-05-14 0:43 ` Carlos O'Donell
0 siblings, 0 replies; 21+ messages in thread
From: Carlos O'Donell @ 2015-05-14 0:43 UTC (permalink / raw)
To: Ondřej Bílka, Mark Wielaard; +Cc: libc-alpha, fweimer, Josh Stone
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.
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2015-05-14 0:43 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-24 10:39 [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour Mark Wielaard
2015-03-24 14:13 ` Szabolcs Nagy
2015-03-24 19:50 ` Mike Frysinger
2015-03-24 19:53 ` Florian Weimer
2015-03-24 21:41 ` Mike Frysinger
2015-03-24 21:15 ` Mark Wielaard
2015-03-25 21:25 ` Roland McGrath
2015-03-26 8:29 ` Mark Wielaard
2015-04-21 9:21 ` Mark Wielaard
2015-04-22 8:15 ` Florian Weimer
2015-04-22 8:25 ` Andreas Schwab
2015-04-22 8:33 ` Florian Weimer
2015-04-22 8:59 ` Mark Wielaard
2015-04-22 8:59 ` Alexander Cherepanov
2015-04-22 9:18 ` Florian Weimer
2015-04-28 8:22 ` Mark Wielaard
2015-04-28 12:01 ` Florian Weimer
2015-05-13 10:27 ` Ondřej Bílka
2015-05-13 10:46 ` Mark Wielaard
2015-05-13 10:56 ` Ondřej Bílka
2015-05-14 0:43 ` Carlos O'Donell
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).