[Bug general/29141] _FORTIFY_SOURCE=3 fail for gcc 12/glibc 2.35

2022-05-11 Thread siddhesh at sourceware dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29141

--- Comment #2 from Siddhesh Poyarekar  ---
I can see that it happens with the latest glibc snapshot in rawhide too.  For
some reason the fortified function doesn't get simplified (i.e. choose between
__pread_alias and __pread_chk at compile time, not just emit both) with
_FORTIFY_SOURCE=3 and I need to figure out why.  I'll dig into this.  Please
keep it with elfutils for now.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug libc/29141] _FORTIFY_SOURCE=3 fail for gcc 12/glibc 2.35

2022-05-12 Thread siddhesh at sourceware dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29141

Siddhesh Poyarekar  changed:

   What|Removed |Added

Version|unspecified |2.36
Product|elfutils|glibc
   Assignee|unassigned at sourceware dot org   |siddhesh at sourceware 
dot org
   Last reconfirmed||2022-05-12
 Ever confirmed|0   |1
 Status|UNCONFIRMED |ASSIGNED
 CC||drepper.fsp at gmail dot com
  Component|general |libc

--- Comment #3 from Siddhesh Poyarekar  ---
OK my __glibc_fortify macro isn't explicit enough; it must check if __osz is
constant while checking for -1 so that the condition collapses correctly.

The following single line change in glibc fixes it and I was able to build
elfutils to completion on my Fedora rawhide box.

However, could you tell me what system you're doing this build on?  The glibc
should need this fix for it to stumble on this issue.  I had backported it to
the 2.35 branch a while back, but I haven't tracked which distros synced up
with this.  Fedora seems to have got it only yesterday.

commit c8ee1c85c07b3c9eaef46355cb1095300855e8fa
Author: Joan Bruguera 
Date:   Mon Apr 11 19:49:56 2022 +0200

misc: Fix rare fortify crash on wchar funcs. [BZ 29030]



diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index f1faf8292c..1c2b044a0d 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -164,7 +164,7 @@
 /* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
condition can be folded to a constant and if it is true, or unknown (-1) */
 #define __glibc_safe_or_unknown_len(__l, __s, __osz) \
-  ((__osz) == (__SIZE_TYPE__) -1 \
+  ((__builtin_constant_p (__osz) && (__osz) == (__SIZE_TYPE__) -1)   \
|| (__glibc_unsigned_or_positive (__l)\
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l),
\
   (__s), (__osz)))   \

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug libc/29141] _FORTIFY_SOURCE=3 fail for gcc 12/glibc 2.35

2022-05-12 Thread siddhesh at sourceware dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29141

--- Comment #6 from Siddhesh Poyarekar  ---
(In reply to Petr Ovtchenkov from comment #5)
> Hmm. c8ee1c8 not correspond to diff you show above.

Ah, sorry no, they're two different things that I formatted very badly making
it seem like it's one thing.  The commit that introduced the regression:

commit c8ee1c85c07b3c9eaef46355cb1095300855e8fa
Author: Joan Bruguera 
Date:   Mon Apr 11 19:49:56 2022 +0200

misc: Fix rare fortify crash on wchar funcs. [BZ 29030]

and then the one line fix for it that I'm about to post:

diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index f1faf8292c..1c2b044a0d 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -164,7 +164,7 @@
 /* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
condition can be folded to a constant and if it is true, or unknown (-1) */
 #define __glibc_safe_or_unknown_len(__l, __s, __osz) \
-  ((__osz) == (__SIZE_TYPE__) -1 \
+  ((__builtin_constant_p (__osz) && (__osz) == (__SIZE_TYPE__) -1)   \
|| (__glibc_unsigned_or_positive (__l)\
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l),
\
   (__s), (__osz)))   \

-- 
You are receiving this mail because:
You are on the CC list for the bug.

[Bug libc/29141] _FORTIFY_SOURCE=3 fail for gcc 12/glibc 2.35

2022-05-16 Thread siddhesh at sourceware dot org via Elfutils-devel
https://sourceware.org/bugzilla/show_bug.cgi?id=29141

Siddhesh Poyarekar  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
   Target Milestone|--- |2.36
 Resolution|--- |FIXED

--- Comment #8 from Siddhesh Poyarekar  ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.