]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
tls: skip setting sk_write_space on rekey
authorSabrina Dubroca <sd@queasysnail.net>
Thu, 9 Jan 2025 22:30:54 +0000 (23:30 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 11 Jan 2025 02:34:45 +0000 (18:34 -0800)
syzbot reported a problem when calling setsockopt(SO_SNDBUF) after a
rekey. SO_SNDBUF calls sk_write_space, ie tls_write_space, which then
calls the original socket's sk_write_space, saved in
ctx->sk_write_space. Rekeys should skip re-assigning
ctx->sk_write_space, so we don't end up with tls_write_space calling
itself.

Fixes: 47069594e67e ("tls: implement rekey for TLS1.3")
Reported-by: syzbot+6ac73b3abf1b598863fa@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/676d231b.050a0220.2f3838.0461.GAE@google.com/
Tested-by: syzbot+6ac73b3abf1b598863fa@syzkaller.appspotmail.com
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/ffdbe4de691d1c1eead556bbf42e33ae215304a7.1736436785.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/tls/tls_main.c

index 9ee5a83c5b400a9003d3d4988db7d813a61026f4..99ca4465f70216c5a44e4ca7477df0e93df6b76d 100644 (file)
@@ -737,6 +737,10 @@ static int do_tls_setsockopt_conf(struct sock *sk, sockptr_t optval,
        else
                ctx->rx_conf = conf;
        update_sk_prot(sk, ctx);
+
+       if (update)
+               return 0;
+
        if (tx) {
                ctx->sk_write_space = sk->sk_write_space;
                sk->sk_write_space = tls_write_space;