Bug 31187 - Some CET tests fail with GCC 14
Summary: Some CET tests fail with GCC 14
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: 2.39
: P2 normal
Target Milestone: 2.39
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-22 16:27 UTC by H.J. Lu
Modified: 2024-01-01 23:58 UTC (History)
0 users

See Also:
Host:
Target: x86_64
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2023-12-22 16:27:43 UTC
Some CET tests failed when compiled with GCC 14:

FAIL: elf/tst-cet-legacy-4
FAIL: elf/tst-cet-legacy-5a
FAIL: elf/tst-cet-legacy-6a

which are caused by

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113039

These tests use -fcf-protection -fcf-protection=branch and
assume -fcf-protection=branch will override -fcf-protection.
But

https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1c6231c05bdcca

changed the -fcf-protection behavior such that

-fcf-protection -fcf-protection=branch

is the same as

-fcf-protection

The workaround is to use

-fcf-protection -fcf-protection=none -fcf-protection=branch
Comment 1 Sourceware Commits 2024-01-01 23:56:42 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b5dcccfb12385ee492eb074f6beb9ead56b5e5fd

commit b5dcccfb12385ee492eb074f6beb9ead56b5e5fd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Jan 1 07:55:18 2024 -0800

    x86/cet: Add -fcf-protection=none before -fcf-protection=branch
    
    When shadow stack is enabled, some CET tests failed when compiled with
    GCC 14:
    
    FAIL: elf/tst-cet-legacy-4
    FAIL: elf/tst-cet-legacy-5a
    FAIL: elf/tst-cet-legacy-6a
    
    which are caused by
    
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113039
    
    These tests use -fcf-protection -fcf-protection=branch and assume that
    -fcf-protection=branch will override -fcf-protection.  But this GCC 14
    commit:
    
    https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1c6231c05bdcca
    
    changed the -fcf-protection behavior such that
    
    -fcf-protection -fcf-protection=branch
    
    is treated the same as
    
    -fcf-protection
    
    Use
    
    -fcf-protection -fcf-protection=none -fcf-protection=branch
    
    as the workaround.  This fixes BZ #31187.
    
    Tested with GCC 13 and GCC 14 on Intel Tiger Lake.
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Comment 2 H.J. Lu 2024-01-01 23:58:27 UTC
Fixed for 2.39.