aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/security
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2019-02-17 17:08:36 -0500
committerJonathan Corbet <corbet@lwn.net>2019-02-22 10:51:40 -0500
commitd61330c689df2ef7ac76b63be2bd0a8561e47fd9 (patch)
tree1dd5dd449f49ea47435fd895ea43e4c6faec6ca0 /Documentation/security
parent3203561d6d081fa53d3b448d99fb9ffd933b3123 (diff)
doc: sctp: Merge and clean up rst files
The SCTP sections were ending up at the top-level table of contents under the security section when they should have be sections with the SCTP chapters. In addition to correcting the section and subsection headings, this merges the SCTP documents into a single file to organize the chapters more clearly, internally linkifies them, and adds the missing SPDX header. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation/security')
-rw-r--r--Documentation/security/SCTP.rst (renamed from Documentation/security/LSM-sctp.rst)180
-rw-r--r--Documentation/security/SELinux-sctp.rst158
-rw-r--r--Documentation/security/index.rst3
3 files changed, 175 insertions, 166 deletions
diff --git a/Documentation/security/LSM-sctp.rst b/Documentation/security/SCTP.rst
index 6e5a3925a860..d903eb97fcf3 100644
--- a/Documentation/security/LSM-sctp.rst
+++ b/Documentation/security/SCTP.rst
@@ -1,6 +1,15 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3====
4SCTP
5====
6
1SCTP LSM Support 7SCTP LSM Support
2================ 8================
3 9
10Security Hooks
11--------------
12
4For security module support, three SCTP specific hooks have been implemented:: 13For security module support, three SCTP specific hooks have been implemented::
5 14
6 security_sctp_assoc_request() 15 security_sctp_assoc_request()
@@ -12,11 +21,11 @@ Also the following security hook has been utilised::
12 security_inet_conn_established() 21 security_inet_conn_established()
13 22
14The usage of these hooks are described below with the SELinux implementation 23The usage of these hooks are described below with the SELinux implementation
15described in ``Documentation/security/SELinux-sctp.rst`` 24described in the `SCTP SELinux Support`_ chapter.
16 25
17 26
18security_sctp_assoc_request() 27security_sctp_assoc_request()
19----------------------------- 28~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the 29Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the
21security module. Returns 0 on success, error on failure. 30security module. Returns 0 on success, error on failure.
22:: 31::
@@ -26,7 +35,7 @@ security module. Returns 0 on success, error on failure.
26 35
27 36
28security_sctp_bind_connect() 37security_sctp_bind_connect()
29----------------------------- 38~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30Passes one or more ipv4/ipv6 addresses to the security module for validation 39Passes one or more ipv4/ipv6 addresses to the security module for validation
31based on the ``@optname`` that will result in either a bind or connect 40based on the ``@optname`` that will result in either a bind or connect
32service as shown in the permission check tables below. 41service as shown in the permission check tables below.
@@ -102,7 +111,7 @@ ASCONF chunk when the corresponding ``@optname``'s are present::
102 111
103 112
104security_sctp_sk_clone() 113security_sctp_sk_clone()
105------------------------- 114~~~~~~~~~~~~~~~~~~~~~~~~
106Called whenever a new socket is created by **accept**\(2) 115Called whenever a new socket is created by **accept**\(2)
107(i.e. a TCP style socket) or when a socket is 'peeled off' e.g userspace 116(i.e. a TCP style socket) or when a socket is 'peeled off' e.g userspace
108calls **sctp_peeloff**\(3). 117calls **sctp_peeloff**\(3).
@@ -114,7 +123,7 @@ calls **sctp_peeloff**\(3).
114 123
115 124
116security_inet_conn_established() 125security_inet_conn_established()
117--------------------------------- 126~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118Called when a COOKIE ACK is received:: 127Called when a COOKIE ACK is received::
119 128
120 @sk - pointer to sock structure. 129 @sk - pointer to sock structure.
@@ -122,7 +131,8 @@ Called when a COOKIE ACK is received::
122 131
123 132
124Security Hooks used for Association Establishment 133Security Hooks used for Association Establishment
125================================================= 134-------------------------------------------------
135
126The following diagram shows the use of ``security_sctp_bind_connect()``, 136The following diagram shows the use of ``security_sctp_bind_connect()``,
127``security_sctp_assoc_request()``, ``security_inet_conn_established()`` when 137``security_sctp_assoc_request()``, ``security_inet_conn_established()`` when
128establishing an association. 138establishing an association.
@@ -173,3 +183,161 @@ establishing an association.
173 ------------------------------------------------------------------ 183 ------------------------------------------------------------------
174 184
175 185
186SCTP SELinux Support
187====================
188
189Security Hooks
190--------------
191
192The `SCTP LSM Support`_ chapter above describes the following SCTP security
193hooks with the SELinux specifics expanded below::
194
195 security_sctp_assoc_request()
196 security_sctp_bind_connect()
197 security_sctp_sk_clone()
198 security_inet_conn_established()
199
200
201security_sctp_assoc_request()
202~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the
204security module. Returns 0 on success, error on failure.
205::
206
207 @ep - pointer to sctp endpoint structure.
208 @skb - pointer to skbuff of association packet.
209
210The security module performs the following operations:
211 IF this is the first association on ``@ep->base.sk``, then set the peer
212 sid to that in ``@skb``. This will ensure there is only one peer sid
213 assigned to ``@ep->base.sk`` that may support multiple associations.
214
215 ELSE validate the ``@ep->base.sk peer_sid`` against the ``@skb peer sid``
216 to determine whether the association should be allowed or denied.
217
218 Set the sctp ``@ep sid`` to socket's sid (from ``ep->base.sk``) with
219 MLS portion taken from ``@skb peer sid``. This will be used by SCTP
220 TCP style sockets and peeled off connections as they cause a new socket
221 to be generated.
222
223 If IP security options are configured (CIPSO/CALIPSO), then the ip
224 options are set on the socket.
225
226
227security_sctp_bind_connect()
228~~~~~~~~~~~~~~~~~~~~~~~~~~~~
229Checks permissions required for ipv4/ipv6 addresses based on the ``@optname``
230as follows::
231
232 ------------------------------------------------------------------
233 | BIND Permission Checks |
234 | @optname | @address contains |
235 |----------------------------|-----------------------------------|
236 | SCTP_SOCKOPT_BINDX_ADD | One or more ipv4 / ipv6 addresses |
237 | SCTP_PRIMARY_ADDR | Single ipv4 or ipv6 address |
238 | SCTP_SET_PEER_PRIMARY_ADDR | Single ipv4 or ipv6 address |
239 ------------------------------------------------------------------
240
241 ------------------------------------------------------------------
242 | CONNECT Permission Checks |
243 | @optname | @address contains |
244 |----------------------------|-----------------------------------|
245 | SCTP_SOCKOPT_CONNECTX | One or more ipv4 / ipv6 addresses |
246 | SCTP_PARAM_ADD_IP | One or more ipv4 / ipv6 addresses |
247 | SCTP_SENDMSG_CONNECT | Single ipv4 or ipv6 address |
248 | SCTP_PARAM_SET_PRIMARY | Single ipv4 or ipv6 address |
249 ------------------------------------------------------------------
250
251
252`SCTP LSM Support`_ gives a summary of the ``@optname``
253entries and also describes ASCONF chunk processing when Dynamic Address
254Reconfiguration is enabled.
255
256
257security_sctp_sk_clone()
258~~~~~~~~~~~~~~~~~~~~~~~~
259Called whenever a new socket is created by **accept**\(2) (i.e. a TCP style
260socket) or when a socket is 'peeled off' e.g userspace calls
261**sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new
262sockets sid and peer sid to that contained in the ``@ep sid`` and
263``@ep peer sid`` respectively.
264::
265
266 @ep - pointer to current sctp endpoint structure.
267 @sk - pointer to current sock structure.
268 @sk - pointer to new sock structure.
269
270
271security_inet_conn_established()
272~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
273Called when a COOKIE ACK is received where it sets the connection's peer sid
274to that in ``@skb``::
275
276 @sk - pointer to sock structure.
277 @skb - pointer to skbuff of the COOKIE ACK packet.
278
279
280Policy Statements
281-----------------
282The following class and permissions to support SCTP are available within the
283kernel::
284
285 class sctp_socket inherits socket { node_bind }
286
287whenever the following policy capability is enabled::
288
289 policycap extended_socket_class;
290
291SELinux SCTP support adds the ``name_connect`` permission for connecting
292to a specific port type and the ``association`` permission that is explained
293in the section below.
294
295If userspace tools have been updated, SCTP will support the ``portcon``
296statement as shown in the following example::
297
298 portcon sctp 1024-1036 system_u:object_r:sctp_ports_t:s0
299
300
301SCTP Peer Labeling
302------------------
303An SCTP socket will only have one peer label assigned to it. This will be
304assigned during the establishment of the first association. Any further
305associations on this socket will have their packet peer label compared to
306the sockets peer label, and only if they are different will the
307``association`` permission be validated. This is validated by checking the
308socket peer sid against the received packets peer sid to determine whether
309the association should be allowed or denied.
310
311NOTES:
312 1) If peer labeling is not enabled, then the peer context will always be
313 ``SECINITSID_UNLABELED`` (``unlabeled_t`` in Reference Policy).
314
315 2) As SCTP can support more than one transport address per endpoint
316 (multi-homing) on a single socket, it is possible to configure policy
317 and NetLabel to provide different peer labels for each of these. As the
318 socket peer label is determined by the first associations transport
319 address, it is recommended that all peer labels are consistent.
320
321 3) **getpeercon**\(3) may be used by userspace to retrieve the sockets peer
322 context.
323
324 4) While not SCTP specific, be aware when using NetLabel that if a label
325 is assigned to a specific interface, and that interface 'goes down',
326 then the NetLabel service will remove the entry. Therefore ensure that
327 the network startup scripts call **netlabelctl**\(8) to set the required
328 label (see **netlabel-config**\(8) helper script for details).
329
330 5) The NetLabel SCTP peer labeling rules apply as discussed in the following
331 set of posts tagged "netlabel" at: http://www.paul-moore.com/blog/t.
332
333 6) CIPSO is only supported for IPv4 addressing: ``socket(AF_INET, ...)``
334 CALIPSO is only supported for IPv6 addressing: ``socket(AF_INET6, ...)``
335
336 Note the following when testing CIPSO/CALIPSO:
337 a) CIPSO will send an ICMP packet if an SCTP packet cannot be
338 delivered because of an invalid label.
339 b) CALIPSO does not send an ICMP packet, just silently discards it.
340
341 7) IPSEC is not supported as RFC 3554 - sctp/ipsec support has not been
342 implemented in userspace (**racoon**\(8) or **ipsec_pluto**\(8)),
343 although the kernel supports SCTP/IPSEC.
diff --git a/Documentation/security/SELinux-sctp.rst b/Documentation/security/SELinux-sctp.rst
deleted file mode 100644
index a332cb1c5334..000000000000
--- a/Documentation/security/SELinux-sctp.rst
+++ /dev/null
@@ -1,158 +0,0 @@
1SCTP SELinux Support
2=====================
3
4Security Hooks
5===============
6
7``Documentation/security/LSM-sctp.rst`` describes the following SCTP security
8hooks with the SELinux specifics expanded below::
9
10 security_sctp_assoc_request()
11 security_sctp_bind_connect()
12 security_sctp_sk_clone()
13 security_inet_conn_established()
14
15
16security_sctp_assoc_request()
17-----------------------------
18Passes the ``@ep`` and ``@chunk->skb`` of the association INIT packet to the
19security module. Returns 0 on success, error on failure.
20::
21
22 @ep - pointer to sctp endpoint structure.
23 @skb - pointer to skbuff of association packet.
24
25The security module performs the following operations:
26 IF this is the first association on ``@ep->base.sk``, then set the peer
27 sid to that in ``@skb``. This will ensure there is only one peer sid
28 assigned to ``@ep->base.sk`` that may support multiple associations.
29
30 ELSE validate the ``@ep->base.sk peer_sid`` against the ``@skb peer sid``
31 to determine whether the association should be allowed or denied.
32
33 Set the sctp ``@ep sid`` to socket's sid (from ``ep->base.sk``) with
34 MLS portion taken from ``@skb peer sid``. This will be used by SCTP
35 TCP style sockets and peeled off connections as they cause a new socket
36 to be generated.
37
38 If IP security options are configured (CIPSO/CALIPSO), then the ip
39 options are set on the socket.
40
41
42security_sctp_bind_connect()
43-----------------------------
44Checks permissions required for ipv4/ipv6 addresses based on the ``@optname``
45as follows::
46
47 ------------------------------------------------------------------
48 | BIND Permission Checks |
49 | @optname | @address contains |
50 |----------------------------|-----------------------------------|
51 | SCTP_SOCKOPT_BINDX_ADD | One or more ipv4 / ipv6 addresses |
52 | SCTP_PRIMARY_ADDR | Single ipv4 or ipv6 address |
53 | SCTP_SET_PEER_PRIMARY_ADDR | Single ipv4 or ipv6 address |
54 ------------------------------------------------------------------
55
56 ------------------------------------------------------------------
57 | CONNECT Permission Checks |
58 | @optname | @address contains |
59 |----------------------------|-----------------------------------|
60 | SCTP_SOCKOPT_CONNECTX | One or more ipv4 / ipv6 addresses |
61 | SCTP_PARAM_ADD_IP | One or more ipv4 / ipv6 addresses |
62 | SCTP_SENDMSG_CONNECT | Single ipv4 or ipv6 address |
63 | SCTP_PARAM_SET_PRIMARY | Single ipv4 or ipv6 address |
64 ------------------------------------------------------------------
65
66
67``Documentation/security/LSM-sctp.rst`` gives a summary of the ``@optname``
68entries and also describes ASCONF chunk processing when Dynamic Address
69Reconfiguration is enabled.
70
71
72security_sctp_sk_clone()
73-------------------------
74Called whenever a new socket is created by **accept**\(2) (i.e. a TCP style
75socket) or when a socket is 'peeled off' e.g userspace calls
76**sctp_peeloff**\(3). ``security_sctp_sk_clone()`` will set the new
77sockets sid and peer sid to that contained in the ``@ep sid`` and
78``@ep peer sid`` respectively.
79::
80
81 @ep - pointer to current sctp endpoint structure.
82 @sk - pointer to current sock structure.
83 @sk - pointer to new sock structure.
84
85
86security_inet_conn_established()
87---------------------------------
88Called when a COOKIE ACK is received where it sets the connection's peer sid
89to that in ``@skb``::
90
91 @sk - pointer to sock structure.
92 @skb - pointer to skbuff of the COOKIE ACK packet.
93
94
95Policy Statements
96==================
97The following class and permissions to support SCTP are available within the
98kernel::
99
100 class sctp_socket inherits socket { node_bind }
101
102whenever the following policy capability is enabled::
103
104 policycap extended_socket_class;
105
106SELinux SCTP support adds the ``name_connect`` permission for connecting
107to a specific port type and the ``association`` permission that is explained
108in the section below.
109
110If userspace tools have been updated, SCTP will support the ``portcon``
111statement as shown in the following example::
112
113 portcon sctp 1024-1036 system_u:object_r:sctp_ports_t:s0
114
115
116SCTP Peer Labeling
117===================
118An SCTP socket will only have one peer label assigned to it. This will be
119assigned during the establishment of the first association. Any further
120associations on this socket will have their packet peer label compared to
121the sockets peer label, and only if they are different will the
122``association`` permission be validated. This is validated by checking the
123socket peer sid against the received packets peer sid to determine whether
124the association should be allowed or denied.
125
126NOTES:
127 1) If peer labeling is not enabled, then the peer context will always be
128 ``SECINITSID_UNLABELED`` (``unlabeled_t`` in Reference Policy).
129
130 2) As SCTP can support more than one transport address per endpoint
131 (multi-homing) on a single socket, it is possible to configure policy
132 and NetLabel to provide different peer labels for each of these. As the
133 socket peer label is determined by the first associations transport
134 address, it is recommended that all peer labels are consistent.
135
136 3) **getpeercon**\(3) may be used by userspace to retrieve the sockets peer
137 context.
138
139 4) While not SCTP specific, be aware when using NetLabel that if a label
140 is assigned to a specific interface, and that interface 'goes down',
141 then the NetLabel service will remove the entry. Therefore ensure that
142 the network startup scripts call **netlabelctl**\(8) to set the required
143 label (see **netlabel-config**\(8) helper script for details).
144
145 5) The NetLabel SCTP peer labeling rules apply as discussed in the following
146 set of posts tagged "netlabel" at: http://www.paul-moore.com/blog/t.
147
148 6) CIPSO is only supported for IPv4 addressing: ``socket(AF_INET, ...)``
149 CALIPSO is only supported for IPv6 addressing: ``socket(AF_INET6, ...)``
150
151 Note the following when testing CIPSO/CALIPSO:
152 a) CIPSO will send an ICMP packet if an SCTP packet cannot be
153 delivered because of an invalid label.
154 b) CALIPSO does not send an ICMP packet, just silently discards it.
155
156 7) IPSEC is not supported as RFC 3554 - sctp/ipsec support has not been
157 implemented in userspace (**racoon**\(8) or **ipsec_pluto**\(8)),
158 although the kernel supports SCTP/IPSEC.
diff --git a/Documentation/security/index.rst b/Documentation/security/index.rst
index 85492bfca530..aad6d92ffe31 100644
--- a/Documentation/security/index.rst
+++ b/Documentation/security/index.rst
@@ -9,7 +9,6 @@ Security Documentation
9 IMA-templates 9 IMA-templates
10 keys/index 10 keys/index
11 LSM 11 LSM
12 LSM-sctp 12 SCTP
13 SELinux-sctp
14 self-protection 13 self-protection
15 tpm/index 14 tpm/index