LSM-sctp.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. SCTP LSM Support
  2. ================
  3. For security module support, three SCTP specific hooks have been implemented::
  4. security_sctp_assoc_request()
  5. security_sctp_bind_connect()
  6. security_sctp_sk_clone()
  7. Also the following security hook has been utilised::
  8. security_inet_conn_established()
  9. The usage of these hooks are described below with the SELinux implementation
  10. described in ``Documentation/security/SELinux-sctp.rst``
  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. security_sctp_bind_connect()
  19. -----------------------------
  20. Passes one or more ipv4/ipv6 addresses to the security module for validation
  21. based on the ``@optname`` that will result in either a bind or connect
  22. service as shown in the permission check tables below.
  23. Returns 0 on success, error on failure.
  24. ::
  25. @sk - Pointer to sock structure.
  26. @optname - Name of the option to validate.
  27. @address - One or more ipv4 / ipv6 addresses.
  28. @addrlen - The total length of address(s). This is calculated on each
  29. ipv4 or ipv6 address using sizeof(struct sockaddr_in) or
  30. sizeof(struct sockaddr_in6).
  31. ------------------------------------------------------------------
  32. | BIND Type Checks |
  33. | @optname | @address contains |
  34. |----------------------------|-----------------------------------|
  35. | SCTP_SOCKOPT_BINDX_ADD | One or more ipv4 / ipv6 addresses |
  36. | SCTP_PRIMARY_ADDR | Single ipv4 or ipv6 address |
  37. | SCTP_SET_PEER_PRIMARY_ADDR | Single ipv4 or ipv6 address |
  38. ------------------------------------------------------------------
  39. ------------------------------------------------------------------
  40. | CONNECT Type Checks |
  41. | @optname | @address contains |
  42. |----------------------------|-----------------------------------|
  43. | SCTP_SOCKOPT_CONNECTX | One or more ipv4 / ipv6 addresses |
  44. | SCTP_PARAM_ADD_IP | One or more ipv4 / ipv6 addresses |
  45. | SCTP_SENDMSG_CONNECT | Single ipv4 or ipv6 address |
  46. | SCTP_PARAM_SET_PRIMARY | Single ipv4 or ipv6 address |
  47. ------------------------------------------------------------------
  48. A summary of the ``@optname`` entries is as follows::
  49. SCTP_SOCKOPT_BINDX_ADD - Allows additional bind addresses to be
  50. associated after (optionally) calling
  51. bind(3).
  52. sctp_bindx(3) adds a set of bind
  53. addresses on a socket.
  54. SCTP_SOCKOPT_CONNECTX - Allows the allocation of multiple
  55. addresses for reaching a peer
  56. (multi-homed).
  57. sctp_connectx(3) initiates a connection
  58. on an SCTP socket using multiple
  59. destination addresses.
  60. SCTP_SENDMSG_CONNECT - Initiate a connection that is generated by a
  61. sendmsg(2) or sctp_sendmsg(3) on a new asociation.
  62. SCTP_PRIMARY_ADDR - Set local primary address.
  63. SCTP_SET_PEER_PRIMARY_ADDR - Request peer sets address as
  64. association primary.
  65. SCTP_PARAM_ADD_IP - These are used when Dynamic Address
  66. SCTP_PARAM_SET_PRIMARY - Reconfiguration is enabled as explained below.
  67. To support Dynamic Address Reconfiguration the following parameters must be
  68. enabled on both endpoints (or use the appropriate **setsockopt**\(2))::
  69. /proc/sys/net/sctp/addip_enable
  70. /proc/sys/net/sctp/addip_noauth_enable
  71. then the following *_PARAM_*'s are sent to the peer in an
  72. ASCONF chunk when the corresponding ``@optname``'s are present::
  73. @optname ASCONF Parameter
  74. ---------- ------------------
  75. SCTP_SOCKOPT_BINDX_ADD -> SCTP_PARAM_ADD_IP
  76. SCTP_SET_PEER_PRIMARY_ADDR -> SCTP_PARAM_SET_PRIMARY
  77. security_sctp_sk_clone()
  78. -------------------------
  79. Called whenever a new socket is created by **accept**\(2)
  80. (i.e. a TCP style socket) or when a socket is 'peeled off' e.g userspace
  81. calls **sctp_peeloff**\(3).
  82. ::
  83. @ep - pointer to current sctp endpoint structure.
  84. @sk - pointer to current sock structure.
  85. @sk - pointer to new sock structure.
  86. security_inet_conn_established()
  87. ---------------------------------
  88. Called when a COOKIE ACK is received::
  89. @sk - pointer to sock structure.
  90. @skb - pointer to skbuff of the COOKIE ACK packet.
  91. Security Hooks used for Association Establishment
  92. =================================================
  93. The following diagram shows the use of ``security_sctp_bind_connect()``,
  94. ``security_sctp_assoc_request()``, ``security_inet_conn_established()`` when
  95. establishing an association.
  96. ::
  97. SCTP endpoint "A" SCTP endpoint "Z"
  98. ================= =================
  99. sctp_sf_do_prm_asoc()
  100. Association setup can be initiated
  101. by a connect(2), sctp_connectx(3),
  102. sendmsg(2) or sctp_sendmsg(3).
  103. These will result in a call to
  104. security_sctp_bind_connect() to
  105. initiate an association to
  106. SCTP peer endpoint "Z".
  107. INIT --------------------------------------------->
  108. sctp_sf_do_5_1B_init()
  109. Respond to an INIT chunk.
  110. SCTP peer endpoint "A" is
  111. asking for an association. Call
  112. security_sctp_assoc_request()
  113. to set the peer label if first
  114. association.
  115. If not first association, check
  116. whether allowed, IF so send:
  117. <----------------------------------------------- INIT ACK
  118. | ELSE audit event and silently
  119. | discard the packet.
  120. |
  121. COOKIE ECHO ------------------------------------------>
  122. |
  123. |
  124. |
  125. <------------------------------------------- COOKIE ACK
  126. | |
  127. sctp_sf_do_5_1E_ca |
  128. Call security_inet_conn_established() |
  129. to set the peer label. |
  130. | |
  131. | If SCTP_SOCKET_TCP or peeled off
  132. | socket security_sctp_sk_clone() is
  133. | called to clone the new socket.
  134. | |
  135. ESTABLISHED ESTABLISHED
  136. | |
  137. ------------------------------------------------------------------
  138. | Association Established |
  139. ------------------------------------------------------------------