Bug 1198917 - named triggering AVC denials when attempting to bind to specific source ports
Summary: named triggering AVC denials when attempting to bind to specific source ports
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-05 05:29 UTC by Rob Foehl
Modified: 2016-10-06 13:58 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-02 09:45:21 UTC
Type: Bug


Attachments (Terms of Use)

Description Rob Foehl 2015-03-05 05:29:52 UTC
Description of problem:

Similar to the report in bug #1103439 for RHEL 6, named on both Fedora 20 and 21 triggers AVC denials when trying to bind to specific source ports, particularly these:

1935 2605 4321 4444 5546 8554 8610 8611 8612 8613 8614

These (silent) denials manifest themselves as log entries like this:

Mar 04 23:32:54 xxx named[24257]: dispatch 0x7fe27c091790: open_socket(0.0.0.0#2605) -> permission denied: continuing

...for which the associated AVC looked like this:

type=AVC msg=audit(1425529974.811:8056): avc:  denied  { name_bind } for  pid=24261 comm="named" src=2605 scontext=system_u:system_r:named_t:s0 tcontext=system_u:object_r:bgp_port_t:s0 tclass=udp_socket permissive=0
type=SYSCALL msg=audit(1425529974.811:8056): arch=c000003e syscall=49 success=no exit=-13 a0=20d a1=7fe284398460 a2=10 a3=7fe284398248 items=0 ppid=1 pid=24261 auid=4294967295 uid=53 gid=53 euid=53 suid=53 fsuid=53 egid=53 sgid=53 fsgid=53 tty=(none) ses=4294967295 comm="named" exe="/usr/sbin/named" subj=system_u:system_r:named_t:s0 key=(null)

Several comments in the other bug suggest that this is or was fixed in Fedora or upstream, but this does not appear to be the case.  I'm opening this bug specifically to cover the issue present in Fedora.


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

selinux-policy-3.13.1-105.3.fc21.noarch
selinux-policy-targeted-3.13.1-105.3.fc21.noarch


Expected results:

named should be able to bind to any available source port >1024 without restriction.  A comment on the other bug implied this was the intended behavior in Fedora, which suggests there may be a policy conflict.

Comment 1 Miroslav Grepl 2015-03-18 09:31:01 UTC
#============= named_t ==============

#!!!! This avc has a dontaudit rule in the current policy
allow named_t bgp_port_t:udp_socket name_bin

Did you turn dontaudit rules off?

The point is we allow "bind" to all unreserved ports.

Comment 2 Rob Foehl 2015-03-18 14:13:18 UTC
Okay, since the other bug was closed for the same stated reason and later reopened after the issue was reproduced:

The policy does not do what you think.  I turned off dontaudit rules temporarily to demonstrate that these:

Mar 16 12:02:27 xxx named[867]: dispatch 0x7fbaf48b3760: open_socket(0.0.0.0#4444) -> permission denied: continuing
Mar 16 12:02:35 xxx named[867]: dispatch 0x7fbaf48b8700: open_socket(0.0.0.0#4444) -> permission denied: continuing
Mar 16 12:13:25 xxx named[867]: dispatch 0x7fbad4019810: open_socket(0.0.0.0#4444) -> permission denied: continuing
Mar 16 16:58:55 xxx named[867]: dispatch 0x7fbad4016d30: open_socket(0.0.0.0#8613) -> permission denied: continuing
Mar 16 23:35:48 xxx named[867]: dispatch 0x7fbad4017350: open_socket(0.0.0.0#8613) -> permission denied: continuing
Mar 17 19:12:49 xxx named[867]: dispatch 0x7fbaf48b7ac0: open_socket(::#4321) -> permission denied: continuing
Mar 17 21:08:14 xxx named[867]: dispatch 0x7fbaf48b3760: open_socket(0.0.0.0#4444) -> permission denied: continuing
Mar 17 22:58:51 xxx named[867]: dispatch 0x7fbaf48b74a0: open_socket(0.0.0.0#8613) -> permission denied: continuing
Mar 18 00:49:01 xxx named[867]: dispatch 0x7fbaf48b49c0: open_socket(0.0.0.0#4321) -> permission denied: continuing

...are in fact caused by SELinux.

All of those occurred with dontaudit rules enabled, as did the ~100 others between these and the earlier entry in this bug.  The system that produced these isn't very busy, but I have others where the problem is far worse -- thousands of denials per day.

It's also not limited to the single rule you listed above.  Rather, as stated in bug #1103439 by several people, it's all of these ports:

╶➤ journalctl -lu named |perl -lne 'next unless /open_socket/; /#(\d+)\)/; $x{$1}++; END { print join(" ", sort keys %x) }'
1935 2605 4321 4444 5546 8554 8610 8611 8612 8613 8614

named is not allowed to bind to these ports by the current policy.  Multiple Red Hat employees have now stated that it should be allowed, yet this issue is present in every current supported Fedora, RHEL, and CentOS release, and has been reproduced by at least one other Red Hat employee.

The point is, this is is a bug.  Full stop.

Comment 3 Miroslav Grepl 2015-04-09 16:05:55 UTC
That was the idea. To not allow bind these reserved port type and force to bind unreserved port type.

But yes this is not correct way how to handle it and we should allow bind any UDP port > 1024.

Comment 4 Fedora End Of Life 2015-11-04 15:29:50 UTC
This message is a reminder that Fedora 21 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 21. 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 '21'.

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 21 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 5 Fedora End Of Life 2015-12-02 09:45:26 UTC
Fedora 21 changed to end-of-life (EOL) status on 2015-12-01. Fedora 21 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.

Comment 6 ilmostro7 2016-10-06 13:49:33 UTC
So, this bug was closed automatically by the system as EOL for the relevant Fedroa version.  However, there is no resolution to this, nor a follow-up to another place where this is tracked.  I can observe these denials on a RHEL7.3 Beta system as of this date.

Comment 7 ilmostro7 2016-10-06 13:58:28 UTC
One possible candidate for the status tracking is https://bugzilla.redhat.com/show_bug.cgi?id=1312972


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