Introduce minidlna policy
cover Introduce minidlna policy
These two patches (one for the main repository, one for contrib when the main one is accepted and applied) introduce the minidlna policy for the similarly named daemon.
The policy provides the necessary capabilities for minidlna to serve media files marked as public, but a boolean (minidlna_read_generic_user_content) is available to allow the domain to serve user content as well.
Wkr,
Sven Vermeulen
PATCH 1/2 Add trivnet1 port (8200)
Create the proper port types for trivnet1 (port 8200)
--- policy/modules/kernel/corenetwork.te.in | 1 + 1 file changed, 1 insertion(+)
policy/modules/kernel/corenetwork.te.in +1 -0
@@ -261,6 +261,7 @@ network_port(tor, tcp,6969,s0, tcp,9001,s0, tcp,9030,s0, tcp,9050,s0, tcp,9051,s network_port(traceroute, udp,64000-64010,s0) network_port(transproxy, tcp,8081,s0) network_port(trisoap, tcp,10200,s0, udp,10200,s0) +network_port(trivnet1, tcp, 8200, s0, udp, 8200, s0) network_port(ups, tcp,3493,s0) network_port(utcpserver) # no defined portcon network_port(uucpd, tcp,540,s0)
Signature · 1 line
1.8.1.5
PATCH 2/2 Add minidlna policy
In reply to Sven VermeulenThe minidlna policy allows the minidla server to listen on the ssdp and trivnet1 ports (ssdp is for the discovery, trivnet1 for serving the files) and serve files marked as public_t.
If minidlna_read_generic_user_content is set, the server can also be used to serve user content.
--- minidlna.fc | 11 +++++++ minidlna.if | 64 +++++++++++++++++++++++++++++++++++++++ minidlna.te | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 minidlna.fc create mode 100644 minidlna.if create mode 100644 minidlna.te
minidlna.fc new file +11 -0
@@ -0,0 +1,11 @@ +/etc/rc\.d/init\.d/minidlna -- gen_context(system_u:object_r:minidlna_initrc_exec_t,s0) + +/etc/minidlna\.conf -- gen_context(system_u:object_r:minidlna_etc_t,s0) + +/usr/sbin/minidlna -- gen_context(system_u:object_r:minidlna_exec_t,s0) + +/var/lib/minidlna(/.*)? gen_context(system_u:object_r:minidlna_db_t,s0) + +/var/log/minidlna\.log -- gen_context(system_u:object_r:minidlna_log_t,s0) + +/var/run/minidlna(/.*)? gen_context(system_u:object_r:minidlna_var_run_t,s0)
minidlna.if new file +64 -0
64 lines not on this page · raw message
minidlna.te new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH 2/2 Add minidlna policy
Quoted 6 lines · Sven Vermeulen
The minidlna policy allows the minidla server to listen on the ssdp and trivnet1 ports (ssdp is for the discovery, trivnet1 for serving the files) and serve files marked as
public_t.If
minidlna_read_generic_user_contentis set, the server can also be used to serve user content.
Some comments in-line
Quoted 16 lines
Signed-off-by Sven Vermeulen <[email protected]>--- minidlna.fc | 11 +++++++ minidlna.if | 64 +++++++++++++++++++++++++++++++++++++++ minidlna.te | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+) create mode 100644 minidlna.fc create mode 100644 minidlna.if create mode 100644 minidlna.teminidlna.fc new file +0
-0
minidlna.fc line 3
Quoted 3 lines
minidlna.fc new file +3
-0@@ -0,0 +1,11 @@ +/etc/rc\.d/init\.d/minidlna -- gen_context(system_u:object_r:minidlna_initrc_exec_t,s0) + +/etc/minidlna\.conf -- gen_context(system_u:object_r:minidlna_etc_t,s0)
Can we use type minidlna_conf_t instead for consistency?
minidlna.fc line 7
Quoted 4 lines
minidlna.fc new file +4
-0+ +/usr/sbin/minidlna -- gen_context(system_u:object_r:minidlna_exec_t,s0) + +/var/lib/minidlna(/.*)? gen_context(system_u:object_r:minidlna_db_t,s0)
Can add support /var/cache/minidlna(/.*)? as well for Fedora? (Fedora installs the /var/cache/minidlna dir instead for this content
minidlna.fc line 9
Quoted 2 lines
minidlna.fc new file +2
-0+ +/var/log/minidlna\.log -- gen_context(system_u:object_r:minidlna_log_t,s0)
This daemon runs as root on gentoo?
Can we do /var/log/minidlna.log.* instead? (in case someone uses logrotate to maintain the log files)
Also add support for /var/log/minidlna(/.*)? as well for Fedora? ( Fedora installs the /var/log/minidlna dir instead )
minidlna.if line 1
Quoted 9 lines
minidlna.fc new file +2
-0+ +/var/run/minidlna(/.*)? gen_context(system_u:object_r:minidlna_var_run_t,s0)minidlna.if new file +1
-0@@ -0,0 +1,64 @@ +## <summary>MiniDLNA server</summary>
Gimme a break ;)
Please use something a little more descriptive:
MiniDLNA lightweight DLNA/UPnP media server.
Quoted 69 lines
minidlna.if new file +63
-0+ +######################################## +## <summary> +## All of the rules required to +## administrate an minidlna environment. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <param name="role"> +## <summary> +## Role allowed access. +## </summary> +## </param> +## <rolecap/> +# +interface(`minidlna_admin',` + gen_require(` + type minidlna_t, minidlna_var_run_t, minidlna_initrc_exec_t; + type minidlna_etc_t, minidlna_log_t, minidlna_db_t; + ') + + allow $1 minidlna_t:process { ptrace signal_perms }; + ps_process_pattern($1, minidlna_t) + + minidlna_initrc_domtrans($1) + domain_system_change_exemption($1) + role_transition $2 minidlna_initrc_exec_t system_r; + allow $2 system_r; + + files_search_etc($1) + admin_pattern($1, minidlna_etc_t) + + logging_search_logs($1) + admin_pattern($1, minidlna_log_t) + + files_search_var_lib($1) + admin_pattern($1, minidlna_db_t) + + files_search_pids($1) + admin_pattern($1, minidlna_var_run_t) +') + +######################################## +## <summary> +## Execute minidlna init scripts in +## the initrc domain. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed to transition. +## </summary> +## </param> +# +interface(`minidlna_initrc_domtrans',` + gen_require(` + type minidlna_initrc_exec_t; + ') + + init_labeled_script_domtrans($1, minidlna_initrc_exec_t) +')minidlna.te new file +0
-0
minidlna.te line 10
Quoted 10 lines
minidlna.te new file +10
-0@@ -0,0 +1,99 @@ +policy_module(minidlna, 0.1) + +############################################# +# +# Declarations +# + +## <desc> +## <p> +## Allow minidlna to read generic user content
Determine whether Minidlna can read generic user content. (i am trying to be consistent)
Quoted 19 lines
minidlna.te new file +19
-0+## </p> +## </desc> +gen_tunable(minidlna_read_generic_user_content, false) + +type minidlna_t; +type minidlna_exec_t; +init_daemon_domain(minidlna_t, minidlna_exec_t) + +type minidlna_initrc_exec_t; +init_script_file(minidlna_initrc_exec_t) + +type minidlna_etc_t; +files_config_file(minidlna_etc_t) + +type minidlna_log_t; +logging_log_file(minidlna_log_t) + +type minidlna_db_t; +files_type(minidlna_db_t)
minidlna.te line 39
Quoted 10 lines
minidlna.te new file +10
-0+ +type minidlna_var_run_t; +files_pid_file(minidlna_var_run_t) + +############################################### +# +# Local policy +# + +allow minidlna_t self:process { setsched };
No need for brace expansion here (nothing to expand)
minidlna.te line 41
Quoted 2 lines
minidlna.te new file +2
-0+allow minidlna_t self:tcp_socket create_stream_socket_perms; +allow minidlna_t self:udp_socket { create_socket_perms node_bind };
Whats node_bind permission doing there?
minidlna.te line 42
Quoted 1 line
minidlna.te new file +1
-0+allow minidlna_t self:netlink_route_socket rw_netlink_socket_perms;
Are you sure it needs to write the routing table? (show me the avc denials)
minidlna.te line 43
Quoted 1 line
minidlna.te new file +1
-0+allow minidlna_t minidlna_log_t:file { create_file_perms append_file_perms };
Need support for adding dir entries to minidlna_log_t dirs (fedora installs /var/log/minidlna dir)
minidlna.te line 49
Quoted 6 lines
minidlna.te new file +6
-0+allow minidlna_t minidlna_etc_t:file read_file_perms; + +manage_files_pattern(minidlna_t, minidlna_db_t, minidlna_db_t) +create_dirs_pattern(minidlna_t, minidlna_db_t, minidlna_db_t) +rw_dirs_pattern(minidlna_t, minidlna_db_t, minidlna_db_t) +files_var_lib_filetrans(minidlna_t, minidlna_db_t, dir)
Are you saying that it does not actually install /var/lib/minidlna? This can probably be done cleaner (use permission sets where possible instead of patterns)
minidlna.te line 52
Quoted 3 lines
minidlna.te new file +3
-0+ +manage_files_pattern(minidlna_t, minidlna_var_run_t, minidlna_var_run_t) +rw_dirs_pattern(minidlna_t, minidlna_var_run_t, minidlna_var_run_t)
permission set is cleaner.
minidlna.te line 58
Quoted 5 lines
minidlna.te new file +5
-0+files_pid_filetrans(minidlna_t, minidlna_var_run_t, file) + +kernel_read_fs_sysctls(minidlna_t) +kernel_read_system_state(minidlna_t) +logging_log_filetrans(minidlna_t, minidlna_log_t, file)
This needs to go up (to where the other logging rules are
Quoted 12 lines
minidlna.te new file +12
-0+ +corecmd_exec_bin(minidlna_t) +corecmd_exec_shell(minidlna_t) + +corenet_all_recvfrom_netlabel(minidlna_t) +corenet_all_recvfrom_unlabeled(minidlna_t) + +corenet_sendrecv_ssdp_client_packets(minidlna_t) +corenet_sendrecv_ssdp_server_packets(minidlna_t) + +corenet_tcp_bind_generic_node(minidlna_t) +corenet_tcp_sendrecv_generic_if(minidlna_t)
minidlna.te line 80
Quoted 10 lines
minidlna.te new file +10
-0+corenet_tcp_sendrecv_generic_node(minidlna_t) + +corenet_udp_bind_generic_node(minidlna_t) +corenet_udp_bind_ssdp_port(minidlna_t) + +corenet_sendrecv_trivnet1_client_packets(minidlna_t) +corenet_sendrecv_trivnet1_server_packets(minidlna_t) +corenet_tcp_bind_trivnet1_port(minidlna_t) + +files_read_etc_files(minidlna_t)
Which file is that? /etc/nsswitch.conf?
Quoted 19 lines
minidlna.te new file +19
-0+ +miscfiles_read_localization(minidlna_t) +miscfiles_read_public_files(minidlna_t) + +tunable_policy(`minidlna_read_generic_user_content',` + userdom_list_user_tmp(minidlna_t) + userdom_read_user_home_content_files(minidlna_t) + userdom_read_user_home_content_symlinks(minidlna_t) + userdom_read_user_tmp_files(minidlna_t) + userdom_read_user_tmp_symlinks(minidlna_t) +',` + files_dontaudit_list_home(minidlna_t) + files_dontaudit_list_tmp(minidlna_t) + + userdom_dontaudit_list_user_home_dirs(minidlna_t) + userdom_dontaudit_list_user_tmp(minidlna_t) + userdom_dontaudit_read_user_home_content_files(minidlna_t) + userdom_dontaudit_read_user_tmp_files(minidlna_t) +')
PATCH 2/2 Add minidlna policy
Quoted 3 lines · Dominick Grift
Quoted 1 line
+/etc/minidlna\.conf --
gen_context(system_u:object_r:minidlna_etc_t,s0)Can we use type
minidlna_conf_tinstead for consistency?
Ok... but in the contrib/ folder, I find more _etc_t definitions than _conf_t ones:
$ grep '^type .*_conf_t' *.te | wc -l 36 $ grep '^type .*_etc_t' *.te | wc -l 89
Quoted 7 lines
minidlna.fc line 7
Quoted 4 lines
minidlna.fc new file +4
-0+ +/usr/sbin/minidlna -- gen_context(system_u:object_r:minidlna_exec_t,s0) + +/var/lib/minidlna(/.*)? gen_context(system_u:object_r:minidlna_db_t,s0)Can add support /var/cache/minidlna(/.*)? as well for Fedora? (Fedora installs the
/var/cache/minidlnadir instead for this content
Of course
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +/var/log/minidlna\.log -- gen_context(system_u:object_r:minidlna_log_t,s0)This daemon runs as root on gentoo?
No, but the package manager creates the log file with proper ownership already here.
Quoted 5 lines
Can we do
/var/log/minidlna.log.*instead? (in case someone uses logrotate to maintain the log files)Also add support for /var/log/minidlna(/.*)? as well for Fedora? ( Fedora installs the
/var/log/minidlnadir instead )
Ok
Quoted 7 lines
Quoted 1 line
+## <summary>MiniDLNA server</summary>
Gimme a break ;)
Please use something a little more descriptive:
MiniDLNA lightweight DLNA/UPnP media server.
Have a kitkat ;-)
Sorry about that.
Quoted 6 lines
minidlna.te line 10
Quoted 3 lines
minidlna.te new file +3
-0+## <desc> +## <p> +## Allow minidlna to read generic user contentDetermine whether Minidlna can read generic user content. (i am trying to be consistent)
Ok.
Quoted 4 lines
minidlna.te line 41
Quoted 2 lines
minidlna.te new file +2
-0+allow minidlna_t self:tcp_socket create_stream_socket_perms; +allow minidlna_t self:udp_socket { create_socket_perms node_bind };Whats
node_bindpermission doing there?
Sorry about that, was from before I had thecorenet_udp_bind_generic_node(minidlna_t) set.
Quoted 4 lines
Quoted 1 line
+allow
minidlna_tself:netlink_route_socketrw_netlink_socket_perms;Are you sure it needs to write the routing table? (show me the avc denials)
Ah yes, r_netlink_socket_perms is sufficient, my bad.
Quoted 4 lines
Quoted 1 line
+allow
minidlna_tminidlna_log_t:file {create_file_permsappend_file_perms};Need support for adding dir entries to
minidlna_log_tdirs (fedora installs/var/log/minidlnadir)
Ok
Quoted 10 lines
minidlna.te line 49
Quoted 6 lines
minidlna.te new file +6
-0+allow minidlna_t minidlna_etc_t:file read_file_perms; + +manage_files_pattern(minidlna_t, minidlna_db_t, minidlna_db_t) +create_dirs_pattern(minidlna_t, minidlna_db_t, minidlna_db_t) +rw_dirs_pattern(minidlna_t, minidlna_db_t, minidlna_db_t) +files_var_lib_filetrans(minidlna_t, minidlna_db_t, dir)Are you saying that it does not actually install
/var/lib/minidlna? This can probably be done cleaner (use permission sets where possible instead of patterns)
I wasn't sure what to do here. Gentoo installs the /var/lib/minidlna directory already as part of the software installation. But I noticed that the majority of modules do have this set.
I'll change it to a files_search_var_lib(minidlna_t).
Quoted 5 lines
minidlna.te line 52
Quoted 3 lines
minidlna.te new file +3
-0+ +manage_files_pattern(minidlna_t, minidlna_var_run_t, minidlna_var_run_t) +rw_dirs_pattern(minidlna_t, minidlna_var_run_t, minidlna_var_run_t)permission set is cleaner.
Ok
Quoted 7 lines
minidlna.te line 58
Quoted 5 lines
minidlna.te new file +5
-0+files_pid_filetrans(minidlna_t, minidlna_var_run_t, file) + +kernel_read_fs_sysctls(minidlna_t) +kernel_read_system_state(minidlna_t) +logging_log_filetrans(minidlna_t, minidlna_log_t, file)This needs to go up (to where the other logging rules are
Ok
Quoted 16 lines
Quoted 16 lines
minidlna.te new file +16
-0+ +corecmd_exec_bin(minidlna_t) +corecmd_exec_shell(minidlna_t) + +corenet_all_recvfrom_netlabel(minidlna_t) +corenet_all_recvfrom_unlabeled(minidlna_t) + +corenet_sendrecv_ssdp_client_packets(minidlna_t) +corenet_sendrecv_ssdp_server_packets(minidlna_t) + +corenet_tcp_bind_generic_node(minidlna_t) +corenet_tcp_sendrecv_generic_if(minidlna_t) +corenet_tcp_sendrecv_generic_node(minidlna_t) + +corenet_udp_bind_generic_node(minidlna_t) +corenet_udp_bind_ssdp_port(minidlna_t)
Quoted 8 lines
minidlna.te line 80
Quoted 6 lines
minidlna.te new file +6
-0+ +corenet_sendrecv_trivnet1_client_packets(minidlna_t) +corenet_sendrecv_trivnet1_server_packets(minidlna_t) +corenet_tcp_bind_trivnet1_port(minidlna_t) + +files_read_etc_files(minidlna_t)Which file is that?
/etc/nsswitch.conf?
nsswitch.conf and passwd.
Wkr,
Sven Vermeulen
PATCH 2/2 Add minidlna policy
Quoted 5 lines · Sven Vermeulen
Quoted 3 lines · Dominick Grift
Quoted 1 line
+/etc/minidlna\.conf --
gen_context(system_u:object_r:minidlna_etc_t,s0)Can we use type
minidlna_conf_tinstead for consistency?
Quoted 7 lines
Ok... but in the contrib/ folder, I find more
_etc_tdefinitions than_conf_tones:$ grep '^type .*_conf_t' *.te | wc -l 36 $ grep '^type .*_etc_t' *.te | wc -l 89
Hmm, i see. I prefer conf in light of self-documenting policy
Quoted 6 lines
I wasn't sure what to do here. Gentoo installs the
/var/lib/minidlnadirectory already as part of the software installation. But I noticed that the majority of modules do have this set.I'll change it to a
files_search_var_lib(minidlna_t).
Thanks. A file transition is not needed in that case
Quoted 5 lines
Quoted 2 lines
Which file is that?
/etc/nsswitch.conf?nsswitch.conf and passwd.
Probably needs nsswitch support then
Quoted 2 lines
Wkr,
Sven Vermeulen
PATCH 2/2 Add minidlna policy
Quoted 9 lines · Dominick Grift
Quoted 8 lines · Sven Vermeulen
Quoted 3 lines · Dominick Grift
Quoted 1 line
+/etc/minidlna\.conf --
gen_context(system_u:object_r:minidlna_etc_t,s0)Can we use type
minidlna_conf_tinstead for consistency?Ok... but in the contrib/ folder, I find more
_etc_tdefinitions than_conf_tones:
Quoted 6 lines
Quoted 4 lines
$ grep '^type .*_conf_t' *.te | wc -l 36 $ grep '^type .*_etc_t' *.te | wc -l 89Hmm, i see. I prefer conf in light of self-documenting policy
I prefer it too, but I'd say its not a hard requirement. I think it makes sense, since it ties the name to the concept of a configuration file, rather than a path, which is what _etc_t does. /etc does not consist of only config files.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 2/2 Add minidlna policy
In reply to Sven VermeulenQuoted 8 lines · Sven Vermeulen
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ +/var/log/minidlna\.log -- gen_context(system_u:object_r:minidlna_log_t,s0)This daemon runs as root on gentoo?
No, but the package manager creates the log file with proper ownership already here.
In that case we do not need a file type transition for log files
PATCH 2/2 Add minidlna policy
In reply to Sven VermeulenQuoted 4 lines · Sven Vermeulen
minidlna.te new file +4
-0+corenet_sendrecv_ssdp_client_packets(minidlna_t) +corenet_sendrecv_ssdp_server_packets(minidlna_t) + +corenet_tcp_bind_generic_node(minidlna_t)
minidlna.te line 79
Quoted 10 lines
minidlna.te new file +10
-0+corenet_tcp_sendrecv_generic_if(minidlna_t) +corenet_tcp_sendrecv_generic_node(minidlna_t) + +corenet_udp_bind_generic_node(minidlna_t) +corenet_udp_bind_ssdp_port(minidlna_t) + +corenet_sendrecv_trivnet1_client_packets(minidlna_t) +corenet_sendrecv_trivnet1_server_packets(minidlna_t) +corenet_tcp_bind_trivnet1_port(minidlna_t) +
Another oversight
You do not need the "client_packets" interface calls if the domain does not connect to the port
In this case minidlna domain only binds tcp sockets to trivnet1 ports, and udp sockets to ssdp ports
i think we also need these:
corenet_tcp_sendrecv_trivnet1_port(minidlna_t)corenet_udp_sendrecv_ssdp_port(minidlna_t)
PATCH 2/2 Add minidlna policy
Quoted 7 lines · Dominick Grift
minidlna.te line 79
Quoted 4 lines
minidlna.te new file +4
-0+corenet_sendrecv_trivnet1_client_packets(minidlna_t) +corenet_sendrecv_trivnet1_server_packets(minidlna_t) +corenet_tcp_bind_trivnet1_port(minidlna_t) +Another oversight
Quoted 5 lines
You do not need the "
client_packets" interface calls if the domain does not connect to the portIn this case minidlna domain only binds tcp sockets to trivnet1 ports, and udp sockets to ssdp ports
I must admit, I never understood (and still don't understand) the networking aspects in more detail. The corenet_sendrecv_*_packets() interfaces are for the SECMARK labeled usage, right?
The interfaces assume that iptables (or whatever you use) labels the packets as trivnet1_client_packet_t or trivnet1_server_packet_t. Does that mean that, in case of a daemon (which does not connect to remote ports, i.e. act as a client) we assume that iptables marks it as trivnet1_server_packet_t?
And that, if we would connect to a remote site somehow, these packets would be assumed to be marked trivnet1_client_packet_t?
Also, if a system would use SECMARK, are the following interfaces then no longer needed (as these are the "old" ones)?
- corenet_all_recvfrom_unlabeled
- corenet_tcp_sendrecv_generic_if
- corenet_tcp_sendrecv_generic_node
- corenet_tcp_bind_generic_node
- corenet_tcp_bind_*_port
- corenet_tcp_sendrecv_*_port
Quoted 6 lines
i think we also need these:
corenet_tcp_sendrecv_trivnet1_port(minidlna_t)corenet_udp_sendrecv_ssdp_port(minidlna_t)From the looks of it, you're right, as
minidlna_tcurrently doesn't have {
send_msg recv_msg } rights on the trivnet1_port_t's tcp_socket. The weird thing is, my minidlna server is running just fine and my TV can connect and play stuff from the server. I'm not running a firewall that labels the packets either, so what gives?
# ps -efZ | grep minidlna system_u:system_r:minidlna_t minidlna 10236 1 0 21:08 ? 00:00:00 /usr/sbin/minidlna -P /var/run/minidlna/minidlna.pid -R -f /etc/minidlna.conf
# semanage port -l | grep 8200 trivnet1_port_t tcp 8200 trivnet1_port_t udp 8200
# sesearch -s minidlna_t -t trivnet1_port_t -c tcp_socket -Ad Found 1 semantic av rules: allow minidlna_t trivnet1_port_t : tcp_socket name_bind ;
# sesearch -s minidlna_t -c tcp_socket -p send_msg -A # (no hits, just in case it was through an attribute)
# sestatus | grep mode Current mode: enforcing
# semanage permissive -l # (no permissive domains)
I'll add in the corenet_tcp_sendrecv_trivnet1_port(minidlna_t) and the udp/ssdp one as, from online documentation, I think I understand that they are needed. But I am wondering why my system doesn't mind working onwards even without these rules :-(
Wkr,
Sven Vermeulen
PATCH 2/2 Add minidlna policy
Quoted 11 lines · Sven Vermeulen
Quoted 10 lines · Dominick Grift
minidlna.te line 79
Quoted 4 lines
minidlna.te new file +4
-0+corenet_sendrecv_trivnet1_client_packets(minidlna_t) +corenet_sendrecv_trivnet1_server_packets(minidlna_t) +corenet_tcp_bind_trivnet1_port(minidlna_t) +Another oversight
You do not need the "
client_packets" interface calls if the domain does not connect to the port
Quoted 6 lines
Quoted 2 lines
In this case minidlna domain only binds tcp sockets to trivnet1 ports, and udp sockets to ssdp ports
I must admit, I never understood (and still don't understand) the networking aspects in more detail. The corenet_sendrecv_*_packets() interfaces are for the SECMARK labeled usage, right?
Good question, and i am not sure.
I just know/remember the behavior as i've experienced it. I just do not remember if it was due to secmark or compat_net or something else.
Could be just how selinux network controls were previously configured by default on fedora in the past (compat_net?). In that case it is still good to support backwards compatibility.
I just remember that "client_packets" correspond to connecting to a port, and "server_packets" correspond to binding sockets to a port.
Quoted 8 lines
The interfaces assume that iptables (or whatever you use) labels the packets as
trivnet1_client_packet_tortrivnet1_server_packet_t. Does that mean that, in case of a daemon (which does not connect to remote ports, i.e. act as a client) we assume that iptables marks it astrivnet1_server_packet_t?And that, if we would connect to a remote site somehow, these packets would be assumed to be marked
trivnet1_client_packet_t?
I am just not sure, sorry. Maybe Chris or Paul Moore can shed some more light on this.
Quoted 39 lines
Also, if a system would use SECMARK, are the following interfaces then no longer needed (as these are the "old" ones)?
-corenet_all_recvfrom_unlabeled
-corenet_tcp_sendrecv_generic_if
-corenet_tcp_sendrecv_generic_node
-corenet_tcp_bind_generic_node
- corenet_tcp_bind_*_port
- corenet_tcp_sendrecv_*_portQuoted 4 lines
i think we also need these:
corenet_tcp_sendrecv_trivnet1_port(minidlna_t)corenet_udp_sendrecv_ssdp_port(minidlna_t)From the looks of it, you're right, as
minidlna_tcurrently doesn't have {send_msgrecv_msg} rights on the trivnet1_port_t'stcp_socket. The weird thing is, my minidlna server is running just fine and my TV can connect and play stuff from the server. I'm not running a firewall that labels the packets either, so what gives?# ps -efZ | grep minidlna system_u:system_r:minidlna_t minidlna 10236 1 0 21:08 ? 00:00:00 /usr/sbin/minidlna -P /var/run/minidlna/minidlna.pid -R -f /etc/minidlna.conf# semanage port -l | grep 8200 trivnet1_port_t tcp 8200 trivnet1_port_t udp 8200# sesearch -s minidlna_t -t trivnet1_port_t -c tcp_socket -Ad Found 1 semantic av rules: allow minidlna_t trivnet1_port_t : tcp_socket name_bind ;# sesearch -s minidlna_t -c tcp_socket -p send_msg -A # (no hits, just in case it was through an attribute)# sestatus | grep mode Current mode: enforcing
Quoted 8 lines
# semanage permissive -l # (no permissive domains)I'll add in the
corenet_tcp_sendrecv_trivnet1_port(minidlna_t)and the udp/ssdp one as, from online documentation, I think I understand that they are needed. But I am wondering why my system doesn't mind working onwards even without these rules :-(
Fedora shows the same behavior. I think it is related to "compat_net" but i am not sure. I just know how it use to work, and i would like to maintain backwards compatibility.
Quoted 2 lines
Wkr,
Sven Vermeulen
PATCH 2/2 Add minidlna policy
Quoted 12 lines · Dominick Grift
Quoted 11 lines · Sven Vermeulen
Quoted 10 lines · Dominick Grift
minidlna.te line 79
Quoted 4 lines
minidlna.te new file +4
-0+corenet_sendrecv_trivnet1_client_packets(minidlna_t) +corenet_sendrecv_trivnet1_server_packets(minidlna_t) +corenet_tcp_bind_trivnet1_port(minidlna_t) +Another oversight
You do not need the "
client_packets" interface calls if the domain does not connect to the port
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
In this case minidlna domain only binds tcp sockets to trivnet1 ports, and udp sockets to ssdp ports
I must admit, I never understood (and still don't understand) the networking aspects in more detail. The corenet_sendrecv_*_packets() interfaces are for the SECMARK labeled usage, right?
Good question, and i am not sure.
Looks like compat_net support may have been completely removed:
http://lists.openwall.net/netdev/2009/03/27/144
i think we need more and better, practical examples of how to use secmark and how secmark can be configured to match the old compat_net functionality
There is one nice how to by Dan Walsh on Linux.com, but other than that documentation is lacking in my view
PATCH 2/2 Add minidlna policy
Quoted 3 lines · Dominick Grift
Looks like
compat_netsupport may have been completely removed:
Now i'm completely lost. Does that mean that the "old", non-labeled approach is not used anymore? I could've sworn that node_t and netif_t were still used.
Quoted 6 lines
i think we need more and better, practical examples of how to use secmark and how secmark can be configured to match the old
compat_netfunctionalityThere is one nice how to by Dan Walsh on Linux.com, but other than that documentation is lacking in my view
Ack. And also how the default behavior is if no secmark/labeling is used... -------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.tresys.com/pipermail/refpolicy/attachments/20130503/60918c90/attachment.html
PATCH 2/2 Add minidlna policy
Quoted 9 lines · Sven Vermeulen
Quoted 3 lines · Dominick Grift
Looks like
compat_netsupport may have been completely removed:Now i'm completely lost. Does that mean that the "old", non-labeled approach is not used anymore? I could've sworn that
node_tandnetif_twere still used.
nodes and network interfaces can be labeled with semanage i believe.
but by default i think most domains can use only default network interface and node types (so node_t and netif_t, not all types classified node_type or netif_type)
# semanage interface -l # semanage node -l
Seems no network interfaces or nodes are labeled by default
Quoted 8 lines
Quoted 6 lines
i think we need more and better, practical examples of how to use secmark and how secmark can be configured to match the old
compat_netfunctionalityThere is one nice how to by Dan Walsh on Linux.com, but other than that documentation is lacking in my view
Ack. And also how the default behavior is if no secmark/labeling is used...
what you see (avc denials) is what you get by default.
PATCH 2/2 Add minidlna policy
In reply to Sven VermeulenQuoted 7 lines · Sven Vermeulen
Quoted 3 lines · Dominick Grift
Looks like
compat_netsupport may have been completely removed:Now i'm completely lost. Does that mean that the "old", non-labeled approach is not used anymore?
Seems that way yes, at least part of the old approach
PATCH 2/2 Add minidlna policy
In reply to Dominick GriftQuoted 12 lines · Dominick Grift
Quoted 11 lines · Sven Vermeulen
Quoted 10 lines · Dominick Grift
minidlna.te line 79
Quoted 4 lines
minidlna.te new file +4
-0+corenet_sendrecv_trivnet1_client_packets(minidlna_t) +corenet_sendrecv_trivnet1_server_packets(minidlna_t) +corenet_tcp_bind_trivnet1_port(minidlna_t) +Another oversight
You do not need the "
client_packets" interface calls if the domain does not connect to the port
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
In this case minidlna domain only binds tcp sockets to trivnet1 ports, and udp sockets to ssdp ports
I must admit, I never understood (and still don't understand) the networking aspects in more detail. The corenet_sendrecv_*_packets() interfaces are for the SECMARK labeled usage, right?
Good question, and i am not sure.
Yes, they are used for SECMARK.
Quoted 6 lines
I just know/remember the behavior as i've experienced it. I just do not remember if it was due to secmark or
compat_netor something else.Could be just how selinux network controls were previously configured by default on fedora in the past (
compat_net?). In that case it is still good to support backwards compatibility.
As you mentioned in a latter email, compat_net has been removed. The SELinux network access controls are only SECMARK now.
Quoted 2 lines
I just remember that "
client_packets" correspond to connecting to a port, and "server_packets" correspond to binding sockets to a port.
Yes, the premise was to differentiate incoming and outgoing packets. For example if you ssh out of a system that has a sshd, you want to separate the packets going to sshd from those going to the ssh client.
Quoted 10 lines
Quoted 7 lines
The interfaces assume that iptables (or whatever you use) labels the packets as
trivnet1_client_packet_tortrivnet1_server_packet_t. Does that mean that, in case of a daemon (which does not connect to remote ports, i.e. act as a client) we assume that iptables marks it astrivnet1_server_packet_t?And that, if we would connect to a remote site somehow, these packets would be assumed to be marked
trivnet1_client_packet_t?I am just not sure, sorry. Maybe Chris or Paul Moore can shed some more light on this.
Yes. I think what you're confused on is that SECMARK labels are local only. They are not transferred over the network like labeled IPSEC or NetLabel/CIPSO. The object class for those labels is peer. The only remaining permissions on port types is name_bind and name_connect.
Quoted 11 lines
Quoted 11 lines
Also, if a system would use SECMARK, are the following interfaces then no longer needed (as these are the "old" ones)?
-corenet_all_recvfrom_unlabeled
-corenet_tcp_sendrecv_generic_if
-corenet_tcp_sendrecv_generic_node
-corenet_tcp_bind_generic_node
- corenet_tcp_bind_*_port
- corenet_tcp_sendrecv_*_portQuoted 2 lines
i think we also need these:
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
corenet_tcp_sendrecv_trivnet1_port(minidlna_t)corenet_udp_sendrecv_ssdp_port(minidlna_t)From the looks of it, you're right, as
minidlna_tcurrently doesn't have {send_msgrecv_msg} rights on the trivnet1_port_t'stcp_socket. The weird thing is, my minidlna server is running just fine and my TV can connect and play stuff from the server. I'm not running a firewall that labels the packets either, so what gives?
These permissions are no longer checked, as they are replaced by the SECMARK/packet permissions.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 2/2 Add minidlna policy
Quoted 2 lines · Christopher J. PeBenito
As you mentioned in a latter email,
compat_nethas been removed. The SELinux network access controls are only SECMARK now.
[...]
Quoted 1 line
Yes. I think what you're confused on is that SECMARK labels are local only. They are not transferred over the network like labeled IPSEC or NetLabel/CIPSO. The object class for those labels is peer. The only remaining permissions on port types is
name_bindandname_connect.
So for each port type that we declare, the corenet_{tcp,udp}_sendrecv_*_port is actually void now? Only corenet_{tcp,udp}_{bind,connect}_*_port is then used?
It starts making sense.
Even if SECMARK is used, the bind/connect is still needed, right?
Wkr,
Sven Vermeulen
PATCH 2/2 Add minidlna policy
Quoted 9 lines · Sven Vermeulen
Quoted 2 lines · Christopher J. PeBenito
As you mentioned in a latter email,
compat_nethas been removed. The SELinux network access controls are only SECMARK now.[...]
Quoted 1 line
Yes. I think what you're confused on is that SECMARK labels are local only. They are not transferred over the network like labeled IPSEC or NetLabel/CIPSO. The object class for those labels is peer. The only remaining permissions on port types is
name_bindandname_connect.So for each port type that we declare, the corenet_{tcp,udp}_sendrecv_*_port is actually void now? Only corenet_{tcp,udp}_{bind,connect}_*_port is then used?
Yes. In fact, I've been looking at removing the port send/recv and any other old, unused networking rules.
Quoted 3 lines
It starts making sense.
Even if SECMARK is used, the bind/connect is still needed, right?
Yes. Those permissions are always checked.
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com