Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support -D_FORTIFY_SOURCE=3 #29

Closed
marxin opened this issue Apr 4, 2022 · 11 comments · Fixed by #31
Closed

Support -D_FORTIFY_SOURCE=3 #29

marxin opened this issue Apr 4, 2022 · 11 comments · Fixed by #31

Comments

@marxin
Copy link
Contributor

marxin commented Apr 4, 2022

I'm experimenting with -D_FORTIFY_SOURCE=3 that will be available since GCC 12.1 and I see the following error:

[   18s] cc --std=gnu99  -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -Werror -Wall -Wextra -Wformat=2 -Wformat-overflow=2 -Werror=implicit-int -Werror=implicit-function-declaration -Werror=format-security -Wno-clobbered -Wno-error=clobbered -Werror=cast-qual -Werror=discarded-qualifiers -pipe -DBIN_DIR=\"/usr/sbin\" -DLIB_STRING=\"lib64\" -DRUN_DIR=\"run\" -MMD -MP -fPIE -DPIE -I. -I../libmultipath -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DLIBDM_API_COOKIE -Wp,-D_FORTIFY_SOURCE=2 -c -o unixware.o unixware.c
[   18s] <command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror]
[   18s] <command-line>: note: this is the location of the previous definition

Note I pass the -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 as part of make OPTFLAGS=...

@siddhesh

@mwilck
Copy link
Contributor

mwilck commented Apr 4, 2022

Well, it's not exactly an "OPTFLAG", right? Perhaps you need to patch Makefile.inc.

@marxin
Copy link
Contributor Author

marxin commented Apr 4, 2022

I think the simplest patch would be changing -Wp,-D_FORTIFY_SOURCE=2 to -D_FORTIFY_SOURCE=2. Then one would be able to unset it with U_FORTIFY_SOURCE.

@mwilck
Copy link
Contributor

mwilck commented Apr 4, 2022

Sounds ok. Would you send a patch to dm-devel (cc me & bmarzins at redhat.com)?

@marxin
Copy link
Contributor Author

marxin commented Apr 6, 2022

Sure, I've just done that.

@mwilck
Copy link
Contributor

mwilck commented Apr 12, 2022

@bmarzins , FTR: the -Wp syntax has been added by your commit 1fce669 ("multipath: Build with standard rpm cflags") a long time ago. Any idea why you were using this rather than simply -D_FORTIFY_SOURCE=2 ?

@bmarzins
Copy link
Contributor

Don't recall, and I have no objection to changing it.

@siddhesh
Copy link

Since it is rpm cflags, it may be because the default flags set in redhat-rpm-config in Fedora has the flags with the -Wp syntax. FWIW, it should be possible to unset and reset the macro with -Wp too, e.g. with -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3

@marxin
Copy link
Contributor Author

marxin commented Apr 12, 2022

I can confirm that gcc -Wp,-D_FORTIFY_SOURCE=2 -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 a.c -Werror works, but still, I would like to have a unified approach for enabling of -D_FORTIFY_SOURCE=3. So please accept my patch.

mwilck pushed a commit to openSUSE/multipath-tools that referenced this issue Apr 13, 2022
As explained here:
opensvc#29

using -Wp,-D_FORTIFY_SOURCE cannot be redefined with
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3.

Signed-off-by: Martin Liska <mliska@suse.cz>
Reviewed-by: Martin Wilck <mwilck@suse.com>
@mwilck
Copy link
Contributor

mwilck commented Apr 13, 2022

pushed to openSUSE/multipath-tools (queue). Will be included in next bunch of fixes.

@marxin
Copy link
Contributor Author

marxin commented Apr 21, 2022

@mwilck Please close this issue once the queue lands to master.

This was referenced May 3, 2022
@mwilck
Copy link
Contributor

mwilck commented May 9, 2022

It turns out that the proposed patch didn't work as intended. Updated the fix for #29 to d13d154.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants