isdn and script problem
Hi!
this time I write rules to use isdn with SELinux. The rules for isdnlog and isdnctrl are additional.
I've follow 2 problems:
1.
I add entries for ippp to net_contexts and types/network.te. The entries based on the eth0-entries and the patch patch_ifippp0 contains this changes.
I don't know how can I garant user_r, sysadm_r and system_r access to the network interfaces. I think follow rule is not the way to go
allow netmsg_t netif_t:netif { tcp_recv udp_recv };
This are the correspond log messages:
Sep 4 15:13:09 max kernel: avc: denied { udp_recv } for
saddr=192.76.144.66 source=17664 daddr=213.6.81.177 dest=244 netif=ippp0
scontext=system_u:object_r:netmsg_t tcontext=system_u:object_r:netif_t
tclass=netif
Sep 4 15:13:09 max kernel: avc: denied { tcp_recv } for
saddr=81.88.35.41 source=17664 daddr=213.6.81.177 dest=44 netif=ippp0
scontext=system_u:object_r:netmsg_t tcontext=system_u:object_r:netif_t
tclass=netif2.
The ipppd runs at start and stop a shell script. This script runs in the ipppd_t domain and start different programms most with can_exec.
. Two of this route and ifconfig runs via daemon_auto_trans(ipppd_t,
..., ....) in his own domain.
After this I recive this log entry:
Sep 4 15:13:30 max kernel: avc: denied { read } for pid=1991
exe=/sbin/ifconfig path=/etc/ppp/pap-secrets dev=03:0a ino=102578
scontext=system_u:system_r:ifconfig_t
tcontext=system_u:object_r:pppd_secret_t tclass=file
And I don't understand why needs ifconfig access to the ppp password
files?
I think something is wrong with my types and types transitions and I don't
found what.I'll by happy about all coments.
Thanks!
Carsten
net_contexts renamed from original/net_contexts +1 -0
@@ -53,6 +53,7 @@ netifcon eth0 system_u:object_r:netif_eth0_t system_u:object_r:netmsg_eth0_t netifcon eth1 system_u:object_r:netif_eth1_t system_u:object_r:netmsg_eth1_t netifcon eth2 system_u:object_r:netif_eth2_t system_u:object_r:netmsg_eth2_t +netifcon ippp0 system_u:object_r:netif_ippp0_t system_u:object_r:netmsg_ippp0_t netifcon ipsec0 system_u:object_r:netif_ipsec0_t system_u:object_r:netmsg_ipsec0_t netifcon ipsec1 system_u:object_r:netif_ipsec1_t system_u:object_r:netmsg_ipsec1_t netifcon ipsec2 system_u:object_r:netif_ipsec2_t system_u:object_r:netmsg_ipsec2_t
network.te renamed from original/types/network.te +4 -0
@@ -54,6 +54,7 @@ type netif_eth1_t, netif_type; type netif_eth2_t, netif_type; type netif_lo_t, netif_type; +type netif_ippp0_t, netif_type; type netif_ipsec0_t, netif_type; type netif_ipsec1_t, netif_type;
@@ -69,6 +70,7 @@ type netmsg_eth1_t, netmsg_type; type netmsg_eth2_t, netmsg_type; type netmsg_lo_t, netmsg_type; +type netmsg_ippp0_t, netmsg_type; type netmsg_ipsec0_t, netmsg_type; type netmsg_ipsec1_t, netmsg_type;
@@ -116,6 +118,8 @@ allow netmsg_lo_t node_lo_t:node { tcp_recv udp_recv rawip_recv }; allow netmsg_lo_t node_t:node { tcp_recv udp_recv rawip_recv }; allow netmsg_lo_t netif_lo_t:netif { tcp_recv udp_recv rawip_recv }; +allow netmsg_ippp0_t node_t:node { tcp_recv udp_recv rawip_recv }; +allow netmsg_ippp0_t netif_ippp0_t:netif { tcp_recv udp_recv rawip_recv }; allow netmsg_ipsec0_t node_t:node { tcp_recv udp_recv rawip_recv }; allow netmsg_ipsec0_t netif_ipsec0_t:node { tcp_recv udp_recv rawip_recv }; allow netmsg_ipsec1_t node_t:node { tcp_recv udp_recv rawip_recv };
#
# This policy is for isdnlog
#
# Author : Carsten Grohmann <[email protected]>
#
# $Id$
#
# License : GPL
#
# last change: 28. August 2002 # # state : EXPERIMENTAL -> NOT complete and NOT testet # # Hints : # - 20020726 rename isdnlog_var_log_t to var_log_isdnlog_t # rename isdnlog_var_lock_t to var_lock_isdnlog_t # rename isdnlock_var_run_t to var_run_isdnlock_t # use daemon_domain # # Enhancements/Corrections: # -
# General declarations
######################
daemon_domain(isdnlog)
# type for isdn log file type var_log_isdnlog_t, file_type, sysadmfile; file_type_auto_trans(isdnlog_t, var_log_t, var_log_isdnlog_t)
# type for /var/lock type var_lock_isdnlog_t, file_type, sysadmfile; file_type_auto_trans(isdnlog_t, var_lock_t, var_lock_isdnlog_t)
# type for configuration type isdnlog_conf_t, file_type, sysadmfile; file_type_auto_trans(isdnlog_t, etc_t, isdnlog_conf_t)
# File permissions
##################
allow isdnlog_t device_t:dir { search };
allow isdnlog_t var_log_isdnlog_t:file { getattr read write };
allow isdnlog_t { isdnlog_conf_t etc_t proc_t resolv_conf_t }:file { getattr read };
ifdef( ipppd.te',
allow isdnlog_t { isdnctrl_device_t isdninfo_device_t }:chr_file { ioctl read }; ');
# Allow network communication
#############################
allow isdnlog_t self:unix_dgram_socket { connect create write }; allow isdnlog_t self:unix_stream_socket { connect create }; allow isdnlog_t self:tcp_socket { bind create listen }; allow isdnlog_t port_t:tcp_socket { name_bind };
# Dontaudit access to /root/.isdn/
##################################
dontaudit isdnlog_t sysadm_home_dir_t:dir r_dir_perms; dontaudit isdnlog_t sysadm_home_t:file r_file_perms;
#
# Author: Carsten Grohmann <[email protected]> #
# $Id$
#
# settings for isdnlog ######################
/etc/isdn/isdnlog.* system_u:object_r:isdnlog_conf_t/usr/sbin/isdnlog system_u:object_r:isdnlog_exec_t/var/log/isdn.log system_u:object_r:var_log_isdnlog_t/var/run/isdnlog.*pid system_u:object_r:var_run_isdnlog_t
#
# This policy is for isdnctrl
#
# Author : Carsten Grohmann <[email protected]>
#
# $Id$
#
# License : GPL
#
# last change: 03. September 2002 # # state : EXPERIMENTAL -> NOT complete and NOT testet # # Hints : # - # # Enhancements/Corrections: # -
# General declarations
######################
daemon_domain(isdnctrl)
role sysadm_r types isdnctrl_t; domain_auto_trans(sysadm_t, isdnctrl_exec_t, isdnctrl_t)
type var_lock_isdnctrl_t, file_type, sysadmfile; file_type_auto_trans(isdnctrl_t, var_lock_t, var_lock_isdnctrl_t)
# File permissions
##################
allow isdnctrl_t device_t:dir { search };
allow isdnctrl_t { sysadm_tty_device_t user_tty_device_t }:chr_file { getattr ioctl read write };
ifdef( `ipppd.te',
`# allow access to isdninfo_device_t ( /dev/isdninfo ) and
# isdnctrl_device_t ( /dev/isdnctrl* )
allow isdnctrl_t isdninfo_device_t:chr_file { ioctl read };
allow isdnctrl_t isdnctrl_device_t:chr_file { ioctl read write };
allow isdnctrl_t isdnctrl_device_t:lnk_file { read };
');#
# This policy is for ipppd_t domain.
# It based on pppd.te from Russell Coker
#
# Author : Carsten Grohmann <[email protected]>
#
# $Id$
#
# License : GPL
#
# last change: 04. September 2002 # # state : EXPERIMENTAL -> NOT complete and NOT testet # # Hints : # - # # Enhancements/Corrections: # -
# General declarations
######################
daemon_domain(ipppd, `, privmail')
type ipppd_var_log_t, file_type, sysadmfile; file_type_auto_trans(ipppd_t, var_log_t, ipppd_var_log_t)
# type for /dev/isdninfo, /dev/isdnctrl*, /dev/ippp* type isdninfo_device_t, file_type, sysadmfile; type isdnctrl_device_t, file_type, sysadmfile; type ippp_device_t, file_type, sysadmfile;
# type for configuration files #type ipppd_conf_t, file_type, sysadmfile; #file_type_auto_trans(ipppd_t, etc_t, ipppd_conf_t)
# type for ip-up and ip-down scripts type ipppd_ipscript_exec_t, file_type, exec_type, sysadmfile;
# file permissions ##################
allow ipppd_t { bin_t device_t proc_t sbin_t }:dir { search }; allow ipppd_t { bin_t ipppd_ipscript_exec_t }:lnk_file { read }; allow ipppd_t devtty_t:chr_file { read write };
allow ipppd_t { etc_t etc_runtime_t }:file { getattr read }; allow ipppd_t etc_runtime_t:file { ioctl };
allow ipppd_t ippp_device_t:chr_file { getattr ioctl read write }; #allow ipppd_t ipppd_conf_t:file { getattr read }; allow ipppd_t ipppd_var_log_t:file create_file_perms; allow ipppd_t proc_t:file { getattr read ioctl };
# Access secret files
allow ipppd_t pppd_secret_t:file r_file_perms;
# process permissions #####################
allow ipppd_t self:capability { net_admin setgid setuid };
# allow running ip-up and ip-down scripts and running chat.
can_exec(ipppd_t, { ipppd_ipscript_exec_t bin_t shell_exec_t })# process and network communication ###################################
can_network(ipppd_t)
allow ipppd_t self:unix_dgram_socket { connect create write }; allow ipppd_t self:unix_stream_socket { connect create }; allow ipppd_t self:fifo_file { getattr ioctl read write };
# Rules for ifconfig_t
######################
ifdef(ifconfig.te', domain_auto_trans(ipppd_t, ifconfig_exec_t, ifconfig_t) allow ifconfig_t ipppd_t:udp_socket { read write }; allow ipppd_t ifconfig_exec_t:file { read };')
# Rules for route_t
###################
ifdef(`route.te',
`domain_auto_trans(ipppd_t, route_exec_t, route_t) allow ipppd_t route_exec_t:file { read };
allow route_t ipppd_t:udp_socket { read write }; allow ipppd_t etc_route_t:file { getattr ioctl read };')
#
# Author: Carsten Grohmann <[email protected]> #
# $Id$
#
# settings for isdnlog ######################
/usr/sbin/isdnctrl system_u:object_r:isdnctrl_exec_t/usr/sbin/hisaxctrl system_u:object_r:isdnctrl_exec_t
#
# Author: Carsten Grohmann <[email protected]> #
# $Id$
#
/dev/ippp.* system_u:object_r:ippp_device_t/dev/isdnctrl.* system_u:object_r:isdnctrl_device_t/dev/isdninfo system_u:object_r:isdninfo_device_t
#/etc/ppp(|/.*) system_u:object_r:ipppd_conf_t/etc/ppp/ip-.* system_u:object_r:ipppd_ipscript_exec_t/etc/ppp/.*secrets system_u:object_r:pppd_secret_t/usr/sbin/ipppd system_u:object_r:ipppd_exec_t/var/run/ipppd.*pid system_u:object_r:var_run_ipppd_t
Quoted 10 lines · Carsten Grohmann
this time I write rules to use isdn with SELinux. The rules for isdnlog and isdnctrl are additional.
I've follow 2 problems:
1.
I add entries for ippp tonet_contextsand types/network.te. The entries based on the eth0-entries and the patchpatch_ifippp0contains this changes.
I don't know how can I garantuser_r,sysadm_randsystem_raccess to the network interfaces. I think follow rule is not the way to go
Quoted 10 lines
allow netmsg_t netif_t:netif { tcp_recv udp_recv };
This are the correspond log messages:
Sep 4 15:13:09 max kernel: avc: denied { udp_recv } for
saddr=192.76.144.66 source=17664 daddr=213.6.81.177 dest=244 netif=ippp0
scontext=system_u:object_r:netmsg_t tcontext=system_u:object_r:netif_t
tclass=netif
Sep 4 15:13:09 max kernel: avc: denied { tcp_recv } for
saddr=81.88.35.41 source=17664 daddr=213.6.81.177 dest=44 netif=ippp0
scontext=system_u:object_r:netmsg_t tcontext=system_u:object_r:netif_t
tclass=netifIt looks like your changes to net_contexts haven't taken effect, since the above log messages are still showing netmsg_t and netif_t. The SELinux kernel module only obtains the network interface SID and default message SID from the security server when the device is first initialized/accessed. The SIDs are then cached in the network device's security structure as long as the device remains registered. Try rebooting with the new policy.
Quoted 6 lines
2.
The ipppd runs at start and stop a shell script. This script runs in theipppd_tdomain and start different programms most withcan_exec.
. Two of this route and ifconfig runs via daemon_auto_trans(ipppd_t,
..., ....) in his own domain.
After this I recive this log entry:
Quoted 6 lines
Sep 4 15:13:30 max kernel: avc: denied { read } for pid=1991
exe=/sbin/ifconfig path=/etc/ppp/pap-secrets dev=03:0a ino=102578
scontext=system_u:system_r:ifconfig_t
tcontext=system_u:object_r:pppd_secret_t tclass=file
And I don't understand why needs ifconfig access to the ppp password
files?It probably doesn't need such access. A possible cause for the log message is that ipppd failed to close an open descriptor to pap-secrets [or mark the descriptor as close-on-exec] before exec'ing ifconfig, so SELinux is checking access on the descriptor inheritance. I'd suggest using a dontaudit rule to suppress the log message without allowing access.
--
Stephen D. Smalley, NAI Labs
[email protected]
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.