Patches to support the SELinux SCTP kernel patch
Please find attached two patches for testing the SELinux SCTP kernel patch:
0001-libsepol-Update-RC5-to-support-SCTP-DCCP-portcon-key.patch
This updates the https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20140826/libsepol-2.4-rc5.tar.gz
Requires the test policy modules to be built in CIL as it is much
easier to add new class/permissions:
;; Use last classorder from refpolicy base - cil module:
;(classorder (db_language sctp_socket))
;; Use last classorder from Fedora targeted base - cil module:
(classorder (proxy sctp_socket))
;; Define class / perms:
;; For some reason these work on refpolicy but NOT Fedora targeted:
;(classcommon sctp_socket socket)
;(class sctp_socket (node_bind name_connect bindx_add_addr bindx_rem_addr))
; But this works for Fedora:
(class sctp_socket (ioctl read write create getattr setattr lock relabelfrom relabelto append bind connect listen accept getopt setopt shutdown recvfrom sendto recv_msg send_msg name_bind node_bind name_connect bindx_add_addr bindx_rem_addr))
0001-lksctp-tools-Add-SELinux-support-to-sctp_test.patch This patch calls getpeercon/lgetfilecon to display the various contexts. It is applied to lksctp-tools.
Richard
From a68c23c12e55947ace7ddb5baf432c0ba8015929 Mon Sep 17 00:00:00 2001
From: Richard Haines <[email protected]>
Date: Sat, 1 Nov 2014 12:58:19 +0000
Subject: [PATCH] libsepol: Update RC5 to support SCTP/DCCP portcon keywords
This will allow the kernel patches to be tested.
--- libsepol/cil/docs/CIL_Reference_Guide.xml | 7 +++---- libsepol/cil/docs/cil_network_labeling_statements.xml | 8 +++++--- libsepol/cil/src/cil.c | 2 ++ libsepol/cil/src/cil_binary.c | 6 ++++++ libsepol/cil/src/cil_build_ast.c | 4 ++++ libsepol/cil/src/cil_internal.h | 6 +++++- libsepol/cil/src/cil_policy.c | 4 ++++ libsepol/cil/src/cil_tree.c | 4 ++++ libsepol/cil/test/policy.cil | 2 ++ libsepol/include/sepol/policydb/policydb.h | 8 ++++---- libsepol/include/sepol/port_record.h | 2 ++ libsepol/src/port_record.c | 4 ++++ libsepol/src/ports.c | 8 ++++++++ 13 files changed, 53 insertions(+), 12 deletions(-)
libsepol/cil/docs/CIL_Reference_Guide.xml +3 -4
@@ -29,9 +29,9 @@ <title>Common Interface Language (CIL) Reference Guide</title> <revhistory> <revision> - <revnumber>0.2</revnumber> - <date>22nd May '14</date> - <revremark>Updated classmap/classmapping, added classmap to statements that utilise class_id's (defaultuser, typetransition etc.), update various examples to show anonymous classpermissionset's using expressions.</revremark> + <revnumber>0.3</revnumber> + <date>1st November '14</date> + <revremark>Add portcon support for DCCP and SCTP.</revremark> </revision> </revhistory> </articleinfo>
@@ -39,7 +39,6 @@ <sect1> <title>CIL Information</title> <orderedlist> - <listitem><para>The statement definitions are those found in the source from: <literal>git clone <ulink url="https://bitbucket.org/jwcarter/secilc.git"></ulink></literal> dated 21st May '14.</para></listitem> <listitem><para>Not all possible alternate statement permutations are shown, however there should be enough variation to work out any other valid formats. There is also an example <filename>policy.cil</filename> file shown in the <link linkend="example_policy">Appendix</link>.</para></listitem> <listitem><para>The MLS components on contexts and user statements must be declared even if the policy does not support MCS/MLS. </para></listitem> <listitem><para>The CIL compiler will not build a policy unless it also has as a minimum: one <literal><link linkend="allow">allow</link></literal> rule, one <literal><link linkend="sid">sid</link></literal>, <literal><link linkend="sidorder">sidorder</link></literal> and <literal><link linkend="sidcontext">sidcontext</link></literal> statement. </para></listitem>
libsepol/cil/docs/cil_network_labeling_statements.xml +5 -3
@@ -184,7 +184,7 @@ <sect2 id="portcon"> <title>portcon</title> - <para>Label a udp or tcp port.</para> + <para>Label a tcp, udp, dccp or sctp port.</para> <para><emphasis role="bold">Statement definition:</emphasis></para> <programlisting><![CDATA[(portcon protocol port context_id)]]></programlisting> <para><emphasis role="bold">Where:</emphasis></para>
@@ -206,7 +206,7 @@ <para><literal>protocol</literal></para> </entry> <entry> - <para>The protocol keyword <literal>tcp</literal> or <literal>udp</literal>.</para> + <para>The protocol keyword <literal>tcp</literal>, <literal>udp</literal>, <literal>dccp</literal> or <literal>sctp</literal>.</para> </entry> </row> <row>
@@ -227,7 +227,9 @@ (portcon tcp 2222 (unconfined.user object_r unconfined.object levelrange_2)) (portcon tcp 3333 (unconfined.user object_r unconfined.object levelrange_1)) (portcon udp 4444 (unconfined.user object_r unconfined.object ((s0) level_2))) -(portcon tcp 55555 (unconfined.user object_r unconfined.object (systemlow level_3)))]]> +(portcon tcp 55555 (unconfined.user object_r unconfined.object (systemlow level_3))) +(portcon sctp 19000 (unconfined.user object_r unconfined.object ((s0) level_2))) +(portcon dccp 19001 (unconfined.user object_r unconfined.object (systemlow level_3)))]]> </programlisting> </sect2>
libsepol/cil/src/cil.c +2 -0
@@ -90,6 +90,8 @@ static void cil_init_keys(void)CIL_KEY_STAR =cil_strpool_add ("*" );CIL_KEY_UDP =cil_strpool_add ("udp" );CIL_KEY_TCP =cil_strpool_add ("tcp" ); +CIL_KEY_DCCP =cil_strpool_add ("dccp" ); +CIL_KEY_SCTP =cil_strpool_add ("sctp" );CIL_KEY_AUDITALLOW =cil_strpool_add ("auditallow" );CIL_KEY_TUNABLEIF =cil_strpool_add ("tunableif" );CIL_KEY_ALLOW =cil_strpool_add ("allow" );
libsepol/cil/src/cil_binary.c +6 -0
@@ -2732,6 +2732,12 @@ int cil_portcon_to_policydb(policydb_t *pdb, struct cil_sort *portcons)case CIL_PROTOCOL_TCP : new_ocon->u.port.protocol =IPPROTO_TCP ;break ; +case CIL_PROTOCOL_DCCP : + new_ocon->u.port.protocol =IPPROTO_DCCP ; +break ; +case CIL_PROTOCOL_SCTP : + new_ocon->u.port.protocol =IPPROTO_SCTP ; +break ;default :/* should not get here */ rc =SEPOL_ERR ;
libsepol/cil/src/cil_build_ast.c +4 -0
@@ -3928,6 +3928,10 @@ int cil_gen_portcon(struct cil_db *db, struct cil_tree_node *parse_current, stru portcon->proto =CIL_PROTOCOL_UDP ; }else if (proto ==CIL_KEY_TCP ) { portcon->proto =CIL_PROTOCOL_TCP ; + }else if (proto ==CIL_KEY_DCCP ) { + portcon->proto =CIL_PROTOCOL_DCCP ; + }else if (proto ==CIL_KEY_SCTP ) { + portcon->proto =CIL_PROTOCOL_SCTP ; }else {cil_log (CIL_ERR ,"Invalid protocol\n" ); rc =SEPOL_ERR ;
libsepol/cil/src/cil_internal.h +5 -1
@@ -100,6 +100,8 @@ char *CIL_KEY_OBJECT_R;char *CIL_KEY_STAR ;char *CIL_KEY_TCP ;char *CIL_KEY_UDP ; +char *CIL_KEY_DCCP ; +char *CIL_KEY_SCTP ;char *CIL_KEY_AUDITALLOW ;char *CIL_KEY_TUNABLEIF ;char *CIL_KEY_ALLOW ;
@@ -658,7 +660,9 @@ struct cil_filecon {enum cil_protocol {CIL_PROTOCOL_UDP =1 , -CIL_PROTOCOL_TCP +CIL_PROTOCOL_TCP , +CIL_PROTOCOL_DCCP , +CIL_PROTOCOL_SCTP };struct cil_portcon {
libsepol/cil/src/cil_policy.c +4 -0
@@ -122,6 +122,10 @@ int cil_portcon_to_policy(FILE **file_arr, struct cil_sort *sort)fprintf (file_arr[NETIFCONS ],"udp " ); }else if (portcon->proto ==CIL_PROTOCOL_TCP ) {fprintf (file_arr[NETIFCONS ],"tcp " ); + }else if (portcon->proto ==CIL_PROTOCOL_DCCP ) { +fprintf (file_arr[NETIFCONS ],"dccp " ); + }else if (portcon->proto ==CIL_PROTOCOL_SCTP ) { +fprintf (file_arr[NETIFCONS ],"sctp " ); }fprintf (file_arr[NETIFCONS ],"%d " , portcon->port_low);fprintf (file_arr[NETIFCONS ],"%d " , portcon->port_high);
libsepol/cil/src/cil_tree.c +4 -0
@@ -1289,6 +1289,10 @@ void cil_tree_print_node(struct cil_tree_node *node)cil_log (CIL_INFO ," udp" ); }else if (portcon->proto ==CIL_PROTOCOL_TCP ) {cil_log (CIL_INFO ," tcp" ); + }else if (portcon->proto ==CIL_PROTOCOL_DCCP ) { +cil_log (CIL_INFO ," dccp" ); + }else if (portcon->proto ==CIL_PROTOCOL_SCTP ) { +cil_log (CIL_INFO ," sctp" ); }cil_log (CIL_INFO ," (%d %d)" , portcon->port_low, portcon->port_high);
libsepol/cil/test/policy.cil +2 -0
@@ -241,6 +241,8 @@ (nodecon ip_v6 netmask_v6 system_u_bin_t_l2h) (portcon udp 25 system_u_bin_t_l2h) (portcon tcp 22 system_u_bin_t_l2h) + (portcon sctp 19000 system_u_bin_t_l2h) + (portcon dccp 19001 system_u_bin_t_l2h) (genfscon - "/usr/bin" system_u_bin_t_l2h) (netifcon eth0 system_u_bin_t_l2h system_u_bin_t_l2h) ;different contexts? (fsuse xattr ext3 system_u_bin_t_l2h)
libsepol/include/sepol/policydb/policydb.h +4 -4
@@ -299,7 +299,7 @@ typedef struct range_trans_rule {/* * The configuration data includes security contexts for -* initial SIDs, unlabeled file systems, TCP and UDP port numbers, +* initial SIDs, unlabeled file systems, TCP, UDP, DCCP and SCTP port numbers, * network interfaces, and nodes. This structure stores the * relevant data for one such entry. Entries of the same kind * (e.g. all initial SIDs) are linked together into a list.
@@ -311,7 +311,7 @@ typedef struct ocontext {uint8_t protocol;uint16_t low_port;uint16_t high_port; - } port;/* TCP or UDP port information */ + } port;/* TCP, UDP, DCCP or SCTP port information */ struct {uint32_t addr;/* network order */ uint32_t mask;/* network order */
@@ -360,7 +360,7 @@ typedef struct genfs {/* object context array indices */ #define OCON_ISID 0/* initial SIDs */ #define OCON_FS 1/* unlabeled file systems */ -#define OCON_PORT 2/* TCP and UDP port numbers */ +#define OCON_PORT 2/* TCP, UDP, DCCP and SCTP port numbers */ #define OCON_NETIF 3/* network interfaces */ #define OCON_NODE 4/* nodes */ #define OCON_FSUSE 5/* fs_use */
@@ -538,7 +538,7 @@ typedef struct policydb {role_allow_t *role_allow;/* security contexts of initial SIDs, unlabeled file systems, -TCP or UDP port numbers, network interfaces and nodes */ +TCP, UDP, DCCP or SCTP port numbers, network interfaces and nodes */ ocontext_t *ocontexts[OCON_NUM ];/* security contexts for files in filesystems that cannot support
libsepol/include/sepol/port_record.h +2 -0
@@ -11,6 +11,8 @@ typedef struct sepol_port_key sepol_port_key_t;#define SEPOL_PROTO_UDP 0#define SEPOL_PROTO_TCP 1 +#define SEPOL_PROTO_DCCP 2 +#define SEPOL_PROTO_SCTP 3/* Key */ extern int sepol_port_compare(const sepol_port_t * port,
libsepol/src/port_record.c +4 -0
@@ -184,6 +184,10 @@ const char *sepol_port_get_proto_str(int proto)return "udp" ;case SEPOL_PROTO_TCP :return "tcp" ; +case SEPOL_PROTO_DCCP : +return "dccp" ; +case SEPOL_PROTO_SCTP : +return "sctp" ;default :return "???" ; }
libsepol/src/ports.c +8 -0
@@ -16,6 +16,10 @@ static inline int sepol2ipproto(sepol_handle_t * handle, int proto)return IPPROTO_TCP ;case SEPOL_PROTO_UDP :return IPPROTO_UDP ; +case SEPOL_PROTO_DCCP : +return IPPROTO_DCCP ; +case SEPOL_PROTO_SCTP : +return IPPROTO_SCTP ;default :ERR (handle,"unsupported protocol %u" , proto);return STATUS_ERR ;
@@ -30,6 +34,10 @@ static inline int ipproto2sepol(sepol_handle_t * handle, int proto)return SEPOL_PROTO_TCP ;case IPPROTO_UDP :return SEPOL_PROTO_UDP ; +case IPPROTO_DCCP : +return SEPOL_PROTO_DCCP ; +case IPPROTO_SCTP : +return SEPOL_PROTO_SCTP ;default :ERR (handle,"invalid protocol %u " "found in policy" , proto);return STATUS_ERR ;
Signature · 1 line
1.9.3
From 69c757b3f0e42041c917d8a8c935449a1f17d6d2 Mon Sep 17 00:00:00 2001
From: Richard Haines <[email protected]>
Date: Thu, 6 Nov 2014 19:32:39 +0000
Subject: [PATCH] lksctp-tools: Add SELinux support to sctp_test
Add getcon, getpeercon and fgetfilecon to check each of the contexts for sctp_test.c. This will allow testing of the SELinux kernel updates to support SCTP.
--- configure.ac | 3 +++ src/apps/Makefile.am | 4 ++++ src/apps/sctp_test.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 70 insertions(+), 2 deletions(-)
configure.ac +3 -0
@@ -38,6 +38,9 @@ AC_LIBTOOL_DLOPEN AC_PROG_LIBTOOL AC_SUBST(LIBTOOL_DEPS) +AC_CHECK_LIB([selinux], [getcon]) +AM_CONDITIONAL([USE_SELINUX], [test $ac_cv_lib_selinux_getcon = yes]) + dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT
src/apps/Makefile.am +4 -0
@@ -10,6 +10,10 @@ AM_CPPFLAGS = -I. -I$(top_srcdir)/src/include -I$(top_srcdir)/src/testlib \ AM_LDFLAGS = +if USE_SELINUX +AM_CFLAGS = -DHAVE_SELINUX +endif + LDADD = $(top_builddir)/src/testlib/libsctputil.la \ $(top_builddir)/src/lib/libsctp.la
src/apps/sctp_test.c +63 -2
138 lines not on this page · raw message
Signature · 1 line
1.9.3