From: Wen Gu <guwen@xxxxxxxxxxxxxxxxx> commit c3dfcdb65ec1a4813ec1e0871c52c671ba9c71ac upstream. The logic to determine if SMC-D link group matches is incorrect. The correct logic should be that it only returns true when the GID is the same, and the SMC-D device is the same and the extended GID is the same (in the case of virtual ISM). It can be fixed by adding brackets around the conditional (or ternary) operator expression. But for better readability and maintainability, it has been changed to an if-else statement. Reported-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxx> Closes: https://lore.kernel.org/r/13579588-eb9d-4626-a063-c0b77ed80f11@xxxxxxxxxxxxx Fixes: b40584d14570 ("net/smc: compatible with 128-bits extended GID of virtual ISM device") Link: https://lore.kernel.org/r/13579588-eb9d-4626-a063-c0b77ed80f11@xxxxxxxxxxxxx Signed-off-by: Wen Gu <guwen@xxxxxxxxxxxxxxxxx> Reviewed-by: Alexandra Winter <wintera@xxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20240125123916.77928-1-guwen@xxxxxxxxxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/smc/smc_core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1889,9 +1889,15 @@ static bool smcd_lgr_match(struct smc_li struct smcd_dev *smcismdev, struct smcd_gid *peer_gid) { - return lgr->peer_gid.gid == peer_gid->gid && lgr->smcd == smcismdev && - smc_ism_is_virtual(smcismdev) ? - (lgr->peer_gid.gid_ext == peer_gid->gid_ext) : 1; + if (lgr->peer_gid.gid != peer_gid->gid || + lgr->smcd != smcismdev) + return false; + + if (smc_ism_is_virtual(smcismdev) && + lgr->peer_gid.gid_ext != peer_gid->gid_ext) + return false; + + return true; } /* create a new SMC connection (and a new link group if necessary) */ Patches currently in stable-queue which might be from guwen@xxxxxxxxxxxxxxxxx are queue-6.6/net-smc-define-a-reserved-chid-range-for-virtual-ism.patch queue-6.6/net-smc-unify-the-structs-of-accept-or-confirm-messa.patch queue-6.6/net-smc-initialize-close_work-early-to-avoid-warning.patch queue-6.6/net-smc-compatible-with-128-bits-extended-gid-of-vir.patch queue-6.6/net-smc-at-de-tach-sndbuf-to-peer-dmb-if-supported.patch queue-6.6/net-smc-fix-incorrect-smc-d-link-group-matching-logic.patch queue-6.6/net-smc-add-operations-to-merge-sndbuf-with-peer-dmb.patch queue-6.6/net-smc-mark-optional-smcd_ops-and-check-for-support.patch queue-6.6/net-smc-introduce-sub-functions-for-smc_clc_send_con.patch queue-6.6/net-smc-fix-lgr-and-link-use-after-free-issue.patch queue-6.6/net-smc-rename-some-fce-to-fce_v2x-for-clarity.patch