Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
net/tls: Inform user space about send buffer availability
Browse files Browse the repository at this point in the history
A previous fix ("tls: Fix write space handling") assumed that
user space application gets informed about the socket send buffer
availability when tls_push_sg() gets called. Inside tls_push_sg(), in
case do_tcp_sendpages() returns 0, the function returns without calling
ctx->sk_write_space. Further, the new function tls_sw_write_space()
did not invoke ctx->sk_write_space. This leads to situation that user
space application encounters a lockup always waiting for socket send
buffer to become available.

Rather than call ctx->sk_write_space from tls_push_sg(), it should be
called from tls_write_space. So whenever tcp stack invokes
sk->sk_write_space after freeing socket send buffer, we always declare
the same to user space by the way of invoking ctx->sk_write_space.

Fixes: 7463d3a ("tls: Fix write space handling")
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Reviewed-by: Boris Pismenny <borisp@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
nxa22042 authored and davem330 committed Mar 13, 2019
1 parent 5b5f99b commit 4504ab0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 0 additions & 3 deletions net/tls/tls_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,6 @@ void tls_device_write_space(struct sock *sk, struct tls_context *ctx)
MSG_DONTWAIT | MSG_NOSIGNAL);
sk->sk_allocation = sk_allocation;
}

if (!rc)
ctx->sk_write_space(sk);
}

void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn)
Expand Down
3 changes: 2 additions & 1 deletion net/tls/tls_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ int tls_push_sg(struct sock *sk,
}

ctx->in_tcp_sendpages = false;
ctx->sk_write_space(sk);

return 0;
}
Expand Down Expand Up @@ -228,6 +227,8 @@ static void tls_write_space(struct sock *sk)
else
#endif
tls_sw_write_space(sk, ctx);

ctx->sk_write_space(sk);
}

static void tls_ctx_free(struct tls_context *ctx)
Expand Down

0 comments on commit 4504ab0

Please sign in to comment.