Bug 602821 - aiccu policy is incomplete
Summary: aiccu policy is incomplete
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 13
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-10 20:12 UTC by Laurent Rineau
Modified: 2010-06-23 17:49 UTC (History)
3 users (show)

Fixed In Version: selinux-policy-3.7.19-28.fc13
Clone Of:
Environment:
Last Closed: 2010-06-23 17:49:10 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Output of ausearch that shows the corresponding AVCs (93.68 KB, text/plain)
2010-06-10 20:12 UTC, Laurent Rineau
no flags Details
Aiccu redone (5.61 KB, patch)
2010-06-11 07:51 UTC, Dominick Grift
no flags Details | Diff
aiccu re (7.14 KB, patch)
2010-06-11 09:29 UTC, Dominick Grift
no flags Details | Diff
Output of "ausearch -m avc -ts recent" after "service aiccu restart" (selinux is permissive, and all local modules are disabled) (40.25 KB, text/plain)
2010-06-11 11:14 UTC, Laurent Rineau
no flags Details

Description Laurent Rineau 2010-06-10 20:12:40 UTC
Created attachment 423031 [details]
Output of ausearch that shows the corresponding AVCs

Description of problem:

In order to have an IPv6 connectivity using a Sixxs tunnel, I want to trigger the services aiccu and radvd from NetworkManager dispatcher. I have the following script:

$ cat /etc/NetworkManager/dispatcher.d/20-aiccu
#!/bin/sh

if [ "$2" = "up" ] ; then
        /sbin/service aiccu start && /sbin/service radvd start || :
fi

if [ "$2" = "down" ] ; then
        /sbin/service radvd stop || :
        /sbin/service aiccu stop || :
fi


It works if SELinux is in permissive move, but gives AVCs (in enforcing mode, aiccu does not behave correctly). With audit2allow, I have created the following local.te module:
==================================================================
module local 1.1;

require {
        type insmod_exec_t;
        type modules_conf_t;
        type urandom_device_t;
        type syslogd_t;
        type ifconfig_exec_t;
        type sysfs_t;
        type port_t;
        type modules_dep_t;
        type shell_exec_t;
        type bin_t;
        type devlog_t;
        type proc_t;
        type random_device_t;
        type console_device_t;
        type modules_object_t;
        type aiccu_t;
        class tun_socket create;
        class chr_file { read open };
        class capability { net_admin sys_module sys_tty_config };
        class tcp_socket { write name_connect connect shutdown read create };
        class file { execute read execute_no_trans getattr open };
        class sock_file write;
        class netlink_route_socket { setopt nlmsg_write read bind create nlmsg_read write getattr };
        class lnk_file read;
        class unix_dgram_socket { write create connect sendto };
        class udp_socket { write read create connect };
        class dir read;
}

#============= aiccu_t ==============
allow aiccu_t bin_t:lnk_file read;
allow aiccu_t devlog_t:sock_file write;
allow aiccu_t ifconfig_exec_t:file { read getattr open execute execute_no_trans };
allow aiccu_t insmod_exec_t:file { read getattr open execute execute_no_trans };
allow aiccu_t modules_conf_t:dir read;
allow aiccu_t modules_conf_t:file { read getattr open };
allow aiccu_t modules_dep_t:file { read getattr open };
allow aiccu_t modules_object_t:file { read open };
allow aiccu_t port_t:tcp_socket name_connect;
allow aiccu_t proc_t:file { read getattr open };
allow aiccu_t random_device_t:chr_file read;
allow aiccu_t self:capability net_admin;
allow aiccu_t self:netlink_route_socket { setopt nlmsg_write read bind create nlmsg_read write getattr };
allow aiccu_t self:tcp_socket { read write create connect shutdown };
allow aiccu_t self:tun_socket create;
allow aiccu_t self:udp_socket { write read create connect };
allow aiccu_t self:unix_dgram_socket { write create connect };
allow aiccu_t shell_exec_t:file { read execute open getattr execute_no_trans };
allow aiccu_t sysfs_t:file { read getattr open };
allow aiccu_t syslogd_t:unix_dgram_socket sendto;
#!!!! This avc can be allowed using the boolean 'global_ssp'

allow aiccu_t urandom_device_t:chr_file { read open };

allow aiccu_t console_device_t:chr_file open;
allow aiccu_t modules_object_t:file getattr;
allow aiccu_t self:capability { sys_module sys_tty_config };

==================================================================

With that local.te module compiled and loaded, I can toggle the network off and on with NetworkManager and I get the correct IPv6 connectivity.

With the help of  
Dominick Grift <domg472> on selinux.org, my local module has been shrunk to:

  sysnet_domtrans_ifconfig(aiccu_t)
  modutils_domtrans_insmod(aiccu_t)
  corecmd_exec_shell(aiccu_t)
  kernel_read_system_state(aiccu_t)


Version-Release number of selected component (if applicable):
  selinux-policy-3.7.19-23.fc13.noarch
  selinux-policy-targeted-3.7.19-23.fc13.noarch


How reproducible: reproductible


Steps to Reproduce:
0. Have a Sixxs account, and aiccu configured.
1. Create /etc/NetworkManager/dispatcher.d/20-aiccu (see above).
2. cnetworkmanager -o off; cnetworkmanager -o on
3. check the AVCs 
  
Actual results:
 - With "sudo service aiccu restart", aiccu launched from the unconfined root user, it works.
 - Without local.pp loaded, aiccu does not work in enforcing mode (and lots of AVCs in permissive mode).
 - With the local.pp described above, all is right.

Expected results:
  - aiccu should be able to run in its confined domain.

Additional info:
  I have attached the full AVC logs. I got them in permissive mode, without any local module, using a shell one-liner like that one:

cnetworkmanager -o off; DATE=`date '+%H:%M'`; cnetworkmanager -o on; sleep 10; sudo /sbin/ausearch -ts $DATE -m avc

Comment 1 Laurent Rineau 2010-06-10 20:35:49 UTC
I have grepped in the source code of aiccu-2007.01.15-7.fc13, and I have verified that the four lines Dominick Grift are needed:

corecmd_exec_shell(aiccu_t)
  -> because aiccu uses system(3).
sysnet_domtrans_ifconfig(aiccu_t)
  -> because aiccu calls "ip" several times.
kernel_read_system_state(aiccu_t)
  -> because aiccu checks /proc/net/if_inet6
modutils_domtrans_insmod(aiccu_t)
  -> because aiccu tries to "modprobe ipv6" if /proc/net/if_inet6 is missing.

Comment 2 Laurent Rineau 2010-06-10 20:45:23 UTC
Additionally, as /etc/aiccu.conf can contain passwords, would it be possible that this file is labeled system_u:object_r:aiccu_conf_t so that confined domains with files_read_etc_files(foobar_t) cannot read it and only the domain aiccu_t can read it?

Comment 3 Dominick Grift 2010-06-10 21:16:29 UTC
(In reply to comment #2)
> Additionally, as /etc/aiccu.conf can contain passwords, would it be possible
> that this file is labeled system_u:object_r:aiccu_conf_t so that confined
> domains with files_read_etc_files(foobar_t) cannot read it and only the domain
> aiccu_t can read it?    

Great bug report. Thanks.

Labeling configuration files is not only a good idea because of any sensitive information it may contain, but it is also required for confined administration (RBAC): aiccu_admin

Comment 4 Miroslav Grepl 2010-06-11 07:18:57 UTC
(In reply to comment #1)
> I have grepped in the source code of aiccu-2007.01.15-7.fc13, and I have
> verified that the four lines Dominick Grift are needed:
> 
> corecmd_exec_shell(aiccu_t)
>   -> because aiccu uses system(3).
> sysnet_domtrans_ifconfig(aiccu_t)
>   -> because aiccu calls "ip" several times.
> kernel_read_system_state(aiccu_t)
>   -> because aiccu checks /proc/net/if_inet6
> modutils_domtrans_insmod(aiccu_t)
>   -> because aiccu tries to "modprobe ipv6" if /proc/net/if_inet6 is missing.    

Thanks for that. I am fine with it.

But I am looking into raw audit and I am seeing some suspect AVC messages. At least

allow aiccu_t self:capability net_admin;
allow aiccu_t port_t:tcp_socket name_connect;
allow aiccu_t syslogd_t:unix_dgram_socket sendto;
allow aiccu_t devlog_t:sock_file write;
...
...

Could you try 

# service aiccu restart
# ausearch -m avc -ts recent

Thanks for testing.

Comment 5 Dominick Grift 2010-06-11 07:51:28 UTC
Created attachment 423164 [details]
Aiccu redone

Enclosed is "Aiccu redone"

Note: I have removed files_read_etc_files() and domain_use_interactive_fds(). Aiccu may need this access after all but i would like confirmation of that.

Comment 6 Dominick Grift 2010-06-11 08:27:16 UTC
(In reply to comment #4)
> (In reply to comment #1)
> > I have grepped in the source code of aiccu-2007.01.15-7.fc13, and I have
> > verified that the four lines Dominick Grift are needed:
> > 
> > corecmd_exec_shell(aiccu_t)
> >   -> because aiccu uses system(3).
> > sysnet_domtrans_ifconfig(aiccu_t)
> >   -> because aiccu calls "ip" several times.
> > kernel_read_system_state(aiccu_t)
> >   -> because aiccu checks /proc/net/if_inet6
> > modutils_domtrans_insmod(aiccu_t)
> >   -> because aiccu tries to "modprobe ipv6" if /proc/net/if_inet6 is missing.    
> 
> Thanks for that. I am fine with it.
> 
> But I am looking into raw audit and I am seeing some suspect AVC messages. At
> least
> 
> allow aiccu_t self:capability net_admin;

That is "ip" but i also see it for comm="aiccu" so we may indeed need it.

> allow aiccu_t port_t:tcp_socket name_connect;

This port should be labelled: (tcp/udp:3874)

sixxsconfig

http://www.pc-library.com/ports/tcp-udp-port/3874/

And then i guess aiccu_t need to name_connect tp sixxsconfig_port_t tcp ports

> allow aiccu_t syslogd_t:unix_dgram_socket sendto;
> allow aiccu_t devlog_t:sock_file write;

Looks like this is indeed for comm="aiccu" so i guess we should also add:

logging_send_syslog_msg(aiccu_t)

Comment 7 Miroslav Grepl 2010-06-11 08:33:21 UTC
(In reply to comment #6)
> (In reply to comment #4)
> > (In reply to comment #1)
> > > I have grepped in the source code of aiccu-2007.01.15-7.fc13, and I have
> > > verified that the four lines Dominick Grift are needed:
> > > 
> > > corecmd_exec_shell(aiccu_t)
> > >   -> because aiccu uses system(3).
> > > sysnet_domtrans_ifconfig(aiccu_t)
> > >   -> because aiccu calls "ip" several times.
> > > kernel_read_system_state(aiccu_t)
> > >   -> because aiccu checks /proc/net/if_inet6
> > > modutils_domtrans_insmod(aiccu_t)
> > >   -> because aiccu tries to "modprobe ipv6" if /proc/net/if_inet6 is missing.    
> > 
> > Thanks for that. I am fine with it.
> > 
> > But I am looking into raw audit and I am seeing some suspect AVC messages. At
> > least
> > 
> > allow aiccu_t self:capability net_admin;
> 
> That is "ip" but i also see it for comm="aiccu" so we may indeed need it.
> 
> > allow aiccu_t port_t:tcp_socket name_connect;
> 
> This port should be labelled: (tcp/udp:3874)
> 
> sixxsconfig
> 
> http://www.pc-library.com/ports/tcp-udp-port/3874/
> 
> And then i guess aiccu_t need to name_connect tp sixxsconfig_port_t tcp ports
> 
> > allow aiccu_t syslogd_t:unix_dgram_socket sendto;
> > allow aiccu_t devlog_t:sock_file write;
> 
> Looks like this is indeed for comm="aiccu" so i guess we should also add:
> 
> logging_send_syslog_msg(aiccu_t)    

Yes :).

Comment 8 Dominick Grift 2010-06-11 08:52:35 UTC
Yet looking from that perspective there should be even more. I will submit a patch with what i suspect may also be needed.

Comment 9 Dominick Grift 2010-06-11 09:29:21 UTC
Created attachment 423188 [details]
aiccu re

This might look more like it.

Comment 10 Miroslav Grepl 2010-06-11 10:33:45 UTC
Thanks Dominick. It looks better. Only

allow aiccu_t self:unix_dgram_socket create_stream_socket_perms;

can be removed. It is a part of logging_send_syslog_msg().

Comment 11 Laurent Rineau 2010-06-11 11:14:24 UTC
Created attachment 423242 [details]
Output of "ausearch -m avc -ts recent" after "service aiccu restart" (selinux is permissive, and all local modules are disabled)

Comment 12 Laurent Rineau 2010-06-11 11:25:32 UTC
(In reply to comment #4)
> # service aiccu restart
> # ausearch -m avc -ts recent
> 
> Thanks for testing.    

Hi, thank you for spending time on this bug.

I have attached what you asked. It might be redundant with the first attachment of this bug (attachment #423031 [details]).

Comment 13 Laurent Rineau 2010-06-11 11:30:34 UTC
(In reply to comment #4)
> # service aiccu restart
> # ausearch -m avc -ts recent
> 
> Thanks for testing.    

Hi, thank you for spending time on this bug.

I have attached what you asked. It might be redundant with the first attachment of this bug (attachment #423031 [details]).

Comment 14 Miroslav Grepl 2010-06-14 09:29:45 UTC
Fixed in selinux-policy-3.7.19-28.fc13

Comment 15 Fedora Update System 2010-06-14 19:30:38 UTC
selinux-policy-3.7.19-28.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/selinux-policy-3.7.19-28.fc13

Comment 16 Fedora Update System 2010-06-15 16:00:39 UTC
selinux-policy-3.7.19-28.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/selinux-policy-3.7.19-28.fc13

Comment 17 Laurent Rineau 2010-06-16 09:04:25 UTC
After the upgrade to selinux-policy-3.7.19-28.fc13:
  sudo semodule -r myaiccu
  sudo service aiccu restart
and no AVC.

Same after NetworkManager toggled to OFF then ON (remember my aiccu service is launched by NM-dispatcher).

As far as I am concerned, the bug is fixed. Thank you all.

Comment 18 Fedora Update System 2010-06-23 17:47:33 UTC
selinux-policy-3.7.19-28.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.


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