SUNRPC: Do not dereference non-socket transports in sysfs

[ Upstream commit 421ab1be43 ]

Do not cast the struct xprt to a sock_xprt unless we know it is a UDP or
TCP transport. Otherwise the call to lock the mutex will scribble over
whatever structure is actually there. This has been seen to cause hard
system lockups when the underlying transport was RDMA.

Fixes: b49ea673e1 ("SUNRPC: lock against ->sock changing during sysfs read")
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Trond Myklebust 2022-03-25 10:37:31 -04:00 • committed by Greg Kroah-Hartman
commit 7dbee046e2
4 changed files with 54 additions and 31 deletions