Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 909080 - net-vpn/i2pd[i2p-hardening] warning: _FORTIFY_SOURCE redefined with gcc12 hardened _F_S=3
Summary: net-vpn/i2pd[i2p-hardening] warning: _FORTIFY_SOURCE redefined with gcc12 har...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Alexey Korepanov
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: 847148
  Show dependency tree
 
Reported: 2023-06-24 14:12 UTC by genBTC
Modified: 2024-08-25 20:27 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
i2pd build.log (i2pd-build2.log,131.72 KB, text/x-log)
2023-06-24 14:13 UTC, genBTC
Details
emerge --info of my system (emerge.info,7.32 KB, text/plain)
2024-08-18 19:40 UTC, Filip Kobierski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description genBTC 2023-06-24 14:12:13 UTC
When using gentoo-hardened with the new  fortify-source-3.patch  built into gcc-12.2.1_p20230428-r1 ,
net-vpn/i2pd package with the i2p-hardening USE flag enabled:
results in a warning about a definition redefined collision.

<command-line>: warning: "_FORTIFY_SOURCE" redefined
<built-in>: note: this is the location of the previous definition

Meaning the package has _F_S=2 hardcoded internally:
 @ CMakeLists.txt line 134 : add_definitions("-D_FORTIFY_SOURCE=2")
 @  & build.ninja (generated command)
that flag should be stripped so _F_S=3 can take effect from the gcc spec profile without conflict.
Comment 1 genBTC 2023-06-24 14:13:48 UTC
Created attachment 864560 [details]
i2pd build.log

FORTIFY_SOURCE redefined
Comment 2 gentoo-setan 2024-07-05 07:32:56 UTC
Please also attach emerge --info with the build log.

This was happening for i2pd 2.46.1 with GCC 12.

Does this happen for the current version?
Comment 3 genBTC 2024-08-18 14:55:00 UTC
yes this still happens with stable net-vpn/i2pd-2.52.0 as of August 18, 2024.
this also still happens with testing net-vpn/i2pd-2.53.1 as of today as well.
so it
should be very easy to reproduce under any hardened profile gentoo system.

[1/84] /usr/bin/x86_64-pc-linux-gnu-g++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DOPENSSL_SUPPRESS_DEPRECATED -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_NANOSLEEP=1 -D__AES__ -Dlibi2pd_EXPORTS -I/var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/build/../libi2pd -I/var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/build/../libi2pd_client -I/var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/build/../i18n -I/var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/build/../daemon  -O2 -pipe -march=x86-64-v2 -fdiagnostics-color=always -Wall -Wextra -Winvalid-pch -Wno-unused-parameter -Wno-uninitialized -std=c++17 -pipe -Wformat -Wformat-security -Werror=format-security -fstack-protector --param ssp-buffer-size=4 -maes -fPIC -fPIC -fdiagnostics-color=always -MD -MT CMakeFiles/libi2pd.dir/var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/libi2pd/Base.cpp.o -MF CMakeFiles/libi2pd.dir/var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/libi2pd/Base.cpp.o.d -o CMakeFiles/libi2pd.dir/var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/libi2pd/Base.cpp.o -c /var/tmp/portage/net-vpn/i2pd-2.53.1/work/i2pd-2.53.1/libi2pd/Base.cpp
<command-line>: warning: "_FORTIFY_SOURCE" redefined
<built-in>: note: this is the location of the previous definition
Comment 4 Filip Kobierski 2024-08-18 19:40:15 UTC
Created attachment 900597 [details]
emerge --info of my system

i2pd 2.52.0 & 2.53.1 compile fine here
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-08-18 19:48:11 UTC
(In reply to Filip Kobierski from comment #4)

Did you try grepping for _FORTIFY_SOURCE or look for the warning in the log? It's clearly still there.
Comment 6 Eli Schwartz gentoo-dev 2024-08-18 22:17:48 UTC
  if(WITH_HARDENING)
    add_definitions("-D_FORTIFY_SOURCE=2")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security -Werror=format-security")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector --param ssp-buffer-size=4")
  endif()


  if(WITH_HARDENING AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "-z relro -z now")
  endif()


We should simply never ever set this.
Comment 7 Eli Schwartz gentoo-dev 2024-08-18 22:23:34 UTC
In gentoo-historical,

commit 4af95be36ca13b36a87ccb67d20882b0368fb74e
Author:     Anthony G. Basile <blueness@gentoo.org>
AuthorDate: Thu Jan 8 17:44:46 2015
Commit:     Anthony G. Basile <blueness@gentoo.org>
CommitDate: Thu Jan 8 17:44:46 2015

    Initial commit to gentoo tree, copied from klondike's overlay
    
    (Portage version: 2.2.14/cvs/Linux x86_64, signed Manifest commit with key 0xF52D4BBA)



This version already contained the USE=i2p-hardening and it has remained there ever since -- even though the USE flag duplicates existing efforts, provides no value, and even overrides the hardening profile.
Comment 8 Larry the Git Cow gentoo-dev 2024-08-25 20:27:29 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a48dc95507286b1c1866f152d399fdee0499d8d8

commit a48dc95507286b1c1866f152d399fdee0499d8d8
Author:     Filip Kobierski <fkobi@pm.me>
AuthorDate: 2024-08-18 22:24:11 +0000
Commit:     Eli Schwartz <eschwartz@gentoo.org>
CommitDate: 2024-08-25 20:23:18 +0000

    net-vpn/i2pd: drop i2p-hardening USE flag
    
    Sam James and Eli Schwartz suggested that it should be done:
    "[the hardening] matches the defaults or makes them worse"
    No revbump as it was turned off by default.
    
    Closes: https://bugs.gentoo.org/909080
    Signed-off-by: Filip Kobierski <fkobi@pm.me>
    Closes: https://github.com/gentoo/gentoo/pull/38193
    Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>

 net-vpn/i2pd/i2pd-2.52.0.ebuild | 10 ++--------
 net-vpn/i2pd/i2pd-2.53.1.ebuild | 10 ++--------
 net-vpn/i2pd/metadata.xml       |  5 -----
 3 files changed, 4 insertions(+), 21 deletions(-)