Skip to content

Commit 02b1fa0

Browse files
Jakub Kicinskidavem330
authored andcommitted
net/tls: don't pay attention to sk_write_pending when pushing partial records
sk_write_pending being not zero does not guarantee that partial record will be pushed. If the thread waiting for memory times out the pending record may get stuck. In case of tls_device there is no path where parial record is set and writer present in the first place. Partial record is set only in tls_push_sg() and tls_push_sg() will return an error immediately. All tls_device callers of tls_push_sg() will return (and not wait for memory) if it failed. Fixes: a42055e ("net/tls: Add support for async encryption of records for performance") Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 17fdd76 commit 02b1fa0

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

net/tls/tls_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,11 @@ static int tls_device_push_pending_record(struct sock *sk, int flags)
623623

624624
void tls_device_write_space(struct sock *sk, struct tls_context *ctx)
625625
{
626-
if (!sk->sk_write_pending && tls_is_partially_sent_record(ctx)) {
626+
if (tls_is_partially_sent_record(ctx)) {
627627
gfp_t sk_allocation = sk->sk_allocation;
628628

629+
WARN_ON_ONCE(sk->sk_write_pending);
630+
629631
sk->sk_allocation = GFP_ATOMIC;
630632
tls_push_partial_record(sk, ctx,
631633
MSG_DONTWAIT | MSG_NOSIGNAL |

net/tls/tls_sw.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,12 +2180,9 @@ void tls_sw_write_space(struct sock *sk, struct tls_context *ctx)
21802180
struct tls_sw_context_tx *tx_ctx = tls_sw_ctx_tx(ctx);
21812181

21822182
/* Schedule the transmission if tx list is ready */
2183-
if (is_tx_ready(tx_ctx) && !sk->sk_write_pending) {
2184-
/* Schedule the transmission */
2185-
if (!test_and_set_bit(BIT_TX_SCHEDULED,
2186-
&tx_ctx->tx_bitmask))
2187-
schedule_delayed_work(&tx_ctx->tx_work.work, 0);
2188-
}
2183+
if (is_tx_ready(tx_ctx) &&
2184+
!test_and_set_bit(BIT_TX_SCHEDULED, &tx_ctx->tx_bitmask))
2185+
schedule_delayed_work(&tx_ctx->tx_work.work, 0);
21892186
}
21902187

21912188
void tls_sw_strparser_arm(struct sock *sk, struct tls_context *tls_ctx)

0 commit comments

Comments
 (0)