2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-14 06:30:11 +03:00
|
|
|
|
2018-01-31 21:34:37 +05:30
|
|
|
|
2017-11-14 06:30:11 +03:00
|
|
|
|
|
|
|
|
|
2018-10-13 02:45:59 +02:00
|
|
|
|
2019-11-05 14:24:35 -08:00
|
|
|
|
2019-06-05 14:11:39 -07:00
|
|
|
|
2019-08-30 12:25:47 +02:00
|
|
|
|
2018-10-13 02:45:59 +02:00
|
|
|
|
2019-10-04 16:19:24 -07:00
|
|
|
|
2017-11-14 06:30:11 +03:00
|
|
|
|
tls: RX path for ktls
Add rx path for tls software implementation.
recvmsg, splice_read, and poll implemented.
An additional sockopt TLS_RX is added, with the same interface as
TLS_TX. Either TLX_RX or TLX_TX may be provided separately, or
together (with two different setsockopt calls with appropriate keys).
Control messages are passed via CMSG in a similar way to transmit.
If no cmsg buffer is passed, then only application data records
will be passed to userspace, and EIO is returned for other types of
alerts.
EBADMSG is passed for decryption errors, and EMSGSIZE is passed for
framing too big, and EBADMSG for framing too small (matching openssl
semantics). EINVAL is returned for TLS versions that do not match the
original setsockopt call. All are unrecoverable.
strparser is used to parse TLS framing. Decryption is done directly
in to userspace buffers if they are large enough to support it, otherwise
sk_cow_data is called (similar to ipsec), and buffers are decrypted in
place and copied. splice_read always decrypts in place, since no
buffers are provided to decrypt in to.
sk_poll is overridden, and only returns POLLIN if a full TLS message is
received. Otherwise we wait for strparser to finish reading a full frame.
Actual decryption is only done during recvmsg or splice_read calls.
Signed-off-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-03-22 10:10:35 -07:00
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-31 21:41:52 +05:30
|
|
|
|
2019-03-20 02:03:36 +00:00
|
|
|
|
2019-06-10 21:40:00 -07:00
|
|
|
|
2019-03-20 02:03:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-04 16:19:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net/tls: Fixed race condition in async encryption
On processors with multi-engine crypto accelerators, it is possible that
multiple records get encrypted in parallel and their encryption
completion is notified to different cpus in multicore processor. This
leads to the situation where tls_encrypt_done() starts executing in
parallel on different cores. In current implementation, encrypted
records are queued to tx_ready_list in tls_encrypt_done(). This requires
addition to linked list 'tx_ready_list' to be protected. As
tls_decrypt_done() could be executing in irq content, it is not possible
to protect linked list addition operation using a lock.
To fix the problem, we remove linked list addition operation from the
irq context. We do tx_ready_list addition/removal operation from
application context only and get rid of possible multiple access to
the linked list. Before starting encryption on the record, we add it to
the tail of tx_ready_list. To prevent tls_tx_records() from transmitting
it, we mark the record with a new flag 'tx_ready' in 'struct tls_rec'.
When record encryption gets completed, tls_encrypt_done() has to only
update the 'tx_ready' flag to true & linked list add operation is not
required.
The changed logic brings some other side benefits. Since the records
are always submitted in tls sequence number order for encryption, the
tx_ready_list always remains sorted and addition of new records to it
does not have to traverse the linked list.
Lastly, we renamed tx_ready_list in 'struct tls_sw_context_tx' to
'tx_list'. This is because now, the some of the records at the tail are
not ready to transmit.
Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-09-24 15:35:56 +05:30
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2018-10-13 02:45:59 +02:00
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2018-10-13 02:45:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2019-03-20 02:03:36 +00:00
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-02-23 08:42:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net/tls: Fixed race condition in async encryption
On processors with multi-engine crypto accelerators, it is possible that
multiple records get encrypted in parallel and their encryption
completion is notified to different cpus in multicore processor. This
leads to the situation where tls_encrypt_done() starts executing in
parallel on different cores. In current implementation, encrypted
records are queued to tx_ready_list in tls_encrypt_done(). This requires
addition to linked list 'tx_ready_list' to be protected. As
tls_decrypt_done() could be executing in irq content, it is not possible
to protect linked list addition operation using a lock.
To fix the problem, we remove linked list addition operation from the
irq context. We do tx_ready_list addition/removal operation from
application context only and get rid of possible multiple access to
the linked list. Before starting encryption on the record, we add it to
the tail of tx_ready_list. To prevent tls_tx_records() from transmitting
it, we mark the record with a new flag 'tx_ready' in 'struct tls_rec'.
When record encryption gets completed, tls_encrypt_done() has to only
update the 'tx_ready' flag to true & linked list add operation is not
required.
The changed logic brings some other side benefits. Since the records
are always submitted in tls sequence number order for encryption, the
tx_ready_list always remains sorted and addition of new records to it
does not have to traverse the linked list.
Lastly, we renamed tx_ready_list in 'struct tls_sw_context_tx' to
'tx_list'. This is because now, the some of the records at the tail are
not ready to transmit.
Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-09-24 15:35:56 +05:30
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
2019-10-06 21:09:31 -07:00
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
2019-07-19 10:29:16 -07:00
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
2018-04-30 10:16:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-16 10:40:16 +00:00
|
|
|
|
2018-04-30 10:16:15 +03:00
|
|
|
|
2018-10-13 02:46:00 +02:00
|
|
|
|
2018-04-30 10:16:15 +03:00
|
|
|
|
|
|
|
|
|
2019-10-06 21:09:31 -07:00
|
|
|
|
2019-10-06 21:09:32 -07:00
|
|
|
|
2018-08-29 15:26:55 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:39 +03:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-05 14:11:39 -07:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-05 14:11:38 -07:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:39 +03:00
|
|
|
|
2019-06-05 14:11:39 -07:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
2019-06-04 12:00:12 -07:00
|
|
|
|
|
|
|
|
|
2019-06-10 21:40:09 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-04 12:00:12 -07:00
|
|
|
|
|
|
|
|
|
2018-03-22 10:10:06 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-12 17:44:42 +02:00
|
|
|
|
|
|
|
|
|
2019-01-30 21:58:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-12 17:44:42 +02:00
|
|
|
|
|
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-20 02:03:36 +00:00
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
|
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
|
|
|
|
|
2018-04-30 10:16:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
2017-11-13 10:22:45 +02:00
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
2018-03-22 10:10:06 -07:00
|
|
|
|
tls: RX path for ktls
Add rx path for tls software implementation.
recvmsg, splice_read, and poll implemented.
An additional sockopt TLS_RX is added, with the same interface as
TLS_TX. Either TLX_RX or TLX_TX may be provided separately, or
together (with two different setsockopt calls with appropriate keys).
Control messages are passed via CMSG in a similar way to transmit.
If no cmsg buffer is passed, then only application data records
will be passed to userspace, and EIO is returned for other types of
alerts.
EBADMSG is passed for decryption errors, and EMSGSIZE is passed for
framing too big, and EBADMSG for framing too small (matching openssl
semantics). EINVAL is returned for TLS versions that do not match the
original setsockopt call. All are unrecoverable.
strparser is used to parse TLS framing. Decryption is done directly
in to userspace buffers if they are large enough to support it, otherwise
sk_cow_data is called (similar to ipsec), and buffers are decrypted in
place and copied. splice_read always decrypts in place, since no
buffers are provided to decrypt in to.
sk_poll is overridden, and only returns POLLIN if a full TLS message is
received. Otherwise we wait for strparser to finish reading a full frame.
Actual decryption is only done during recvmsg or splice_read calls.
Signed-off-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-03-22 10:10:35 -07:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2018-05-01 13:05:39 -07:00
|
|
|
|
2018-10-13 02:45:59 +02:00
|
|
|
|
2019-11-05 14:24:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
2019-07-19 10:29:18 -07:00
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
2019-06-03 15:17:04 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-30 12:25:47 +02:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
2019-04-25 12:32:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-08 19:53:13 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-25 12:32:03 -07:00
|
|
|
|
|
|
|
|
|
2019-06-10 21:40:02 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-10 21:40:02 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-05 14:11:39 -07:00
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-05 14:11:38 -07:00
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-05 14:11:39 -07:00
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
2019-10-03 11:18:57 -07:00
|
|
|
|
2019-08-30 12:25:47 +02:00
|
|
|
|
2019-10-03 11:18:57 -07:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tls: RX path for ktls
Add rx path for tls software implementation.
recvmsg, splice_read, and poll implemented.
An additional sockopt TLS_RX is added, with the same interface as
TLS_TX. Either TLX_RX or TLX_TX may be provided separately, or
together (with two different setsockopt calls with appropriate keys).
Control messages are passed via CMSG in a similar way to transmit.
If no cmsg buffer is passed, then only application data records
will be passed to userspace, and EIO is returned for other types of
alerts.
EBADMSG is passed for decryption errors, and EMSGSIZE is passed for
framing too big, and EBADMSG for framing too small (matching openssl
semantics). EINVAL is returned for TLS versions that do not match the
original setsockopt call. All are unrecoverable.
strparser is used to parse TLS framing. Decryption is done directly
in to userspace buffers if they are large enough to support it, otherwise
sk_cow_data is called (similar to ipsec), and buffers are decrypted in
place and copied. splice_read always decrypts in place, since no
buffers are provided to decrypt in to.
sk_poll is overridden, and only returns POLLIN if a full TLS message is
received. Otherwise we wait for strparser to finish reading a full frame.
Actual decryption is only done during recvmsg or splice_read calls.
Signed-off-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-03-22 10:10:35 -07:00
|
|
|
|
2019-07-19 10:29:14 -07:00
|
|
|
|
2019-07-19 10:29:17 -07:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-11-18 10:40:51 -05:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
2019-07-19 10:29:16 -07:00
|
|
|
|
2019-07-19 10:29:17 -07:00
|
|
|
|
|
|
|
|
|
2018-04-30 10:16:15 +03:00
|
|
|
|
2018-07-13 14:33:41 +03:00
|
|
|
|
2019-07-19 10:29:17 -07:00
|
|
|
|
tls: RX path for ktls
Add rx path for tls software implementation.
recvmsg, splice_read, and poll implemented.
An additional sockopt TLS_RX is added, with the same interface as
TLS_TX. Either TLX_RX or TLX_TX may be provided separately, or
together (with two different setsockopt calls with appropriate keys).
Control messages are passed via CMSG in a similar way to transmit.
If no cmsg buffer is passed, then only application data records
will be passed to userspace, and EIO is returned for other types of
alerts.
EBADMSG is passed for decryption errors, and EMSGSIZE is passed for
framing too big, and EBADMSG for framing too small (matching openssl
semantics). EINVAL is returned for TLS versions that do not match the
original setsockopt call. All are unrecoverable.
strparser is used to parse TLS framing. Decryption is done directly
in to userspace buffers if they are large enough to support it, otherwise
sk_cow_data is called (similar to ipsec), and buffers are decrypted in
place and copied. splice_read always decrypts in place, since no
buffers are provided to decrypt in to.
sk_poll is overridden, and only returns POLLIN if a full TLS message is
received. Otherwise we wait for strparser to finish reading a full frame.
Actual decryption is only done during recvmsg or splice_read calls.
Signed-off-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-03-22 10:10:35 -07:00
|
|
|
|
|
|
|
|
|
2018-10-13 02:46:00 +02:00
|
|
|
|
tls: RX path for ktls
Add rx path for tls software implementation.
recvmsg, splice_read, and poll implemented.
An additional sockopt TLS_RX is added, with the same interface as
TLS_TX. Either TLX_RX or TLX_TX may be provided separately, or
together (with two different setsockopt calls with appropriate keys).
Control messages are passed via CMSG in a similar way to transmit.
If no cmsg buffer is passed, then only application data records
will be passed to userspace, and EIO is returned for other types of
alerts.
EBADMSG is passed for decryption errors, and EMSGSIZE is passed for
framing too big, and EBADMSG for framing too small (matching openssl
semantics). EINVAL is returned for TLS versions that do not match the
original setsockopt call. All are unrecoverable.
strparser is used to parse TLS framing. Decryption is done directly
in to userspace buffers if they are large enough to support it, otherwise
sk_cow_data is called (similar to ipsec), and buffers are decrypted in
place and copied. splice_read always decrypts in place, since no
buffers are provided to decrypt in to.
sk_poll is overridden, and only returns POLLIN if a full TLS message is
received. Otherwise we wait for strparser to finish reading a full frame.
Actual decryption is only done during recvmsg or splice_read calls.
Signed-off-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-03-22 10:10:35 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
2018-07-13 14:33:39 +03:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
2019-11-27 12:16:44 -08:00
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
2019-02-23 08:42:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-02-27 17:38:03 +02:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-02-27 17:38:03 +02:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net/tls: Fixed race condition in async encryption
On processors with multi-engine crypto accelerators, it is possible that
multiple records get encrypted in parallel and their encryption
completion is notified to different cpus in multicore processor. This
leads to the situation where tls_encrypt_done() starts executing in
parallel on different cores. In current implementation, encrypted
records are queued to tx_ready_list in tls_encrypt_done(). This requires
addition to linked list 'tx_ready_list' to be protected. As
tls_decrypt_done() could be executing in irq content, it is not possible
to protect linked list addition operation using a lock.
To fix the problem, we remove linked list addition operation from the
irq context. We do tx_ready_list addition/removal operation from
application context only and get rid of possible multiple access to
the linked list. Before starting encryption on the record, we add it to
the tail of tx_ready_list. To prevent tls_tx_records() from transmitting
it, we mark the record with a new flag 'tx_ready' in 'struct tls_rec'.
When record encryption gets completed, tls_encrypt_done() has to only
update the 'tx_ready' flag to true & linked list add operation is not
required.
The changed logic brings some other side benefits. Since the records
are always submitted in tls sequence number order for encryption, the
tx_ready_list always remains sorted and addition of new records to it
does not have to traverse the linked list.
Lastly, we renamed tx_ready_list in 'struct tls_sw_context_tx' to
'tx_list'. This is because now, the some of the records at the tail are
not ready to transmit.
Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-09-24 15:35:56 +05:30
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net/tls: Fixed race condition in async encryption
On processors with multi-engine crypto accelerators, it is possible that
multiple records get encrypted in parallel and their encryption
completion is notified to different cpus in multicore processor. This
leads to the situation where tls_encrypt_done() starts executing in
parallel on different cores. In current implementation, encrypted
records are queued to tx_ready_list in tls_encrypt_done(). This requires
addition to linked list 'tx_ready_list' to be protected. As
tls_decrypt_done() could be executing in irq content, it is not possible
to protect linked list addition operation using a lock.
To fix the problem, we remove linked list addition operation from the
irq context. We do tx_ready_list addition/removal operation from
application context only and get rid of possible multiple access to
the linked list. Before starting encryption on the record, we add it to
the tail of tx_ready_list. To prevent tls_tx_records() from transmitting
it, we mark the record with a new flag 'tx_ready' in 'struct tls_rec'.
When record encryption gets completed, tls_encrypt_done() has to only
update the 'tx_ready' flag to true & linked list add operation is not
required.
The changed logic brings some other side benefits. Since the records
are always submitted in tls sequence number order for encryption, the
tx_ready_list always remains sorted and addition of new records to it
does not have to traverse the linked list.
Lastly, we renamed tx_ready_list in 'struct tls_sw_context_tx' to
'tx_list'. This is because now, the some of the records at the tail are
not ready to transmit.
Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-09-24 15:35:56 +05:30
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net/tls: Fixed race condition in async encryption
On processors with multi-engine crypto accelerators, it is possible that
multiple records get encrypted in parallel and their encryption
completion is notified to different cpus in multicore processor. This
leads to the situation where tls_encrypt_done() starts executing in
parallel on different cores. In current implementation, encrypted
records are queued to tx_ready_list in tls_encrypt_done(). This requires
addition to linked list 'tx_ready_list' to be protected. As
tls_decrypt_done() could be executing in irq content, it is not possible
to protect linked list addition operation using a lock.
To fix the problem, we remove linked list addition operation from the
irq context. We do tx_ready_list addition/removal operation from
application context only and get rid of possible multiple access to
the linked list. Before starting encryption on the record, we add it to
the tail of tx_ready_list. To prevent tls_tx_records() from transmitting
it, we mark the record with a new flag 'tx_ready' in 'struct tls_rec'.
When record encryption gets completed, tls_encrypt_done() has to only
update the 'tx_ready' flag to true & linked list add operation is not
required.
The changed logic brings some other side benefits. Since the records
are always submitted in tls sequence number order for encryption, the
tx_ready_list always remains sorted and addition of new records to it
does not have to traverse the linked list.
Lastly, we renamed tx_ready_list in 'struct tls_sw_context_tx' to
'tx_list'. This is because now, the some of the records at the tail are
not ready to transmit.
Fixes: a42055e8d2c3 ("net/tls: Add support for async encryption")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-09-24 15:35:56 +05:30
|
|
|
|
2018-09-21 09:46:13 +05:30
|
|
|
|
|
|
|
|
|
2019-08-30 12:25:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
2019-04-08 17:59:50 -07:00
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
2018-03-22 10:10:15 -07:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2018-03-22 10:10:15 -07:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-30 12:25:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-06-03 15:17:05 -07:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
2018-03-22 10:10:15 -07:00
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
2019-06-03 15:17:05 -07:00
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2019-02-14 07:11:35 +00:00
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-13 10:22:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-13 10:22:47 +02:00
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
2017-11-13 10:22:47 +02:00
|
|
|
|
2019-01-30 21:58:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-13 10:22:47 +02:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2018-04-30 10:16:15 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
2018-04-30 10:16:15 +03:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:39 +03:00
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2018-07-13 14:33:39 +03:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
bpf: sk_msg, sock{map|hash} redirect through ULP
A sockmap program that redirects through a kTLS ULP enabled socket
will not work correctly because the ULP layer is skipped. This
fixes the behavior to call through the ULP layer on redirect to
ensure any operations required on the data stream at the ULP layer
continue to be applied.
To do this we add an internal flag MSG_SENDPAGE_NOPOLICY to avoid
calling the BPF layer on a redirected message. This is
required to avoid calling the BPF layer multiple times (possibly
recursively) which is not the current/expected behavior without
ULPs. In the future we may add a redirect flag if users _do_
want the policy applied again but this would need to work for both
ULP and non-ULP sockets and be opt-in to avoid breaking existing
programs.
Also to avoid polluting the flag space with an internal flag we
reuse the flag space overlapping MSG_SENDPAGE_NOPOLICY with
MSG_WAITFORONE. Here WAITFORONE is specific to recv path and
SENDPAGE_NOPOLICY is only used for sendpage hooks. The last thing
to verify is user space API is masked correctly to ensure the flag
can not be set by user. (Note this needs to be true regardless
because we have internal flags already in-use that user space
should not be able to set). But for completeness we have two UAPI
paths into sendpage, sendfile and splice.
In the sendfile case the function do_sendfile() zero's flags,
./fs/read_write.c:
static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos,
size_t count, loff_t max)
{
...
fl = 0;
#if 0
/*
* We need to debate whether we can enable this or not. The
* man page documents EAGAIN return for the output at least,
* and the application is arguably buggy if it doesn't expect
* EAGAIN on a non-blocking file descriptor.
*/
if (in.file->f_flags & O_NONBLOCK)
fl = SPLICE_F_NONBLOCK;
#endif
file_start_write(out.file);
retval = do_splice_direct(in.file, &pos, out.file, &out_pos, count, fl);
}
In the splice case the pipe_to_sendpage "actor" is used which
masks flags with SPLICE_F_MORE.
./fs/splice.c:
static int pipe_to_sendpage(struct pipe_inode_info *pipe,
struct pipe_buffer *buf, struct splice_desc *sd)
{
...
more = (sd->flags & SPLICE_F_MORE) ? MSG_MORE : 0;
...
}
Confirming what we expect that internal flags are in fact internal
to socket side.
Fixes: d3b18ad31f93 ("tls: add bpf support to sk_msg handling")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2018-12-20 11:35:35 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-02-27 17:38:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-06-05 14:11:39 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-25 12:32:04 -07:00
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
2019-06-10 21:40:02 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
2019-06-10 21:40:09 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-04 16:19:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:40 +03:00
|
|
|
|
|
|
|
|
|
2019-06-05 14:11:40 -07:00
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:39 +03:00
|
|
|
|
2018-04-30 10:16:16 +03:00
|
|
|
|
|
|
|
|
|
2019-09-02 21:31:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
|
|
|
|
|
2019-06-10 21:40:02 -07:00
|
|
|
|
2019-10-04 16:19:22 -07:00
|
|
|
|
2019-10-06 21:09:30 -07:00
|
|
|
|
|
|
|
|
|
2019-09-02 21:31:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-13 14:33:43 +03:00
|
|
|
|
2019-09-02 21:31:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-06 21:09:30 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-09-02 21:31:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-06-14 11:37:39 -07:00
|
|
|
|