]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net/tls: swap sk_write_space on close
authorJakub Kicinski <jakub.kicinski@netronome.com>
Sat, 10 Aug 2019 01:36:23 +0000 (18:36 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 10 Aug 2019 02:55:22 +0000 (19:55 -0700)
Now that we swap the original proto and clear the ULP pointer
on close we have to make sure no callback will try to access
the freed state. sk_write_space is not part of sk_prot, remember
to swap it.

Reported-by: syzbot+dcdc9deefaec44785f32@syzkaller.appspotmail.com
Fixes: 95fa145479fb ("bpf: sockmap/tls, close can race with map free")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tls/tls_main.c

index 9cbbae606ced4a12469151a523c11d3d3cfa7d7b..ce6ef56a65ef675b799364b31380ae530225dd32 100644 (file)
@@ -308,6 +308,7 @@ static void tls_sk_proto_close(struct sock *sk, long timeout)
        if (free_ctx)
                icsk->icsk_ulp_data = NULL;
        sk->sk_prot = ctx->sk_proto;
+       sk->sk_write_space = ctx->sk_write_space;
        write_unlock_bh(&sk->sk_callback_lock);
        release_sock(sk);
        if (ctx->tx_conf == TLS_SW)