Bug 456105 - prelink erases file-based capabilities
Summary: prelink erases file-based capabilities
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: prelink
Version: 14
Hardware: All
OS: Linux
high
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 649972 (view as bug list)
Depends On:
Blocks: removesetuid 646481 653635
TreeView+ depends on / blocked
 
Reported: 2008-07-21 15:36 UTC by LC Bruzenak
Modified: 2011-04-05 13:10 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 653635 (view as bug list)
Environment:
Last Closed: 2010-11-23 23:51:46 UTC
Type: ---
Embargoed:


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

Description LC Bruzenak 2008-07-21 15:36:38 UTC
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-10 02:10:04 UTC
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 14:54:51 UTC
Still unfixed on F11.

Comment 3 Bug Zapper 2010-04-27 12:09:23 UTC
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 14:27:24 UTC
The bug is still present in F12 and F13.

Comment 5 Bug Zapper 2010-11-04 11:50:29 UTC
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 13:51:38 UTC
Still present in F14 and rawhide.

Comment 7 devzero2000 2010-11-04 15:49:56 UTC
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 16:06:53 UTC
It does for me regardless of -m presence.

Comment 9 Jakub Jelinek 2010-11-04 16:22:58 UTC
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 17:04:32 UTC
(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 17:53:39 UTC
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 10:37:58 UTC
*** Bug 649972 has been marked as a duplicate of this bug. ***

Comment 13 Panu Matilainen 2010-11-08 06:47:34 UTC
(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 18:10:55 UTC
Created attachment 462093 [details]
prelink-xattr.patch

Lightly tested patch.

Comment 16 Jakub Jelinek 2010-11-22 18:31:28 UTC
Test packages built in
http://koji.fedoraproject.org/scratch/jakub/task_2617107/

Comment 17 Jakub Jelinek 2010-11-23 23:51:46 UTC
In prelink-0.4.4-1.fc15.


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