Bug 561379 - Kernel not blocking raw_socket with SELinux controls
Summary: Kernel not blocking raw_socket with SELinux controls
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 19
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2010-02-03 15:22 UTC by Daniel Walsh
Modified: 2013-04-05 16:54 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2013-04-05 16:54:02 UTC
Type: ---

Attachments (Terms of Use)

Description Daniel Walsh 2010-02-03 15:22:50 UTC
On Monday 01 February 2010 12:44:56 pm Jason Shaw wrote:
> > Here is what I found. Using netlabelctl, I could successfully restrict all
> > inbound/outbound network access to the system on a specific interface. I
> > could then permit only SSH into the system via allow rules associated with
> > the peer label assigned using netlabelctl unlbl.That worked great. In fact,
> > I'm really excited to explore other possibilities using netlabelctl as it
> > has many valuable possible uses.
Great, glad to hear you got everything (well, almost) working; I apologize it 
took so long :)

> > However, I found that my test app (with the allow rule below), could still
> > read and display packet data coming in on any interface even with all
> > interfaces assigned a unique peer_t using netlabelctl unlbl add. This was
> > true when no explicit allow rules were added for the test app (running in
> > myAPP_t). So while netlabelctl did require explicit allow rules for SSH to
> > send/receive data (I beleive for sshd_t), an allow rule was not required to
> > read raw data off of the interface for myAPP_t.
> > 
> > allow myApp_t self:packet_socket { create read bind ioctl };
> > 
> > My understanding is that a packet socket is read at the device driver
> >  level. As such, is it possible that the packet socket is being read before
> >  netlabelctl enforcements are taking place?
Hmm, yes, I think you've stumbled across a bug in the kernel where the LSM 
sock_rcv_skb() hook is not called for AF_PACKET.  I need to take a look and 
verify the rest of the packet families and work up a fix.

-- paul moore linux @ hp Description of problem:

Comment 1 Daniel Walsh 2010-02-03 15:23:57 UTC
I think this is a bug we need to pay attention too.  Can not prevent raw_socket from certain packets.

Comment 2 Stephen Smalley 2010-02-03 18:32:51 UTC
Last I looked, SELinux only mediated IP packet send/recv.
selinux_sock_rcv_skb bails immediately if not inet or inet6.
Outbound netfilter hooks are for ipv4 and ipv6 only.
packet socket is not the same thing as IP raw socket.

So merely changing packet/af_packet.c:run_filter() to invoke sk_filter() [which calls security_sock_rcv_skb] wouldn't cause these packets to get mediated; the SELinux hook would immediately return.

Comment 3 Paul Moore 2010-02-03 21:49:08 UTC
To elaborate a bit on the issue I think Stephen is trying to make ...

The real issue is that we likely can't rely on the packet already being parsed, i.e. skb_network_offset() isn't going to return anything useful, and without knowing that the packet is an IP packet we would have to parse the packet starting at the Ethernet header in order to get the IP information and the peer label (really only CIPSO and fallback, dealing with labeled IPsec packets here makes my head hurt due to the fact we would need to verify the AH/ESP header and then verify the SPI - basically a no-go).  I'll look at this a bit more on Friday but I'm pretty sure this is just a limitation of non AF_INET[6] sockets.

Comment 4 Bug Zapper 2010-11-03 23:10:11 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: 

Comment 6 Dave Jones 2011-10-11 18:16:25 UTC
I'm moving this bug to be against 'rawhide' so that we don't keep getting the end-of-life bugzapper comments added.

Is there any progress being made on this upstream ? Stephen, Paul ?

Comment 7 Stephen Smalley 2011-10-11 19:15:18 UTC
No one is actively pursuing adding SELinux per-packet controls for AF_PACKET sockets to my knowledge.  SELinux can control what applications can create and use such sockets, but not per-packet send/recv based on peer information.

Comment 8 Fedora End Of Life 2013-04-03 18:42:24 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

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

More information and reason for this action is here:

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