Skip to content

Commit 4504ab0

Browse files
nxa22042davem330
authored andcommitted
net/tls: Inform user space about send buffer availability
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>
1 parent 5b5f99b commit 4504ab0

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

net/tls/tls_device.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,6 @@ void tls_device_write_space(struct sock *sk, struct tls_context *ctx)
558558
MSG_DONTWAIT | MSG_NOSIGNAL);
559559
sk->sk_allocation = sk_allocation;
560560
}
561-
562-
if (!rc)
563-
ctx->sk_write_space(sk);
564561
}
565562

566563
void handle_device_resync(struct sock *sk, u32 seq, u64 rcd_sn)

net/tls/tls_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ int tls_push_sg(struct sock *sk,
146146
}
147147

148148
ctx->in_tcp_sendpages = false;
149-
ctx->sk_write_space(sk);
150149

151150
return 0;
152151
}
@@ -228,6 +227,8 @@ static void tls_write_space(struct sock *sk)
228227
else
229228
#endif
230229
tls_sw_write_space(sk, ctx);
230+
231+
ctx->sk_write_space(sk);
231232
}
232233

233234
static void tls_ctx_free(struct tls_context *ctx)

0 commit comments

Comments
 (0)