net/smc: Use a mutex for locking "struct smc_pnettable"
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Wed, 23 Feb 2022 10:02:52 +0000 (11:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2022 10:47:59 +0000 (11:47 +0100)
commit062772d5cc8cd4018585cdbc2c03457dfb5a3d88
tree1ade99fabd48bdfc4fe51b0cba6d086af00b518f
parente96e204ee6fa46702f6c94c3c69a09e69e0eac52
net/smc: Use a mutex for locking "struct smc_pnettable"

commit 7ff57e98fb78ad94edafbdc7435f2d745e9e6bb5 upstream.

smc_pnetid_by_table_ib() uses read_lock() and then it calls smc_pnet_apply_ib()
which, in turn, calls mutex_lock(&smc_ib_devices.mutex).

read_lock() disables preemption. Therefore, the code acquires a mutex while in
atomic context and it leads to a SAC bug.

Fix this bug by replacing the rwlock with a mutex.

Reported-and-tested-by: syzbot+4f322a6d84e991c38775@syzkaller.appspotmail.com
Fixes: 64e28b52c7a6 ("net/smc: add pnet table namespace support")
Confirmed-by: Tony Lu <tonylu@linux.alibaba.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Acked-by: Karsten Graul <kgraul@linux.ibm.com>
Link: https://lore.kernel.org/r/20220223100252.22562-1-fmdefrancesco@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/smc/smc_pnet.c
net/smc/smc_pnet.h