net: mctp: mark socks as dead on unhash, prevent re-add
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 24 Jan 2023 02:01:06 +0000 (10:01 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:27:28 +0000 (08:27 +0100)
commite69c3a0d9d3dcacb3f89e3b5cda0fa0372717632
treee5bd3e99ef8cd522598bbf891afaf1296b40e72d
parent954cc215cd7ace3591829c8361004d29266883cc
net: mctp: mark socks as dead on unhash, prevent re-add

[ Upstream commit b98e1a04e27fddfdc808bf46fe78eca30db89ab3 ]

Once a socket has been unhashed, we want to prevent it from being
re-used in a sk_key entry as part of a routing operation.

This change marks the sk as SOCK_DEAD on unhash, which prevents addition
into the net's key list.

We need to do this during the key add path, rather than key lookup, as
we release the net keys_lock between those operations.

Fixes: 4a992bbd3650 ("mctp: Implement message fragmentation & reassembly")
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/mctp/af_mctp.c
net/mctp/route.c