Bug 1377249 - -fprofile-generate leads in root-owned files
Summary: -fprofile-generate leads in root-owned files
Keywords:
Status: CLOSED INSUFFICIENT_DATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-19 09:51 UTC by Harald Reindl
Modified: 2016-10-12 13:33 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-12 13:33:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Harald Reindl 2016-09-19 09:51:31 UTC
i am trying to use profile-guided-optimization for a PHP build
"rpmbuild -bb php.spec" is called as restricted user

make %{?_smp_mflags} prof-gen
/rpmbuild/PHP-PGO/profile.sh $PWD
make clean
make %{?_smp_mflags} prof-use

op-vectorize -ftree-slp-vectorize -ftree-vectorize -funroll-loops -funswitch-loops -minline-all-stringops -Wno-pointer-sign -Wno-stack-protector -fPIC -Wa,--noexecstack -fvisibility=hidden -fprofile-generate  -c /home/builduser/rpmbuild/BUILD/php-7.0.11/ext/date/lib/unixtime2tm.c -o ext/date/lib/unixtime2tm.lo
Assembler messages:
Fatal error: can't create ext/date/.libs/php_date.o: Permission denied
Assembler messages:
Fatal error: can't create ext/date/lib/.libs/timelib.o: Permission denied
Assembler messages:
Fatal error: can't create ext/date/lib/.libs/dow.o: Permission denied

how is it possible

/rpmbuild/BUILD/php-7.0.11/ext/standard/.libs:
insgesamt 572K
drwxr-xr-x 2 root      root      4,0K 2016-09-19 11:40 .
drwxr-xr-x 4 builduser builduser 4,0K 2016-09-19 11:40 ..
-rw-r--r-- 1 root      root       35K 2016-09-19 11:45 array.gcda
-rw-r--r-- 1 root      root      5,5K 2016-09-19 11:45 assert.gcda
-rw-r--r-- 1 root      root      2,5K 2016-09-19 11:45 base64.gcda
-rw-r--r-- 1 root      root       22K 2016-09-19 11:45 basic_functions.gcda
-rw-r--r-- 1 root      root      5,4K 2016-09-19 11:45 browscap.gcda
-rw-r--r-- 1 root      root      1,6K 2016-09-19 11:45 crc32.gcda
-rw-r--r-- 1 root      root      2,7K 2016-09-19 11:45 credits.gcda
-rw-r--r-- 1 root      root      2,4K 2016-09-19 11:45 crypt_blowfish.gcda

Comment 1 Jonathan Wakely 2016-09-19 10:41:15 UTC
GCC has not way to become root, so this must be an issue with rpmbuild or your environment.

Comment 2 Harald Reindl 2016-09-19 10:44:59 UTC
i thought so too

in fact it does and that sounds like something is running with suid in case of profile guided optimization because when %pgo_build is 0 all is fine

# build php with 'profile-guided-optimization' when enabled
%if %pgo_build
 echo "PROFILE-GUIDED-OPTIMIZATION: Stage 1"
 make %{?_smp_mflags} prof-gen
 /rpmbuild/PHP-PGO/profile.sh $PWD
 make clean
 echo "PROFILE-GUIDED-OPTIMIZATION: Stage 2"
 make %{?_smp_mflags} prof-use
%else
 make %{?_smp_mflags}
%endif

Comment 3 Jakub Jelinek 2016-09-19 14:55:49 UTC
The *.gcda files aren't written by gcc, but by the application you're testing (when compiled/linked with -fprofile-generate).  It uses whatever uid the process has.  Perhaps you are dlopening your -fprofile-generate built library into some suid app or something similar?
In any case, there is nothing that can be done about it on the gcc side.

Comment 4 Harald Reindl 2016-09-19 16:08:20 UTC
while i have no idea why this is currently not reproduceable and all seems to working fine without any changes in the php.spec or involved scripts there where *in fact* also non-gcda files like .o owned by root and the whole process is started in a ssh session with a restricted user

very strange and that it stopped with this behavior without knowing why don't make me terrible happy - the "don't know why" part especially


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