SELinux-sctp.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. SCTP SELinux Support
  2. =====================
  3. Security Hooks
  4. ===============
  5. ``Documentation/security/LSM-sctp.rst`` describes the following SCTP security
  6. hooks with the SELinux specifics expanded below::
  7. security_sctp_assoc_request()
  8. security_sctp_bind_connect()
  9. security_sctp_sk_clone()
  10. security_inet_conn_established()
  11. security_sctp_assoc_request()
  12. -----------------------------
  13. Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the
  14. security module. Returns 0 on success, error on failure.
  15. ::
  16. @ep - pointer to sctp endpoint structure.
  17. @skb - pointer to skbuff of association packet.
  18. The security module performs the following operations:
  19. IF this is the first association on ``@ep->base.sk``, then set the peer
  20. sid to that in ``@skb``. This will ensure there is only one peer sid
  21. assigned to ``@ep->base.sk`` that may support multiple associations.
  22. ELSE validate the ``@ep->base.sk peer_sid`` against the ``@skb peer sid``
  23. to determine whether the association should be allowed or denied.
  24. Set the sctp ``@ep sid`` to socket's sid (from ``ep->base.sk``) with
  25. MLS portion taken from ``@skb peer sid``. This will be used by SCTP
  26. TCP style sockets and peeled off connections as they cause a new socket
  27. to be generated.
  28. If IP security options are configured (CIPSO/CALIPSO), then the ip
  29. options are set on the socket.
  30. security_sctp_bind_connect()
  31. -----------------------------
  32. Checks permissions required for ipv4/ipv6 addresses based on the ``@optname``
  33. as follows::
  34. ------------------------------------------------------------------
  35. | BIND Permission Checks |
  36. | @optname | @address contains |
  37. |----------------------------|-----------------------------------|
  38. | SCTP_SOCKOPT_BINDX_ADD | One or more ipv4 / ipv6 addresses |
  39. | SCTP_PRIMARY_ADDR | Single ipv4 or ipv6 address |
  40. | SCTP_SET_PEER_PRIMARY_ADDR | Single ipv4 or ipv6 address |
  41. ------------------------------------------------------------------
  42. ------------------------------------------------------------------
  43. | CONNECT Permission Checks |
  44. | @optname | @address contains |
  45. |----------------------------|-----------------------------------|
  46. | SCTP_SOCKOPT_CONNECTX | One or more ipv4 / ipv6 addresses |
  47. | SCTP_PARAM_ADD_IP | One or more ipv4 / ipv6 addresses |
  48. | SCTP_SENDMSG_CONNECT | Single ipv4 or ipv6 address |
  49. | SCTP_PARAM_SET_PRIMARY | Single ipv4 or ipv6 address |
  50. ------------------------------------------------------------------
  51. ``Documentation/security/LSM-sctp.rst`` gives a summary of the ``@optname``
  52. entries and also describes ASCONF chunk processing when Dynamic Address
  53. Reconfiguration is enabled.
  54. security_sctp_sk_clone()
  55. -------------------------
  56. Called whenever a new socket is created by **accept**\(2) (i.e. a TCP style
  57. socket) or when a socket is 'peeled off' e.g userspace calls
  58. **sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new
  59. sockets sid and peer sid to that contained in the ``@ep sid`` and
  60. ``@ep peer sid`` respectively.
  61. ::
  62. @ep - pointer to current sctp endpoint structure.
  63. @sk - pointer to current sock structure.
  64. @sk - pointer to new sock structure.
  65. security_inet_conn_established()
  66. ---------------------------------
  67. Called when a COOKIE ACK is received where it sets the connection's peer sid
  68. to that in ``@skb``::
  69. @sk - pointer to sock structure.
  70. @skb - pointer to skbuff of the COOKIE ACK packet.
  71. Policy Statements
  72. ==================
  73. The following class and permissions to support SCTP are available within the
  74. kernel::
  75. class sctp_socket inherits socket { node_bind }
  76. whenever the following policy capability is enabled::
  77. policycap extended_socket_class;
  78. SELinux SCTP support adds the ``name_connect`` permission for connecting
  79. to a specific port type and the ``association`` permission that is explained
  80. in the section below.
  81. If userspace tools have been updated, SCTP will support the ``portcon``
  82. statement as shown in the following example::
  83. portcon sctp 1024-1036 system_u:object_r:sctp_ports_t:s0
  84. SCTP Peer Labeling
  85. ===================
  86. An SCTP socket will only have one peer label assigned to it. This will be
  87. assigned during the establishment of the first association. Any further
  88. associations on this socket will have their packet peer label compared to
  89. the sockets peer label, and only if they are different will the
  90. ``association`` permission be validated. This is validated by checking the
  91. socket peer sid against the received packets peer sid to determine whether
  92. the association should be allowed or denied.
  93. NOTES:
  94. 1) If peer labeling is not enabled, then the peer context will always be
  95. ``SECINITSID_UNLABELED`` (``unlabeled_t`` in Reference Policy).
  96. 2) As SCTP can support more than one transport address per endpoint
  97. (multi-homing) on a single socket, it is possible to configure policy
  98. and NetLabel to provide different peer labels for each of these. As the
  99. socket peer label is determined by the first associations transport
  100. address, it is recommended that all peer labels are consistent.
  101. 3) **getpeercon**\(3) may be used by userspace to retrieve the sockets peer
  102. context.
  103. 4) While not SCTP specific, be aware when using NetLabel that if a label
  104. is assigned to a specific interface, and that interface 'goes down',
  105. then the NetLabel service will remove the entry. Therefore ensure that
  106. the network startup scripts call **netlabelctl**\(8) to set the required
  107. label (see **netlabel-config**\(8) helper script for details).
  108. 5) The NetLabel SCTP peer labeling rules apply as discussed in the following
  109. set of posts tagged "netlabel" at: http://www.paul-moore.com/blog/t.
  110. 6) CIPSO is only supported for IPv4 addressing: ``socket(AF_INET, ...)``
  111. CALIPSO is only supported for IPv6 addressing: ``socket(AF_INET6, ...)``
  112. Note the following when testing CIPSO/CALIPSO:
  113. a) CIPSO will send an ICMP packet if an SCTP packet cannot be
  114. delivered because of an invalid label.
  115. b) CALIPSO does not send an ICMP packet, just silently discards it.
  116. 7) IPSEC is not supported as RFC 3554 - sctp/ipsec support has not been
  117. implemented in userspace (**racoon**\(8) or **ipsec_pluto**\(8)),
  118. although the kernel supports SCTP/IPSEC.