]> git.baikalelectronics.ru Git - kernel.git/commit
net: mctp: add an explicit reference from a mctp_sk_key to sock
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 24 Jan 2023 02:01:03 +0000 (10:01 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:34:47 +0000 (08:34 +0100)
commit23cf3b60dd809ed84ae58ef490d4b0b6275492a3
treedae32cb3ca40f664bcab5076daf9e49d605d8854
parentb026360fcee5bc25fa2a55b2056702978f1f41b6
net: mctp: add an explicit reference from a mctp_sk_key to sock

[ Upstream commit de8a6b15d9654c3e4f672d76da9d9df8ee06331d ]

Currently, we correlate the mctp_sk_key lifetime to the sock lifetime
through the sock hash/unhash operations, but this is pretty tenuous, and
there are cases where we may have a temporary reference to an unhashed
sk.

This change makes the reference more explicit, by adding a hold on the
sock when it's associated with a mctp_sk_key, released on final key
unref.

Fixes: c88d6fe021f9 ("mctp: locking, lifetime and validity changes for sk_keys")
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/route.c