From: Mark Wielaard <mjw@redhat.com>
To: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
Josh Stone <jistone@redhat.com>
Subject: Re: [PATCH] elf.h SHF_EXCLUDE signed int 31 bit shift triggers undefined behaviour.
Date: Tue, 21 Apr 2015 09:21:00 -0000 [thread overview]
Message-ID: <1429608058.1938.53.camel@bordewijk.wildebeest.org> (raw)
In-Reply-To: <20150324211541.GA2318@blokker.redhat.com>
[-- 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. */
next prev parent reply other threads:[~2015-04-21 9:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 10:39 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 [this message]
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 ` Alexander Cherepanov
2015-04-22 8:59 ` Mark Wielaard
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1429608058.1938.53.camel@bordewijk.wildebeest.org \
--to=mjw@redhat.com \
--cc=jistone@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=szabolcs.nagy@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).