Add SELinux SCTP protocol support
Subsystems (6)
Marcelo Ricardo Leitner
maintainerv3 cover Add SELinux SCTP protocol support
Posting on behalf of Richard Haines. Patchset is based on selinux-tree/next. Some small conflicts are expected when merging with current net-next due to I-Data patches, including one at include/uapi/linux/sctp.h, on which the fix is to update the define SCTP_SENDMSG_CONNECT to a higher number.
Below is the original cover letter from Richard, and the changes from v2->v3.
The kernel patches have been built on Fedora 27 with kernel 4.13.12 plus the following userspace patches to enable testing:
1) Updates to libsepol 2.7 to support the sctp portcon statement. The patch is available from:
http://arctic.selinuxproject.org/~rhaines/selinux-sctp/
selinux-Add-support-for-the-SCTP-portcon-keyword.patch
2) Updates to the SELinux Test Suite adding SCTP tests. Please read the selinux-testsuite/README.sctp for details. The patch is available from:
http://arctic.selinuxproject.org/~rhaines/selinux-sctp/
selinux-testsuite-Add-SCTP-test-support.patch
3) Updates to lksctp-tools that show SELinux info in sctp_darn and sctp_test. It also contains a minor patch for test_1_to_1_connect.c as when CIPSO/CALIPSO configured, NetLabel returns a different error code for illegal addresses in test 5. The patch is available from:
http://arctic.selinuxproject.org/~rhaines/selinux-sctp/
lksctp-tools-Add-SELinux-support-to-sctp_test-and-sc.patch
All SCTP lksctp-tools/src/func_tests run correctly in enforcing mode.
All SCTP regression tests "./sctp-tests run" run correctly in enforcing mode. These tests are obtained from: https://github.com/sctp/sctp-tests
The selinux-testsuite patch also adds remote tests (that need some manual configuration). These are useful for testing CIPSO/CALIPSO over a network with a number of categories to produce large ip option fields with various message sizes forcing fragmentation etc..
Changes since RFC Patch:
Removed the NetLabel patch (was [RFC PATCH 4/5] netlabel: Add SCTP support) as re-engineered. However this patchset will require the NetLabel patch at [1] to fully run the SCTP selinux-testsuite.
PATCH 1/4
Remove unused parameter from security_sctp_assoc_request(). Reformat and update LSM-sctp.rst documentation.
PATCH 2/4
Add variables and RCU locks as requested in [2] to support IP options. PATCH 3/4
Added security_sctp_assoc_request() hook to sctp_sf_do_unexpected_init() and sctp_sf_do_5_2_4_dupcook().
Removed security_sctp_assoc_request() hook from sctp_sf_do_5_1C_ack() as no longer required.
PATCH 4/4
Reformat and update SELinux-sctp.rst documentation.
Remove bindx and connectx permissions.
Rework selinux_socket_connect() and selinux_netlbl_socket_connect() to utilise helpers for code reuse.
Add spinlock to selinux_sctp_assoc_request().
Remove unused parameter from security_sctp_assoc_request(). Use address->sa_family = AF_INET in *_bind and *_connect to ensure correct address type.
Minor cleanups.
Changes since v2 post by Richard:
Updated sctp_frag_point() to also consider the ip options len.
[1] https://marc.info/?l=selinux&m1061619115945&w=2
[2] https://marc.info/?l=selinux&m0962470215797&w=2
Richard Haines (4):
security: Add support for SCTP security hooks
sctp: Add ip option support
sctp: Add LSM hooks
selinux: Add SCTP support
Documentation/security/LSM-sctp.rst | 194 ++++++++++++++++++++++ Documentation/security/SELinux-sctp.rst | 104 ++++++++++++ include/linux/lsm_hooks.h | 35 ++++ include/linux/security.h | 25 +++ include/net/sctp/sctp.h | 4 +- include/net/sctp/structs.h | 12 ++ include/uapi/linux/sctp.h | 1 + net/sctp/chunk.c | 13 +- net/sctp/ipv6.c | 42 ++++- net/sctp/output.c | 5 +- net/sctp/protocol.c | 36 +++++ net/sctp/sm_make_chunk.c | 12 ++ net/sctp/sm_statefuns.c | 18 +++ net/sctp/socket.c | 70 +++++++- security/security.c | 22 +++ security/selinux/hooks.c | 278 +++++++++++++++++++++++++++++--- security/selinux/include/classmap.h | 2 +- security/selinux/include/netlabel.h | 15 +- security/selinux/include/objsec.h | 4 + security/selinux/netlabel.c | 128 +++++++++++++-- 20 files changed, 971 insertions(+), 49 deletions(-) create mode 100644 Documentation/security/LSM-sctp.rst create mode 100644 Documentation/security/SELinux-sctp.rst
Signature · 1 line
2.14.3
Marcelo Ricardo Leitner
maintainerPATCH v3 1/4 security: Add support for SCTP security hooks
From: Richard Haines <[email protected]>
The SCTP security hooks are explained in:Documentation/security/LSM-sctp.rst
--- Documentation/security/LSM-sctp.rst | 194 ++++++++++++++++++++++++++++++++++++ include/linux/lsm_hooks.h | 35 +++++++ include/linux/security.h | 25 +++++ security/security.c | 22 ++++ 4 files changed, 276 insertions(+) create mode 100644 Documentation/security/LSM-sctp.rst
Documentation/security/LSM-sctp.rst new file +192 -0
@@ -0,0 +1,194 @@ +SCTP LSM Support +======== + +For security module support, three sctp specific hooks have been implemented:: + + security_sctp_assoc_request() + security_sctp_bind_connect() + security_sctp_sk_clone() + +Also the following security hook has been utilised:: + + security_inet_conn_established() + +The usage of these hooks are described below with the SELinux implementation +described in ``Documentation/security/SELinux-sctp.rst`` + + +security_sctp_assoc_request() +----------------------------- +This new hook passes the ``@ep`` and ``@chunk->skb`` (the association INIT +packet) to the security module. Returns 0 on success, error on failure. +:: + + @ep - pointer to sctp endpoint structure. + @skb - pointer to skbuff of association packet. + +The security module performs the following operations: + IF this is the first association on ``@ep->base.sk``, then set the peer + sid to that in ``@skb``. This will ensure there is only one peer sid + assigned to ``@ep->base.sk`` that may support multiple associations. + + ELSE validate the ``@ep->base.sk peer_sid`` against the ``@skb peer sid`` + to determine whether the association should be allowed or denied. + + Set the sctp ``@ep sid`` to socket's sid (from ``ep->base.sk``) with + MLS portion taken from ``@skb peer sid``. This will be used by SCTP + TCP style sockets and peeled off connections as they cause a new socket + to be generated. + + If IP security options are configured (CIPSO/CALIPSO), then the ip + options are set on the socket. + + +security_sctp_bind_connect() +----------------------------- +This new hook passes one or more ipv4/ipv6 addresses to the security module +for validation based on the ``@optname`` that will result in either a bind or +connect service as shown in the permission check tables below. +Returns 0 on success, error on failure. +:: + + @sk - Pointer to sock structure. + @optname - Name of the option to validate. + @address - One or more ipv4 / ipv6 addresses. + @addrlen - The total length of address(s). This is calculated on each + ipv4 or ipv6 address using sizeof(struct sockaddr_in) or + sizeof(struct sockaddr_in6). + + ------------------------------------------------------------------ + | BIND Type Checks | + | @optname | @address contains | + |----------------------------|-----------------------------------| + | SCTP_SOCKOPT_BINDX_ADD | One or more ipv4 / ipv6 addresses | + | SCTP_PRIMARY_ADDR | Single ipv4 or ipv6 address | + | SCTP_SET_PEER_PRIMARY_ADDR | Single ipv4 or ipv6 address | + ------------------------------------------------------------------ + + ------------------------------------------------------------------ + | CONNECT Type Checks | + | @optname | @address contains | + |----------------------------|-----------------------------------| + | SCTP_SOCKOPT_CONNECTX | One or more ipv4 / ipv6 addresses | + | SCTP_PARAM_ADD_IP | One or more ipv4 / ipv6 addresses | + | SCTP_SENDMSG_CONNECT | Single ipv4 or ipv6 address | + | SCTP_PARAM_SET_PRIMARY | Single ipv4 or ipv6 address | + ------------------------------------------------------------------ + +A summary of the ``@optname`` entries is as follows:: + + SCTP_SOCKOPT_BINDX_ADD - Allows additional bind addresses to be + associated after (optionally) calling + bind(3). + sctp_bindx(3) adds a set of bind + addresses on a socket. + + SCTP_SOCKOPT_CONNECTX - Allows the allocation of multiple + addresses for reaching a peer + (multi-homed). + sctp_connectx(3) initiates a connection + on an SCTP socket using multiple + destination addresses. + + SCTP_SENDMSG_CONNECT - Initiate a connection that is generated by a + sendmsg(2) or sctp_sendmsg(3) on a new asociation. + + SCTP_PRIMARY_ADDR - Set local primary address. + + SCTP_SET_PEER_PRIMARY_ADDR - Request peer sets address as + association primary. + + SCTP_PARAM_ADD_IP - These are used when Dynamic Address + SCTP_PARAM_SET_PRIMARY - Reconfiguration is enabled as explained below. + + +To support Dynamic Address Reconfiguration the following parameters must be +enabled on both endpoints (or use the appropriate **setsockopt**\(2)):: + + /proc/sys/net/sctp/addip_enable + /proc/sys/net/sctp/addip_noauth_enable + +then the following *_PARAM_*'s are sent to the peer in an +ASCONF chunk when the corresponding ``@optname``'s are present:: + + @optname ASCONF Parameter + ---------- ------------------ + SCTP_SOCKOPT_BINDX_ADD -> SCTP_PARAM_ADD_IP + SCTP_SET_PEER_PRIMARY_ADDR -> SCTP_PARAM_SET_PRIMARY + + +security_sctp_sk_clone() +------------------------- +This new hook is called whenever a new socket is created by **accept**\(2) +(i.e. a TCP style socket) or when a socket is 'peeled off' e.g userspace +calls **sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new +sockets sid and peer sid to that contained in the ``@ep sid`` and +``@ep peer sid`` respectively. +:: + + @ep - pointer to old sctp endpoint structure. + @sk - pointer to old sock structure. + @sk - pointer to new sock structure. + + +security_inet_conn_established() +--------------------------------- +This hook has been added to the receive COOKIE ACK processing where it sets +the connection's peer sid to that in ``@skb``:: + + @sk - pointer to sock structure. + @skb - pointer to skbuff of the COOKIE ACK packet. + + +Security Hooks used for Association Establishment +========================+The following diagram shows the use of ``security_sctp_connect_bind()``, +``security_sctp_assoc_request()``, ``security_inet_conn_established()`` when +establishing an association. +:: + + SCTP endpoint "A" SCTP endpoint "Z" + ========= ========+ sctp_sf_do_prm_asoc() + Association setup can be initiated + by a connect(2), sctp_connectx(3), + sendmsg(2) or sctp_sendmsg(3). + These will result in a call to + security_sctp_bind_connect() to + initiate an association to + SCTP peer endpoint "Z". + INIT ---------------------------------------------> + sctp_sf_do_5_1B_init() + Respond to an INIT chunk. + SCTP peer endpoint "A" is + asking for an association. Call + security_sctp_assoc_request() + to set the peer label if first + association. + If not first association, check + whether allowed, IF so send: + <----------------------------------------------- INIT ACK + | ELSE audit event and silently + | discard the packet. + | + COOKIE ECHO ------------------------------------------> + | + | + | + <------------------------------------------- COOKIE ACK + | | + sctp_sf_do_5_1E_ca | + Call security_inet_conn_established() | + to set the correct peer sid. | + | | + | If SCTP_SOCKET_TCP or peeled off + | socket security_sctp_sk_clone() is + | called to clone the new socket. + | | + ESTABLISHED ESTABLISHED + | | + ------------------------------------------------------------------ + | Association Established | + ------------------------------------------------------------------ + +
include/linux/lsm_hooks.h +35 -0
@@ -906,6 +906,32 @@* associated with the TUN device's security structure. * @security pointer to the TUN devices's security structure. * +* Security hooks for SCTP +* +* @sctp_assoc_request: +* If first association, then set the peer sid to that in @skb. If +* @sctp_cid is from an INIT chunk, then set the sctp endpoint sid to +* socket's sid (ep->base.sk) with MLS portion taken from peer sid. +* @ep pointer to sctp endpoint structure. +* @skb pointer to skbuff of association packet. +* Return 0 on success, error on failure. +* @sctp_bind_connect: +* Validiate permissions required for each address associated with sock +* @sk. Depending on @optname, the addresses will be treated as either +* for a connect or bind service. The @addrlen is calculated on each +* ipv4 and ipv6 address using sizeof(struct sockaddr_in) or +* sizeof(struct sockaddr_in6). +* @sk pointer to sock structure. +* @optname name of the option to validate. +* @address list containing one or more ipv4/ipv6 addresses. +* @addrlen total length of address(s). +* Return 0 on success, error on failure. +* @sctp_sk_clone: +* Sets the new child socket's sid to the old endpoint sid. +* @ep pointer to old sctp endpoint structure. +* @sk pointer to old sock structure. +* @sk pointer to new sock structure. +* * Security hooks for Infiniband * * @ib_pkey_access:
@@ -1631,6 +1657,12 @@ union security_list_options {int (*tun_dev_attach_queue)(void *security);int (*tun_dev_attach)(struct sock *sk,void *security);int (*tun_dev_open)(void *security); +int (*sctp_assoc_request)(struct sctp_endpoint *ep, +struct sk_buff *skb); +int (*sctp_bind_connect)(struct sock *sk,int optname, +struct sockaddr *address,int addrlen); +void (*sctp_sk_clone)(struct sctp_endpoint *ep,struct sock *sk, +struct sock *newsk);#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND
@@ -1869,6 +1901,9 @@ struct security_hook_heads {struct list_head tun_dev_attach_queue;struct list_head tun_dev_attach;struct list_head tun_dev_open; +struct list_head sctp_assoc_request; +struct list_head sctp_bind_connect; +struct list_head sctp_sk_clone;#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND struct list_head ib_pkey_access;
include/linux/security.h +25 -0
@@ -115,6 +115,7 @@ struct xfrm_policy;struct xfrm_state ;struct xfrm_user_sec_ctx ;struct seq_file ; +struct sctp_endpoint ;#ifdef CONFIG_MMU extern unsigned long mmap_min_addr;
@@ -1229,6 +1230,11 @@ int security_tun_dev_create(void);int security_tun_dev_attach_queue (void *security);int security_tun_dev_attach (struct sock *sk,void *security);int security_tun_dev_open (void *security); +int security_sctp_assoc_request (struct sctp_endpoint *ep,struct sk_buff *skb); +int security_sctp_bind_connect (struct sock *sk,int optname, +struct sockaddr *address,int addrlen); +void security_sctp_sk_clone (struct sctp_endpoint *ep,struct sock *sk, +struct sock *newsk);#else /* CONFIG_SECURITY_NETWORK */ static inline int security_unix_stream_connect(struct sock *sock,
@@ -1421,6 +1427,25 @@ static inline int security_tun_dev_open(void *security) {return 0 ; } + +static inline int security_sctp_assoc_request (struct sctp_endpoint *ep, +struct sk_buff *skb) +{ +return 0 ; +} + +static inline int security_sctp_bind_connect (struct sock *sk,int optname, +struct sockaddr *address, +int addrlen) +{ +return 0 ; +} + +static inline void security_sctp_sk_clone (struct sctp_endpoint *ep, +struct sock *sk, +struct sock *newsk) +{ +}#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND
security/security.c +22 -0
@@ -1472,6 +1472,7 @@ void security_inet_conn_established(struct sock *sk, {call_void_hook (inet_conn_established, sk, skb); } +EXPORT_SYMBOL (security_inet_conn_established);int security_secmark_relabel_packet (u32 secid) {
@@ -1527,6 +1528,27 @@ int security_tun_dev_open(void *security) }EXPORT_SYMBOL (security_tun_dev_open); +int security_sctp_assoc_request (struct sctp_endpoint *ep,struct sk_buff *skb) +{ +return call_int_hook (sctp_assoc_request,0 , ep, skb); +} +EXPORT_SYMBOL (security_sctp_assoc_request); + +int security_sctp_bind_connect (struct sock *sk,int optname, +struct sockaddr *address,int addrlen) +{ +return call_int_hook (sctp_bind_connect,0 , sk, optname, + address, addrlen); +} +EXPORT_SYMBOL (security_sctp_bind_connect); + +void security_sctp_sk_clone (struct sctp_endpoint *ep,struct sock *sk, +struct sock *newsk) +{ +call_void_hook (sctp_sk_clone, ep, sk, newsk); +} +EXPORT_SYMBOL (security_sctp_sk_clone); +#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND
Signature · 1 line
2.14.3
Marcelo Ricardo Leitner
maintainerPATCH v3 2/4 sctp: Add ip option support
In reply to Marcelo Ricardo LeitnerFrom: Richard Haines <[email protected]>
Add ip option support to allow LSM security modules to utilise CIPSO/IPv4 and CALIPSO/IPv6 services.
--- include/net/sctp/sctp.h | 4 +++- include/net/sctp/structs.h | 2 ++ net/sctp/chunk.c | 13 ++++++++----- net/sctp/ipv6.c | 42 +++++++++++++++++++++++++++++++++++------- net/sctp/output.c | 5 ++++- net/sctp/protocol.c | 36 ++++++++++++++++++++++++++++++++++++ net/sctp/socket.c | 9 +++++++-- 7 files changed, 95 insertions(+), 16 deletions(-)
include/net/sctp/sctp.h +3 -1
@@ -436,9 +436,11 @@ static inline int sctp_list_single_entry(struct list_head *head)static inline int sctp_frag_point (const struct sctp_association *asoc,int pmtu) {struct sctp_sock *sp =sctp_sk (asoc->base.sk); +struct sctp_af *af = sp->pf->af;int frag = pmtu; - frag -= sp->pf->af->net_header_len; + frag -= af->ip_options_len (asoc->base.sk); + frag -= af->net_header_len; frag -=sizeof (struct sctphdr ) +sizeof (struct sctp_data_chunk );if (asoc->user_frag)
include/net/sctp/structs.h +2 -0
@@ -461,6 +461,7 @@ struct sctp_af {void (*ecn_capable)(struct sock *sk);__u16 net_header_len;int sockaddr_len; +int (*ip_options_len)(struct sock *sk);sa_family_t sa_family;struct list_head list; };
@@ -485,6 +486,7 @@ struct sctp_pf {int (*addr_to_user)(struct sctp_sock *sk,union sctp_addr *addr);void (*to_sk_saddr)(union sctp_addr *,struct sock *sk);void (*to_sk_daddr)(union sctp_addr *,struct sock *sk); +void (*copy_ip_options)(struct sock *sk,struct sock *newsk);struct sctp_af *af; };
net/sctp/chunk.c +8 -5
@@ -153,7 +153,6 @@ static void sctp_datamsg_assign(struct sctp_datamsg *msg, struct sctp_chunk *chu chunk->msg = msg; } -/* A data chunk can have a maximum payload of (2^16 - 20). Break * down any such message into smaller chunks. Opportunistically, fragment * the chunks down to the current MTU constraints. We may get refragmented
@@ -170,6 +169,8 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,struct list_head *pos, *temp;struct sctp_chunk *chunk;struct sctp_datamsg *msg; +struct sctp_sock *sp; +struct sctp_af *af;int err; msg =sctp_datamsg_new (GFP_KERNEL );
@@ -188,9 +189,12 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,/* This is the biggest possible DATA chunk that can fit into * the packet */ - max_data = asoc->pathmtu - -sctp_sk (asoc->base.sk)->pf->af->net_header_len - -sizeof (struct sctphdr ) -sizeof (struct sctp_data_chunk ); + sp =sctp_sk (asoc->base.sk); + af = sp->pf->af; + max_data = asoc->pathmtu - af->net_header_len - +sizeof (struct sctphdr ) -sizeof (struct sctp_data_chunk ) - + af->ip_options_len (asoc->base.sk); + max_data =SCTP_TRUNC4 (max_data);/* If the the peer requested that we authenticate DATA chunks
@@ -210,7 +214,6 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,/* Set first_len and then account for possible bundles on first frag */ first_len = max_data; -/* Check to see if we have a pending SACK and try to let it be bundled * with this message. Do this if we don't have any data queued already. * To check that, look at out_qlen and retransmit list.
net/sctp/ipv6.c +35 -7
72 lines not on this page · raw message
net/sctp/output.c +4 -1
@@ -151,7 +151,10 @@ void sctp_packet_init(struct sctp_packet *packet,INIT_LIST_HEAD (&packet->chunk_list);if (asoc) {struct sctp_sock *sp =sctp_sk (asoc->base.sk); - overhead = sp->pf->af->net_header_len; +struct sctp_af *af = sp->pf->af; + + overhead = af->net_header_len + + af->ip_options_len (asoc->base.sk); }else { overhead =sizeof (struct ipv6hdr ); }
net/sctp/protocol.c +36 -0
@@ -237,6 +237,38 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp,return error; } +/* Copy over any ip options */ +static void sctp_v4_copy_ip_options (struct sock *sk,struct sock *newsk) +{ +struct inet_sock *newinet, *inet =inet_sk (sk); +struct ip_options_rcu *inet_opt, *newopt =NULL ; + + newinet =inet_sk (newsk); + +rcu_read_lock (); + inet_opt =rcu_dereference (inet->inet_opt); +if (inet_opt) { + newopt =sock_kmalloc (newsk,sizeof (*inet_opt) + + inet_opt->opt.optlen,GFP_ATOMIC ); +if (newopt) +memcpy (newopt, inet_opt,sizeof (*inet_opt) + + inet_opt->opt.optlen); + } +RCU_INIT_POINTER (newinet->inet_opt, newopt); +rcu_read_unlock (); +} + +/* Account for the IP options */ +static int sctp_v4_ip_options_len (struct sock *sk) +{ +struct inet_sock *inet =inet_sk (sk); + +if (inet->inet_opt) +return inet->inet_opt->opt.optlen; +else +return 0 ; +} +/* Initialize a sctp_addr from in incoming skb. */ static void sctp_v4_from_skb (union sctp_addr *addr,struct sk_buff *skb,int is_saddr)
@@ -590,6 +622,8 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk,sctp_copy_sock (newsk, sk, asoc);sock_reset_flag (newsk,SOCK_ZAPPED ); +sctp_v4_copy_ip_options (sk, newsk); + newinet =inet_sk (newsk); newinet->inet_daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
@@ -1008,6 +1042,7 @@ static struct sctp_pf sctp_pf_inet = { .addr_to_user = sctp_v4_addr_to_user, .to_sk_saddr = sctp_v4_to_sk_saddr, .to_sk_daddr = sctp_v4_to_sk_daddr, + .copy_ip_options = sctp_v4_copy_ip_options, .af = &sctp_af_inet };
@@ -1092,6 +1127,7 @@ static struct sctp_af sctp_af_inet = { .ecn_capable = sctp_v4_ecn_capable, .net_header_len = sizeof(struct iphdr), .sockaddr_len = sizeof(struct sockaddr_in), + .ip_options_len = sctp_v4_ip_options_len, #ifdef CONFIG_COMPAT .compat_setsockopt = compat_ip_setsockopt, .compat_getsockopt = compat_ip_getsockopt,
net/sctp/socket.c +7 -2
@@ -3125,8 +3125,11 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsignedif (asoc) {if (val =0 ) { +struct sctp_af *af = sp->pf->af; + val = asoc->pathmtu; - val -= sp->pf->af->net_header_len; + val -= af->ip_options_len (asoc->base.sk); + val -= af->net_header_len; val -=sizeof (struct sctphdr ) +sizeof (struct sctp_data_chunk ); }
@@ -4929,9 +4932,11 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)sctp_copy_sock (sock->sk, sk, asoc);/* Make peeled-off sockets more like 1-1 accepted sockets. -* Set the daddr and initialize id to something more random +* Set the daddr and initialize id to something more random and also +* copy over any ip options. */ sp->pf->to_sk_daddr (&asoc->peer.primary_addr, sk); + sp->pf->copy_ip_options (sk, sock->sk);/* Populate the fields of the newsk from the oldsk and migrate the * asoc to the newsk.
Signature · 1 line
2.14.3
Marcelo Ricardo Leitner
maintainerPATCH v3 3/4 sctp: Add LSM hooks
In reply to Marcelo Ricardo LeitnerFrom: Richard Haines <[email protected]>
Add security hooks to allow security modules to exercise access control over SCTP.
--- include/net/sctp/structs.h | 10 ++++++++ include/uapi/linux/sctp.h | 1 + net/sctp/sm_make_chunk.c | 12 +++++++++ net/sctp/sm_statefuns.c | 18 ++++++++++++++ net/sctp/socket.c | 61 +++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 101 insertions(+), 1 deletion(-)
include/net/sctp/structs.h +10 -0
@@ -1271,6 +1271,16 @@ struct sctp_endpoint { reconf_enable:1 ;__u8 strreset_enable; + +/* Security identifiers from incoming (INIT). These are set by +* security_sctp_assoc_request(). These will only be used by +* SCTP TCP type sockets and peeled off connections as they +* cause a new socket to be generated. security_sctp_sk_clone() +* will then plug these into the new socket. +*/ + +u32 secid; +u32 peer_secid; };/* Recover the outter endpoint structure. */
include/uapi/linux/sctp.h +1 -0
@@ -122,6 +122,7 @@ typedef __s32 sctp_assoc_t;#define SCTP_RESET_ASSOC 120#define SCTP_ADD_STREAMS 121#define SCTP_SOCKOPT_PEELOFF_FLAGS 122 +#define SCTP_SENDMSG_CONNECT 123/* PR-SCTP policies */ #define SCTP_PR_SCTP_NONE 0x0000
net/sctp/sm_make_chunk.c +12 -0
@@ -3054,6 +3054,12 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,if (af->is_any (&addr))memcpy (&addr, &asconf->source,sizeof (addr)); +if (security_sctp_bind_connect (asoc->ep->base.sk, +SCTP_PARAM_ADD_IP , + (struct sockaddr *)&addr, + af->sockaddr_len)) +return SCTP_ERROR_REQ_REFUSED ; +/* ADDIP 4.3 D9) If an endpoint receives an ADD IP address * request and does not have the local resources to add this * new address to the association, it MUST return an Error
@@ -3120,6 +3126,12 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,if (af->is_any (&addr))memcpy (&addr.v4,sctp_source (asconf),sizeof (addr)); +if (security_sctp_bind_connect (asoc->ep->base.sk, +SCTP_PARAM_SET_PRIMARY , + (struct sockaddr *)&addr, + af->sockaddr_len)) +return SCTP_ERROR_REQ_REFUSED ; + peer =sctp_assoc_lookup_paddr (asoc, &addr);if (!peer)return SCTP_ERROR_DNS_FAILED ;
net/sctp/sm_statefuns.c +18 -0
@@ -318,6 +318,11 @@ enum sctp_disposition sctp_sf_do_5_1B_init(struct net *net,struct sctp_packet *packet;int len; +/* Update socket peer label if first association. */ +if (security_sctp_assoc_request ((struct sctp_endpoint *)ep, + chunk->skb)) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); +/* 6.10 Bundling * An endpoint MUST NOT bundle INIT, INIT ACK or * SHUTDOWN COMPLETE with any other chunks.
@@ -905,6 +910,9 @@ enum sctp_disposition sctp_sf_do_5_1E_ca(struct net *net,*/ sctp_add_cmd_sf (commands,SCTP_CMD_INIT_COUNTER_RESET ,SCTP_NULL ()); +/* Set peer label for connection. */ +security_inet_conn_established (ep->base.sk, chunk->skb); +/* RFC 2960 5.1 Normal Establishment of an Association * * E) Upon reception of the COOKIE ACK, endpoint "A" will move
@@ -1433,6 +1441,11 @@ static enum sctp_disposition sctp_sf_do_unexpected_init(struct sctp_packet *packet;int len; +/* Update socket peer label if first association. */ +if (security_sctp_assoc_request ((struct sctp_endpoint *)ep, + chunk->skb)) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); +/* 6.10 Bundling * An endpoint MUST NOT bundle INIT, INIT ACK or * SHUTDOWN COMPLETE with any other chunks.
@@ -2103,6 +2116,11 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook( } } +/* Update socket peer label if first association. */ +if (security_sctp_assoc_request ((struct sctp_endpoint *)ep, + chunk->skb)) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); +/* Set temp so that it won't be added into hashtable */ new_asoc->temp =1 ;
net/sctp/socket.c +60 -1
124 lines not on this page · raw message
Signature · 1 line
2.14.3
Marcelo Ricardo Leitner
maintainerPATCH v3 4/4 selinux: Add SCTP support
In reply to Marcelo Ricardo LeitnerFrom: Richard Haines <[email protected]>
The SELinux SCTP implementation is explained in:Documentation/security/SELinux-sctp.rst
--- Documentation/security/SELinux-sctp.rst | 104 ++++++++++++ security/selinux/hooks.c | 278 +++++++++++++++++++++++++++++--- security/selinux/include/classmap.h | 2 +- security/selinux/include/netlabel.h | 15 +- security/selinux/include/objsec.h | 4 + security/selinux/netlabel.c | 128 +++++++++++++-- 6 files changed, 499 insertions(+), 32 deletions(-) create mode 100644 Documentation/security/SELinux-sctp.rst
Documentation/security/SELinux-sctp.rst new file +101 -0
@@ -0,0 +1,104 @@ +SCTP SELinux Support +==========+ +Security Hooks +=======+ +The ``Documentation/security/LSM-sctp.rst`` document describes how the +following sctp security hooks are utilised:: + + security_sctp_assoc_request() + security_sctp_bind_connect() + security_sctp_sk_clone() + security_inet_conn_established() + + +Policy Statements +========= +The following class and permissions to support SCTP are available within the +kernel:: + + class sctp_socket inherits socket { node_bind } + +whenever the following policy capability is enabled:: + + policycap extended_socket_class; + +SELinux SCTP support adds the ``name_connect`` permission for connecting +to a specific port type and the ``association`` permission that is explained +in the section below. + +If userspace tools have been updated, SCTP will support the ``portcon`` +statement as shown in the following example:: + + portcon sctp 1024-1036 system_u:object_r:sctp_ports_t:s0 + + +SCTP Bind, Connect and ASCONF Chunk Parameter Permission Checks +================================ +The hook ``security_sctp_bind_connect()`` is called by SCTP to check +permissions required for ipv4/ipv6 addresses based on the ``@optname`` as +follows:: + + ------------------------------------------------------------------ + | BIND Permission Checks | + | @optname | @address contains | + |----------------------------|-----------------------------------| + | SCTP_SOCKOPT_BINDX_ADD | One or more ipv4 / ipv6 addresses | + | SCTP_PRIMARY_ADDR | Single ipv4 or ipv6 address | + | SCTP_SET_PEER_PRIMARY_ADDR | Single ipv4 or ipv6 address | + ------------------------------------------------------------------ + + ------------------------------------------------------------------ + | CONNECT Permission Checks | + | @optname | @address contains | + |----------------------------|-----------------------------------| + | SCTP_SOCKOPT_CONNECTX | One or more ipv4 / ipv6 addresses | + | SCTP_PARAM_ADD_IP | One or more ipv4 / ipv6 addresses | + | SCTP_SENDMSG_CONNECT | Single ipv4 or ipv6 address | + | SCTP_PARAM_SET_PRIMARY | Single ipv4 or ipv6 address | + ------------------------------------------------------------------ + + +SCTP Peer Labeling +=========+An SCTP socket will only have one peer label assigned to it. This will be +assigned during the establishment of the first association. Once the peer +label has been assigned, any new associations will have the ``association`` +permission validated by checking the socket peer sid against the received +packets peer sid to determine whether the association should be allowed or +denied. + +NOTES: + 1) If peer labeling is not enabled, then the peer context will always be + ``SECINITSID_UNLABELED`` (``unlabeled_t`` in Reference Policy). + + 2) As SCTP can support more than one transport address per endpoint + (multi-homing) on a single socket, it is possible to configure policy + and NetLabel to provide different peer labels for each of these. As the + socket peer label is determined by the first associations transport + address, it is recommended that all peer labels are consistent. + + 3) **getpeercon**\(3) may be used by userspace to retrieve the sockets peer + context. + + 4) While not SCTP specific, be aware when using NetLabel that if a label + is assigned to a specific interface, and that interface 'goes down', + then the NetLabel service will remove the entry. Therefore ensure that + the network startup scripts call **netlabelctl**\(8) to set the required + label (see **netlabel-config**\(8) helper script for details). + + 5) The NetLabel SCTP peer labeling rules apply as discussed in the following + set of posts tagged "netlabel" at: http://www.paul-moore.com/blog/t. + + 6) CIPSO is only supported for IPv4 addressing: ``socket(AF_INET, ...)`` + CALIPSO is only supported for IPv6 addressing: ``socket(AF_INET6, ...)`` + + Note the following when testing CIPSO/CALIPSO: + a) CIPSO will send an ICMP packet if an SCTP packet cannot be + delivered because of an invalid label. + b) CALIPSO does not send an ICMP packet, just silently discards it. + + 7) IPSEC is not supported as RFC 3554 - sctp/ipsec support has not been + implemented in userspace (**racoon**\(8) or **ipsec_pluto**\(8)), + although the kernel supports SCTP/IPSEC.
security/selinux/hooks.c +259 -19
380 lines not on this page · raw message
security/selinux/include/classmap.h +1 -1
@@ -175,7 +175,7 @@ struct security_class_mapping secclass_map[] = { { COMMON_CAP2_PERMS, NULL } }, {"sctp_socket" , { COMMON_SOCK_PERMS, - "node_bind", NULL } }, + "node_bind", "name_connect", "association", NULL } }, {"icmp_socket" , { COMMON_SOCK_PERMS, "node_bind", NULL } },
security/selinux/include/netlabel.h +14 -1
@@ -32,6 +32,7 @@#include <linux/skbuff.h> #include <net/sock.h> #include <net/request_sock.h> +#include <net/sctp/structs.h> #include "avc.h" #include "objsec.h"
@@ -52,7 +53,8 @@ int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,int selinux_netlbl_skbuff_setsid (struct sk_buff *skb,u16 family,u32 sid); - +int selinux_netlbl_sctp_assoc_request (struct sctp_endpoint *ep, +struct sk_buff *skb);int selinux_netlbl_inet_conn_request (struct request_sock *req,u16 family);void selinux_netlbl_inet_csk_clone (struct sock *sk,u16 family);int selinux_netlbl_socket_post_create (struct sock *sk,u16 family);
@@ -64,6 +66,7 @@ int selinux_netlbl_socket_setsockopt(struct socket *sock,int level, int optname);int selinux_netlbl_socket_connect (struct sock *sk,struct sockaddr *addr); +int selinux_netlbl_sctp_socket_connect (struct sock *sk,struct sockaddr *addr);#else static inline void selinux_netlbl_cache_invalidate (void )
@@ -113,6 +116,11 @@ static inline int selinux_netlbl_conn_setsid(struct sock *sk,return 0 ; } +static inline int selinux_netlbl_sctp_assoc_request (struct sctp_endpoint *ep, +struct sk_buff *skb) +{ +return 0 ; +}static inline int selinux_netlbl_inet_conn_request (struct request_sock *req,u16 family) {
@@ -145,6 +153,11 @@ static inline int selinux_netlbl_socket_connect(struct sock *sk, {return 0 ; } +static inline int selinux_netlbl_sctp_socket_connect (struct sock *sk, +struct sockaddr *addr) +{ +return 0 ; +}#endif /* CONFIG_NETLABEL */ #endif
security/selinux/include/objsec.h +4 -0
@@ -130,6 +130,10 @@ struct sk_security_struct {u32 sid;/* SID of this object */ u32 peer_sid;/* SID of peer */ u16 sclass;/* sock security class */ +enum {/* SCTP association state */ +SCTP_ASSOC_UNSET =0 , +SCTP_ASSOC_SET , + } sctp_assoc_state; };struct tun_security_struct {
security/selinux/netlabel.c +117 -11
172 lines not on this page · raw message
Signature · 1 line
2.14.3
Re: [PATCH v3 1/4] security: Add support for SCTP security hooks
In reply to Marcelo Ricardo LeitnerQuoted 52 lines · Marcelo Ricardo Leitner
From: Richard Haines <[email protected]>
The SCTP security hooks are explained in:
Documentation/security/LSM-sctp.rstSigned-off-by Richard Haines <[email protected]>--- Documentation/security/LSM-sctp.rst | 194 ++++++++++++++++++++++++++++++++++++ include/linux/lsm_hooks.h | 35 +++++++ include/linux/security.h | 25 +++++ security/security.c | 22 ++++ 4 files changed, 276 insertions(+) create mode 100644 Documentation/security/LSM-sctp.rstDocumentation/security/LSM-sctp.rst new file +31
-0@@ -0,0 +1,194 @@ +SCTP LSM Support +======== + +For security module support, three sctp specific hooks have been implemented:: + + security_sctp_assoc_request() + security_sctp_bind_connect() + security_sctp_sk_clone() + +Also the following security hook has been utilised:: + + security_inet_conn_established() + +The usage of these hooks are described below with the SELinux implementation +described in ``Documentation/security/SELinux-sctp.rst`` + + +security_sctp_assoc_request() +----------------------------- +This new hook passes the ``@ep`` and ``@chunk->skb`` (the association INIT +packet) to the security module. Returns 0 on success, error on failure. +:: + + @ep - pointer to sctp endpoint structure. + @skb - pointer to skbuff of association packet. + +The security module performs the following operations: + IF this is the first association on ``@ep->base.sk``, then set the peer + sid to that in ``@skb``. This will ensure there is only one peer sid + assigned to ``@ep->base.sk`` that may support multiple associations. +
Documentation/security/LSM-sctp.rst line 41
Quoted 10 lines
Documentation/security/LSM-sctp.rst new file +10
-0+ ELSE validate the ``@ep->base.sk peer_sid`` against the ``@skb peer sid`` + to determine whether the association should be allowed or denied. + + Set the sctp ``@ep sid`` to socket's sid (from ``ep->base.sk``) with + MLS portion taken from ``@skb peer sid``. This will be used by SCTP + TCP style sockets and peeled off connections as they cause a new socket + to be generated. + + If IP security options are configured (CIPSO/CALIPSO), then the ip + options are set on the socket.
Please! Basing the documentation for the infrastructure behavior on a specific security module implementation makes it *really rough* to adopt it to a different module. It makes it doubly difficult to define how it will work with multiple modules. Take the SELinux specifics out of the documentation for the hooks. Describe the general intention, not how SELinux uses it.
Quoted 80 lines
Documentation/security/LSM-sctp.rst new file +80
-0+ + +security_sctp_bind_connect() +----------------------------- +This new hook passes one or more ipv4/ipv6 addresses to the security module +for validation based on the ``@optname`` that will result in either a bind or +connect service as shown in the permission check tables below. +Returns 0 on success, error on failure. +:: + + @sk - Pointer to sock structure. + @optname - Name of the option to validate. + @address - One or more ipv4 / ipv6 addresses. + @addrlen - The total length of address(s). This is calculated on each + ipv4 or ipv6 address using sizeof(struct sockaddr_in) or + sizeof(struct sockaddr_in6). + + ------------------------------------------------------------------ + | BIND Type Checks | + | @optname | @address contains | + |----------------------------|-----------------------------------| + | SCTP_SOCKOPT_BINDX_ADD | One or more ipv4 / ipv6 addresses | + | SCTP_PRIMARY_ADDR | Single ipv4 or ipv6 address | + | SCTP_SET_PEER_PRIMARY_ADDR | Single ipv4 or ipv6 address | + ------------------------------------------------------------------ + + ------------------------------------------------------------------ + | CONNECT Type Checks | + | @optname | @address contains | + |----------------------------|-----------------------------------| + | SCTP_SOCKOPT_CONNECTX | One or more ipv4 / ipv6 addresses | + | SCTP_PARAM_ADD_IP | One or more ipv4 / ipv6 addresses | + | SCTP_SENDMSG_CONNECT | Single ipv4 or ipv6 address | + | SCTP_PARAM_SET_PRIMARY | Single ipv4 or ipv6 address | + ------------------------------------------------------------------ + +A summary of the ``@optname`` entries is as follows:: + + SCTP_SOCKOPT_BINDX_ADD - Allows additional bind addresses to be + associated after (optionally) calling + bind(3). + sctp_bindx(3) adds a set of bind + addresses on a socket. + + SCTP_SOCKOPT_CONNECTX - Allows the allocation of multiple + addresses for reaching a peer + (multi-homed). + sctp_connectx(3) initiates a connection + on an SCTP socket using multiple + destination addresses. + + SCTP_SENDMSG_CONNECT - Initiate a connection that is generated by a + sendmsg(2) or sctp_sendmsg(3) on a new asociation. + + SCTP_PRIMARY_ADDR - Set local primary address. + + SCTP_SET_PEER_PRIMARY_ADDR - Request peer sets address as + association primary. + + SCTP_PARAM_ADD_IP - These are used when Dynamic Address + SCTP_PARAM_SET_PRIMARY - Reconfiguration is enabled as explained below. + + +To support Dynamic Address Reconfiguration the following parameters must be +enabled on both endpoints (or use the appropriate **setsockopt**\(2)):: + + /proc/sys/net/sctp/addip_enable + /proc/sys/net/sctp/addip_noauth_enable + +then the following *_PARAM_*'s are sent to the peer in an +ASCONF chunk when the corresponding ``@optname``'s are present:: + + @optname ASCONF Parameter + ---------- ------------------ + SCTP_SOCKOPT_BINDX_ADD -> SCTP_PARAM_ADD_IP + SCTP_SET_PEER_PRIMARY_ADDR -> SCTP_PARAM_SET_PRIMARY + + +security_sctp_sk_clone() +-------------------------
Documentation/security/LSM-sctp.rst line 131
Quoted 10 lines
Documentation/security/LSM-sctp.rst new file +10
-0+This new hook is called whenever a new socket is created by **accept**\(2) +(i.e. a TCP style socket) or when a socket is 'peeled off' e.g userspace +calls **sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new +sockets sid and peer sid to that contained in the ``@ep sid`` and +``@ep peer sid`` respectively. +:: + + @ep - pointer to old sctp endpoint structure. + @sk - pointer to old sock structure. + @sk - pointer to new sock structure.
Again, SELinux may set the sids in this way, but another module may treat the hook differently. Don't put SELinux specifics into the infrastructure documentation.
Quoted 66 lines
Documentation/security/LSM-sctp.rst new file +61
-0+ + +security_inet_conn_established() +--------------------------------- +This hook has been added to the receive COOKIE ACK processing where it sets +the connection's peer sid to that in ``@skb``:: + + @sk - pointer to sock structure. + @skb - pointer to skbuff of the COOKIE ACK packet. + + +Security Hooks used for Association Establishment +========================> +The following diagram shows the use of ``security_sctp_connect_bind()``, +``security_sctp_assoc_request()``, ``security_inet_conn_established()`` when +establishing an association. +:: + + SCTP endpoint "A" SCTP endpoint "Z" + ========= ========> + sctp_sf_do_prm_asoc() + Association setup can be initiated + by a connect(2), sctp_connectx(3), + sendmsg(2) or sctp_sendmsg(3). + These will result in a call to + security_sctp_bind_connect() to + initiate an association to + SCTP peer endpoint "Z". + INIT ---------------------------------------------> + sctp_sf_do_5_1B_init() + Respond to an INIT chunk. + SCTP peer endpoint "A" is + asking for an association. Call + security_sctp_assoc_request() + to set the peer label if first + association. + If not first association, check + whether allowed, IF so send: + <----------------------------------------------- INIT ACK + | ELSE audit event and silently + | discard the packet. + | + COOKIE ECHO ------------------------------------------> + | + | + | + <------------------------------------------- COOKIE ACK + | | + sctp_sf_do_5_1E_ca | + Call security_inet_conn_established() | + to set the correct peer sid. | + | | + | If SCTP_SOCKET_TCP or peeled off + | socket security_sctp_sk_clone() is + | called to clone the new socket. + | | + ESTABLISHED ESTABLISHED + | | + ------------------------------------------------------------------ + | Association Established | + ------------------------------------------------------------------ + +include/linux/lsm_hooks.h +0
-0
include/linux/lsm_hooks.h line 914
Quoted 9 lines
include/linux/lsm_hooks.h +6
-0@@ -906,6 +906,32 @@* associated with the TUN device's security structure. * @security pointer to the TUN devices's security structure. * +* Security hooks for SCTP +* +* @sctp_assoc_request: +* If first association, then set the peer sid to that in @skb. If +* @sctp_cid is from an INIT chunk, then set the sctp endpoint sid to +* socket's sid (ep->base.sk) with MLS portion taken from peer sid.
Don't direct the module hook to do something. If the SCTP code knows what every module should do, why not have the SCTP code do it? Do not describe the hook in terms of the SELinux behavior.
Quoted 6 lines
include/linux/lsm_hooks.h +6
-0+* @ep pointer to sctp endpoint structure. +* @skb pointer to skbuff of association packet. +* Return 0 on success, error on failure. +* @sctp_bind_connect: +* Validiate permissions required for each address associated with sock +* @sk. Depending on @optname, the addresses will be treated as either
include/linux/lsm_hooks.h line 930
Quoted 10 lines
include/linux/lsm_hooks.h +10
-0+* for a connect or bind service. The @addrlen is calculated on each +* ipv4 and ipv6 address using sizeof(struct sockaddr_in) or +* sizeof(struct sockaddr_in6). +* @sk pointer to sock structure. +* @optname name of the option to validate. +* @address list containing one or more ipv4/ipv6 addresses. +* @addrlen total length of address(s). +* Return 0 on success, error on failure. +* @sctp_sk_clone: +* Sets the new child socket's sid to the old endpoint sid.
... and again.
Quoted 120 lines
include/linux/lsm_hooks.h +13
-0+* @ep pointer to old sctp endpoint structure. +* @sk pointer to old sock structure. +* @sk pointer to new sock structure. +* * Security hooks for Infiniband * * @ib_pkey_access: @@ -1631,6 +1657,12 @@ union security_list_options {int (*tun_dev_attach_queue)(void *security);int (*tun_dev_attach)(struct sock *sk,void *security);int (*tun_dev_open)(void *security); +int (*sctp_assoc_request)(struct sctp_endpoint *ep, +struct sk_buff *skb); +int (*sctp_bind_connect)(struct sock *sk,int optname, +struct sockaddr *address,int addrlen); +void (*sctp_sk_clone)(struct sctp_endpoint *ep,struct sock *sk, +struct sock *newsk);#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND @@ -1869,6 +1901,9 @@ struct security_hook_heads {struct list_head tun_dev_attach_queue;struct list_head tun_dev_attach;struct list_head tun_dev_open; +struct list_head sctp_assoc_request; +struct list_head sctp_bind_connect; +struct list_head sctp_sk_clone;#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND struct list_head ib_pkey_access;include/linux/security.h +25
-0@@ -115,6 +115,7 @@ struct xfrm_policy;struct xfrm_state ;struct xfrm_user_sec_ctx ;struct seq_file ; +struct sctp_endpoint ;#ifdef CONFIG_MMU extern unsigned long mmap_min_addr;@@ -1229,6 +1230,11 @@ int security_tun_dev_create(void);int security_tun_dev_attach_queue (void *security);int security_tun_dev_attach (struct sock *sk,void *security);int security_tun_dev_open (void *security); +int security_sctp_assoc_request (struct sctp_endpoint *ep,struct sk_buff *skb); +int security_sctp_bind_connect (struct sock *sk,int optname, +struct sockaddr *address,int addrlen); +void security_sctp_sk_clone (struct sctp_endpoint *ep,struct sock *sk, +struct sock *newsk);#else /* CONFIG_SECURITY_NETWORK */ static inline int security_unix_stream_connect(struct sock *sock,@@ -1421,6 +1427,25 @@ static inline int security_tun_dev_open(void *security) {return 0 ; } + +static inline int security_sctp_assoc_request (struct sctp_endpoint *ep, +struct sk_buff *skb) +{ +return 0 ; +} + +static inline int security_sctp_bind_connect (struct sock *sk,int optname, +struct sockaddr *address, +int addrlen) +{ +return 0 ; +} + +static inline void security_sctp_sk_clone (struct sctp_endpoint *ep, +struct sock *sk, +struct sock *newsk) +{ +}#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND security/security.c +22
-0@@ -1472,6 +1472,7 @@ void security_inet_conn_established(struct sock *sk, {call_void_hook (inet_conn_established, sk, skb); } +EXPORT_SYMBOL (security_inet_conn_established);int security_secmark_relabel_packet (u32 secid) {@@ -1527,6 +1528,27 @@ int security_tun_dev_open(void *security) }EXPORT_SYMBOL (security_tun_dev_open); +int security_sctp_assoc_request (struct sctp_endpoint *ep,struct sk_buff *skb) +{ +return call_int_hook (sctp_assoc_request,0 , ep, skb); +} +EXPORT_SYMBOL (security_sctp_assoc_request); + +int security_sctp_bind_connect (struct sock *sk,int optname, +struct sockaddr *address,int addrlen) +{ +return call_int_hook (sctp_bind_connect,0 , sk, optname, + address, addrlen); +} +EXPORT_SYMBOL (security_sctp_bind_connect); + +void security_sctp_sk_clone (struct sctp_endpoint *ep,struct sock *sk, +struct sock *newsk) +{ +call_void_hook (sctp_sk_clone, ep, sk, newsk); +} +EXPORT_SYMBOL (security_sctp_sk_clone); +#endif /* CONFIG_SECURITY_NETWORK */ #ifdef CONFIG_SECURITY_INFINIBAND
Marcelo Ricardo Leitner
maintainerRe: [PATCH v3 1/4] security: Add support for SCTP security hooks
Quoted 5 lines · Casey Schaufler
Quoted 4 lines · Marcelo Ricardo Leitner
From: Richard Haines <[email protected]>
The SCTP security hooks are explained in:
Documentation/security/LSM-sctp.rst
Thanks Casey for your comments. However, I'm not that acquainted with these area of codes and I cannot work on them. I'll just wait for Richard then.
Marcelo
Re: [PATCH v3 1/4] security: Add support for SCTP security hooks
Quoted 10 lines · Marcelo Ricardo Leitner
Quoted 5 lines · Casey Schaufler
Quoted 4 lines · Marcelo Ricardo Leitner
From: Richard Haines <[email protected]>
The SCTP security hooks are explained in:
Documentation/security/LSM-sctp.rstThanks Casey for your comments. However, I'm not that acquainted with these area of codes and I cannot work on them. I'll just wait for Richard then.
I'm back online and will post a V4 set of patches within a week. These will address Paul's comments as per [1] and Casey's regarding the documentation.
Sorry for the delay
[1] https://marc.info/?l=selinux&m1274018809822&w=2
Quoted 7 lines
Marcelo
--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Paul Moore
maintainerRe: [PATCH v3 1/4] security: Add support for SCTP security hooks
Quoted 8 lines · Richard Haines
Quoted 7 lines · Marcelo Ricardo Leitner
Quoted 5 lines · Casey Schaufler
Quoted 4 lines · Marcelo Ricardo Leitner
From: Richard Haines <[email protected]>
The SCTP security hooks are explained in:
Documentation/security/LSM-sctp.rst
Quoted 8 lines
Quoted 3 lines
Thanks Casey for your comments. However, I'm not that acquainted with these area of codes and I cannot work on them. I'll just wait for Richard then.
I'm back online and will post a V4 set of patches within a week. These will address Paul's comments as per [1] and Casey's regarding the documentation.
Sorry for the delay
No worries, thanks.
Signature · 2 lines
paul moore www.paul-moore.com