Bug 456105 - prelink erases file-based capabilities
prelink erases file-based capabilities
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: prelink (Show other bugs)
14
All Linux
high Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
: 649972 (view as bug list)
Depends On:
Blocks: removesetuid 646481 653635
  Show dependency treegraph
 
Reported: 2008-07-21 11:36 EDT by LC Bruzenak
Modified: 2011-04-05 09:10 EDT (History)
12 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 653635 (view as bug list)
Environment:
Last Closed: 2010-11-23 18:51:46 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
prelink-xattr.patch (2.61 KB, patch)
2010-11-22 13:10 EST, Jakub Jelinek
no flags Details | Diff

  None (edit)
Description LC Bruzenak 2008-07-21 11:36:38 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.4) Gecko/20070607 Swiftweasel/2.0.0.4

Description of problem:
prelink moves the old executable out of the way, builds the new prelinked version and replaces it. This effectively removes the CAP.
I had installed file-based capabilities like this within an RPM %post scriptlet: /usr/sbin/setcap cap_audit_write+pe /usr/libexec/AuditProxy

If one of the linked libs changes, the prelink sweep will rebuild the executable and remove the CAP. At this point my rpm -V fails, since I have installed a %verifyscript:
%verifyscript
/usr/sbin/getcap /usr/libexec/AuditProxy | grep -q cap_audit_write+ep
[ $? = 1 ] && echo "CAP_AUDIT_WRITE not set" >&2 && exit 1
exit 0

More importantly, though, is that the CAP is not set and all intended actions fail at this point.

Version-Release number of selected component (if applicable):
prelink-0.4.0-3

How reproducible:
Always


Steps to Reproduce:
1.ensure compiler is installed
2.create test directory and cd there
3.echo "int main() {}" > test.c
4.cc test.c 
5.sudo /usr/sbin/setcap cap_audit_write+pe a.out
6.$ /usr/sbin/getcap a.out 
a.out = cap_audit_write+ep
7.sudo /usr/sbin/prelink -m a.out
8./usr/sbin/getcap a.out 
(nothing)

Actual Results:
The file-based CAP cap_audit_write was removed by the prelink.

Expected Results:
prelink should:
1. see if caps are available
2. check to see what CAPs are installed
3. restore those caps after prelinking

Additional info:
I will initially set this to medium, however it does pose a security issue that needs to be addressed.
Comment 1 Bug Zapper 2009-06-09 22:10:04 EDT
This message is a reminder that Fedora 9 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 9.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '9'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 9's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 9 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 2 Tomas Mraz 2009-07-09 10:54:51 EDT
Still unfixed on F11.
Comment 3 Bug Zapper 2010-04-27 08:09:23 EDT
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 4 Christian Krause 2010-06-20 10:27:24 EDT
The bug is still present in F12 and F13.
Comment 5 Bug Zapper 2010-11-04 07:50:29 EDT
This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 6 Tomas Mraz 2010-11-04 09:51:38 EDT
Still present in F14 and rawhide.
Comment 7 devzero2000 2010-11-04 11:49:56 EDT
hmm, but using prelink without "-m" don't drop file capability, if you follow
the same first example.
Comment 8 Tomas Mraz 2010-11-04 12:06:53 EDT
It does for me regardless of -m presence.
Comment 9 Jakub Jelinek 2010-11-04 12:22:58 EDT
So, should I just fgetxattr ... "security.capability" and setxattr it on the new file, or for other capabilities as well (say listxattr and iterate over attributes)?  In the latter case I guess I'd need to blacklist SELinux related acls, because those ought to be handled by using the -lselinux APIs.

Wonder what does e.g. rpm do, does it care just about SELinux context and security.capability caps, or something else too?
Comment 10 devzero2000 2010-11-04 13:04:32 EDT
(In reply to comment #8)
> It does for me regardless of -m presence.


Yes, my mistake.

With 
rpm -q --qf '%{VERSION}-%{RELEASE}\n' prelink
0.4.3-4.fc14

seems working now

/usr/sbin/setcap cap_audit_write+pe a.out
prelink a.out
getcap a.out
a.out = cap_audit_write+ep
prelink -m a.out
getcap a.out
a.out = cap_audit_write+ep

 setfacl -m u:root:rx a.out
prelink -m a.out
getfacl a.out
# file: a.out
# owner: root
# group: root
user::rwx
user:root:r-x
group::rwx
mask::rwx
other::r-x

So, the problem is closed now ?
Comment 11 Tomas Mraz 2010-11-04 13:53:39 EDT
No, what I am saying that it is still broken regardless of -m. Subsequent prelink runs probably do not rewrite the file at all.
Comment 12 Jakub Jelinek 2010-11-06 06:37:58 EDT
*** Bug 649972 has been marked as a duplicate of this bug. ***
Comment 13 Panu Matilainen 2010-11-08 01:47:34 EST
(In reply to comment #9)
> So, should I just fgetxattr ... "security.capability" and setxattr it on the
> new file, or for other capabilities as well (say listxattr and iterate over
> attributes)?  In the latter case I guess I'd need to blacklist SELinux related
> acls, because those ought to be handled by using the -lselinux APIs.
> 
> Wonder what does e.g. rpm do, does it care just about SELinux context and
> security.capability caps, or something else too?

From rpm POV those are enough currently, but you'll want to copy ACL's too if present. Rpm doesn't currently have a way to specify them through packaging, but if set by admin, prelink shouldn't strip them.
Comment 15 Jakub Jelinek 2010-11-22 13:10:55 EST
Created attachment 462093 [details]
prelink-xattr.patch

Lightly tested patch.
Comment 16 Jakub Jelinek 2010-11-22 13:31:28 EST
Test packages built in
http://koji.fedoraproject.org/scratch/jakub/task_2617107/
Comment 17 Jakub Jelinek 2010-11-23 18:51:46 EST
In prelink-0.4.4-1.fc15.

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