net/tls: Don't recursively call push_record during tls_write_space callbacks
authorDave Watson <davejwatson@fb.com>
Tue, 1 May 2018 20:05:39 +0000 (13:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 19 May 2018 08:20:24 +0000 (10:20 +0200)
commit3ac0f3e0b823a1217896ae70a731c825bf26f778
tree11aa5d98bdba088488d12bef6d484e0da55dbd7b
parent78ac65e8e940a0d590a7a2d838ed0cb7d909912a
net/tls: Don't recursively call push_record during tls_write_space callbacks

[ Upstream commit c212d2c7fc4736d49be102fb7a1a545cdc2f1fea ]

It is reported that in some cases, write_space may be called in
do_tcp_sendpages, such that we recursively invoke do_tcp_sendpages again:

[  660.468802]  ? do_tcp_sendpages+0x8d/0x580
[  660.468826]  ? tls_push_sg+0x74/0x130 [tls]
[  660.468852]  ? tls_push_record+0x24a/0x390 [tls]
[  660.468880]  ? tls_write_space+0x6a/0x80 [tls]
...

tls_push_sg already does a loop over all sending sg's, so ignore
any tls_write_space notifications until we are done sending.
We then have to call the previous write_space to wake up
poll() waiters after we are done with the send loop.

Reported-by: Andre Tomt <andre@tomt.net>
Signed-off-by: Dave Watson <davejwatson@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/tls.h
net/tls/tls_main.c