Bug 802072

Summary: SELinux deny_ptrace: Do not restrict PTRACE_TRACEME
Product: [Fedora] Fedora Reporter: Jan Kratochvil <jan.kratochvil>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 25CC: dmalcolm, dominick.grift, dwalsh, eparis, fche, gansalmon, itamar, jan.kratochvil, jonathan, jreiser, kernel-maint, kevin, ldv, madhu.chinakonda, mgrepl, mjw, mnewsome, ndevos, onestero, patrickm, pmoore, pmuldoon, rjones, roland, sdsmall, sergiodj, tsmetana, warren98103
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: kernel-3.3.2-1.fc17 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 786878 Environment:
Last Closed: 2017-12-12 10:28:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 786876, 786878    
Bug Blocks: 810973    

Description Jan Kratochvil 2012-03-10 19:47:44 UTC
+++ This bug was initially created as a clone of Bug #786878 +++

New feature coming in Fedora 17  will allow users to disable ptrace and sys_ptrace access on an SELinux system.

http://danwalsh.livejournal.com/49336.html

[...]

--- Additional comment from eparis on 2012-03-07 00:13:27 CET ---
[...]
Jan is right, it would make more sense to allow one to trace their children.  But such permissions will require a kernel change.  I assume that's what you meant.  We can probably steal the similar logic from YAMA...

Note to self for implementation:
Requires a new policy capability so we check old ptrace permission if policy doesn't yet support the new PTRACE_CHILD permission.  The allow/deny unknown work is only adequate when restricting thing further (aka new permission) instead of changing the semantics of or reducing the scope of current permissions.
[...]
--- Additional comment from sds.gov on 2012-03-07 14:12:14 CET ---
[...]
It would be significantly simpler to just change the existing selinux_ptrace_traceme() hook to use a different permission (if the corresponding policy capability was defined) so that it can be distinguished in policy.  That seems to be all they need, not the general ability to PTRACE_ATTACH to an arbitrary descendant.

Comment 1 Josh Boyer 2012-03-12 13:38:27 UTC
*** Bug 802065 has been marked as a duplicate of this bug. ***

Comment 2 Niels de Vos 2012-04-11 10:26:25 UTC
A proposed patch seems to get included in Rawhide (http://lists.fedoraproject.org/pipermail/kernel/2012-April/003732.html). No confirmation on F-17 yet?

Comment 3 Josh Boyer 2012-04-11 12:23:07 UTC
(In reply to comment #2)
> A proposed patch seems to get included in Rawhide
> (http://lists.fedoraproject.org/pipermail/kernel/2012-April/003732.html). No
> confirmation on F-17 yet?

There now.  Will be in the next F17 update.  Bodhi will leave a comment in the bug when it's available in a repo.

Comment 4 Fedora Update System 2012-04-16 19:10:13 UTC
kernel-3.3.2-1.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/kernel-3.3.2-1.fc17

Comment 5 Fedora Update System 2012-04-16 21:56:49 UTC
Package kernel-3.3.2-1.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing kernel-3.3.2-1.fc17'
as soon as you are able to, then reboot.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-5994/kernel-3.3.2-1.fc17
then log in and leave karma (feedback).

Comment 6 Jan Kratochvil 2012-04-17 11:40:54 UTC
[root@f17 ~]# cat /proc/version 
Linux version 3.3.2-1.fc17.x86_64 (mockbuild.fedoraproject.org) (gcc version 4.7.0 20120322 (Red Hat 4.7.0-1) (GCC) ) #1 SMP Fri Apr 13 20:23:49 UTC 2012
[root@f17 ~]# getsebool deny_ptrace
deny_ptrace --> on
[root@f17 ~]# gdb -q true -ex run
Reading symbols from /usr/bin/true...(no debugging symbols found)...done.
Starting program: /usr/bin/true 
Cannot create process: Permission denied
warning: the SELinux boolean 'deny_ptrace' is enabled, you can disable this process attach protection by: (gdb) shell sudo setsebool deny_ptrace=0
During startup program exited with code 127.
Missing separate debuginfos, use: debuginfo-install coreutils-8.15-6.fc17.x86_64
(gdb) q

Comment 7 Josh Boyer 2012-04-17 14:27:50 UTC
Eric, any thoughts on Jan's issues?

Comment 8 Eric Paris 2012-04-17 15:02:31 UTC
Needs a policy update to make use of the kernel change.  Dan, do we want to try it?

Comment 9 Fedora Update System 2012-04-22 04:14:49 UTC
kernel-3.3.2-1.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Jan Kratochvil 2012-04-22 19:28:22 UTC
It is not yet CLOSED as discussed here.

Comment 11 Josh Boyer 2012-04-23 14:13:19 UTC
The kernel part is done at least.  Reassigning to selinux-policy per comment #8.

Comment 12 Jan Kratochvil 2012-05-03 18:05:38 UTC
ping

Comment 13 Daniel Walsh 2012-05-04 13:16:02 UTC
Still working on it, waiting for F17 to be released.

Comment 14 Jan Kratochvil 2012-05-04 13:23:12 UTC
I expected the goal is to fix bugs _before_ a Fedora release.

Comment 15 Josh Boyer 2012-05-04 13:30:36 UTC
(In reply to comment #14)
> I expected the goal is to fix bugs _before_ a Fedora release.

Technically, it's not going to be a bug that anyone hits by default.  The deny_ptrace stuff defaults to off at this point in the release.

Comment 16 Daniel Walsh 2012-05-04 13:35:49 UTC
First we are in freeze, and I consider this an enhancement not a bug.  The deny_ptrace it turned off by default. Since the definition of deny_ptrace was to disable all ptrace this is not a bug. We have to figure out what the best mechanism for allowing a user to secure his machine.  We need a three way mechanism to setup the system.

Don't deny user ptrace (Same default as F16).
Deny ptrace of processes but allow ptrace of children.
Deny all Ptrace.

If I as the administrator decide I want no ptrace on my machine, I should be able to state this.  I am thinking about adding another boolean which would allow ptrace child.

Comment 17 Kevin Kofler 2012-05-04 19:45:36 UTC
> Deny ptrace of processes but allow ptrace of children.

"of children" is not sufficient. As explained on the mailing list, you need to also support the YAMA registration API for DrKonqi, WINE etc. to work.

Comment 18 Daniel Walsh 2012-05-04 20:09:03 UTC
Once the kernel supports it we will support it.

Comment 19 Josh Boyer 2012-05-04 20:39:05 UTC
We're not going to enable YAMA.

Comment 20 Kevin Kofler 2012-05-04 22:20:37 UTC
You need to support something equivalent or deny_ptrace is just plain not usable.

Comment 21 Kevin Kofler 2012-05-04 22:21:14 UTC
(and I don't care whether it's implemented by reusing YAMA or by doing your own thing in the SELinux code)

Comment 22 Fedora End Of Life 2013-07-04 06:17:01 UTC
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. 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 '17'.

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 17'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 17 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, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

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.

Comment 23 Jan Kurik 2015-07-15 15:10:53 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 23 development cycle.
Changing version to '23'.

(As we did not run this process for some time, it could affect also pre-Fedora 23 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 23 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora23

Comment 24 Warren Lewis 2015-08-30 21:35:33 UTC
Just a ping too see if ptrace child was implemented, I'm trying to get chrome running properly with my user set to staff_u and it wanting sys_ptrace (hopefully only on it's child processes).

Comment 25 Paul Moore 2016-03-28 01:13:58 UTC
The ptrace_child code has been removed from the kernel and we should probably remove the process:ptrace_child permission from policy - Miroslav?

Comment 26 Jan Kurik 2016-07-26 04:44:37 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.

Comment 27 Fedora Admin XMLRPC Client 2016-09-27 15:03:09 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 28 Fedora End Of Life 2017-11-16 19:32:01 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. 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 EOL if it remains open with a Fedora  'version'
of '25'.

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.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 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, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

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.

Comment 29 Fedora End Of Life 2017-12-12 10:28:53 UTC
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.