Bug 2273610 - -fhardened -fcf-protection=none does not cause a warning
Summary: -fhardened -fcf-protection=none does not cause a warning
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 40
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Marek Polacek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-04-05 10:16 UTC by Václav Kadlčík
Modified: 2024-05-20 07:30 UTC (History)
12 users (show)

Fixed In Version: gcc-14.1.1-1.fc40
Clone Of:
Environment:
Last Closed: 2024-05-17 14:13:12 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 114606 0 P3 ASSIGNED -Whardened doesn't trigger with -fcf-protection=none 2024-04-05 16:12:48 UTC

Description Václav Kadlčík 2024-04-05 10:16:17 UTC
When a user uses -fhardened and explicitly weakens any of the hardening
measures implies by -fhardened, a warning should appear IIUIC.

-fhardened implies -fcf-protection=full. I tried to override it by all
the remaining -fcf-protection and I indeed receive the warning except
for -fcf-protection=none which seems strange.

Reproducible: Always

Steps to Reproduce:
$ cat files/main.cc
#include <iostream>
using namespace std;

int main(void) {
    cout << "hello world" << endl;
    return 0;
}

# not actually overriding -> no warning as expected
$ g++ -fhardened -fcf-protection=full -Whardened -O2 -o cxx_hello.exe main.cc

# overriding to branch-only -> warning as expected
$ g++ -fhardened -fcf-protection=branch -Whardened -O2 -o cxx_hello.exe main.cc
cc1plus: warning: ‘-fcf-protection=full’ is not enabled by ‘-fhardened’ because it was specified on the command line [-Whardened]

# overriding to none (disabling it altogether) -> no warning???
$ g++ -fhardened -fcf-protection=none -Whardened -O2 -o cxx_hello.exe main.cc

Comment 1 Marek Polacek 2024-04-05 16:12:48 UTC
Good catch, thanks Vaclav.

Comment 2 Marek Polacek 2024-04-12 14:26:43 UTC
Fixed upstream.


Note You need to log in before you can comment on or make changes to this bug.