From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303603; b=r3Lcjyyj10R0iISU316ZucDb3qKQCzs6IVVTL5hjvpDHRev4X9IW5E9Aac7p8+75/BGp yQxL6B9LFEZWaB/kZijwHoVOaP0X3lskXNFbf3Iscih+v0D2+QErkjxnDZ/hHSWDN4TlJ IoOD5P1PnhV+OCldoKhCpVYyMnmMOOdQbbsQMZSOr+Yodkm4+pSK913d5PM9L7hkizm0+ c9LMSH7nUvaD7+N+WgELR0ITSvjfid9j/el8qTm+hkEuNcCWS5brXL93hPqmhXUaqixkv WmnKDguU+saZAKKW+6CpwrDQKSsudKMtIeujBwVjTsfky+fHmMlIC64FrEI2w9avTbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303603; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=wee3g1DEH72AgWSo1Z1n26rmXim+wFaXdjUE5lOX7wU=; b=eJSwRKpuYt7MhrE1/Ze6IgGnHhcnK/kwGmiRuP6RVE//N8BOBPpfAEtc50Yu5uYl/ASa xMB0caX4c6gsNScwX6Pu0COgztzKA30k3+kHMpUqNA90WwlwIr6mgS14j9flApJca+/R/ vgirBRAM22fkqRFjl1tFIbp8mQPaKUYxMxQY/L3aIh3Yjwk79lDr+wXmIg1zRmEV42Gax z7PuwZjsUIKKp8zh+e36CncwBokWNdZTyClr5l3NWdPQ2+X8KkoxKENmUWgiiugJWN1sY NcwL6tYENM5gP+DYXUIz0UE6pntgrdLGzfy6Sj5c7P34EevlHUYJ1+tuttP5DVqB8Yw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DWHjYEOB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAAF3606A32D; Thu, 3 Dec 2026 13:13:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DWHjYEOB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C6B1F000C1; Thu, 3 Dec 2026 13:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796303603; bh=wee3g1DEH72AgWSo1Z1n26rmXim+wFaXdjUE5lOX7wU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=DWHjYEOB2kspL4S7DHoGj8haLJeqOhCRY34ISo9z9MKHTR/TRvvARkt8teuQjqmqe wK3wNEx7GaAN1wyf2yrccZ6a5S+bpsVOuewrua5x1W/tehb7Nkjox+wZl310JxkbDU 1jdeV++1EYk8oQUyp/yiQAjdR8uydn8jHARCA0FkMruYhaFoAO4zdAVQj97Ll2bGck UFejvo6MQQ4jog2Qg77zXmES4M5iAHd+zMtL6KPHlUU1WtdCdog6diB/ZPtW8xSfpv unvhhxLNBnZWCp6/ri6QoWZol76+zkVRRJprXiCAQ6OUAUmblgXj64QFM0dhe2HcB2 PYVb3OwTNarLQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next] net/smc: serialize the server establishment phase per peer, not globally Reply-To: sashiko-reviews@lists.linux.dev To: "Ermenson Junior" Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261202131243.664308-1-ermenson.sec@gmail.com> References: <20261202131243.664308-1-ermenson.sec@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 13:13:22 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] net/smc: missing SMCv1 check in smc_server_peer_pending_lock() -- commit 96c005e08a29bc14d74ae1b6b0b09f1153e206a7 Author: Ermenson Junior net/smc: serialize the server establishment phase per peer, not globally This commit replaces the hold of the global smc_server_lgr_pending mutex across the server-side CLC CONFIRM wait with a per-peer mutex hashed on the peer system ID and GIDs from the CLC proposal. > diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c > index c0d905140a10a..f2a8e32a2eea6 100644 > --- a/net/smc/af_smc.c > +++ b/net/smc/af_smc.c [ ... ] > @@ -66,6 +67,34 @@ static DEFINE_MUTEX(smc_client_lgr_pending); /* serial= ize link group > * creation on client > */ > =20 > +/* Serialize the server-side establishment phase per peer, hashed on the > + * fields of the proposal that smcr_lgr_match() compares: peer system id= and > + * both peer gids. The system id alone is all zero in a v2-only proposal. > + * Keeps further connections of a peer out of smc_conn_create() until a = new > + * link group's first link is active, which is what smc_server_lgr_pendi= ng > + * used to cover across the peer-paced CLC CONFIRM wait. See the changel= og > + * for what the key does not pin. > + */ > +#define SMC_SERVER_PEER_PENDING_BITS 6 > +#define SMC_SERVER_PEER_PENDING_SIZE BIT(SMC_SERVER_PEER_PENDING_BITS) > +static struct mutex smc_server_peer_pending[SMC_SERVER_PEER_PENDING_SIZE= ]; > + > +static struct mutex * > +smc_server_peer_pending_lock(struct smc_clc_msg_proposal *pclc) > +{ > + struct smc_clc_v2_extension *v2_ext =3D NULL; > + u32 key; > + > + key =3D jhash(pclc->lcl.id_for_peer, SMC_SYSTEMID_LEN, 0); > + key =3D jhash(pclc->lcl.gid, SMC_GID_SIZE, key); > + if (smcr_indicated(pclc->hdr.typev2)) > + v2_ext =3D smc_get_clc_v2_ext(pclc); > + if (v2_ext) > + key =3D jhash(v2_ext->roce, SMC_GID_SIZE, key); > + > + return &smc_server_peer_pending[key & (SMC_SERVER_PEER_PENDING_SIZE - 1= )]; > +} [Severity: Medium] Should smc_server_peer_pending_lock() check pclc->hdr.version > SMC_V1 before inspecting pclc->hdr.typev2 and calling smc_get_clc_v2_ext(pclc)? In an SMCv1 proposal header, the 2-bit typev2 field is reserved and set to 0, which matches SMC_TYPE_R (0) and satisfies smcr_indicated(). When an SMC-Rv1 proposal does not indicate SMC-D (typev1 =3D=3D SMC_TYPE_R, iparea_offset =3D=3D 0), smc_get_clc_msg_smcd() does not check iparea_offset and returns (pclc + 1), which points into the IP prefix area rather than a struct smc_clc_msg_smcd: net/smc/smc_clc.h:smc_get_clc_msg_smcd() { if (smcd_indicated(prop->hdr.typev1) && ntohs(prop->iparea_offset) !=3D sizeof(struct smc_clc_msg_smcd)) return NULL; return (struct smc_clc_msg_smcd *)(prop + 1); } smc_get_clc_v2_ext() then reads prop_smcd->v2_ext_offset from the prefix area (overlapping the first IPv6 prefix entry when ipv6_prefixes_cnt >=3D 1= ). If those bytes fall between 1 and max_offset, v2_ext is non-NULL and 16 bytes from the buffer are hashed as v2_ext->roce. Concurrent SMC-Rv1 first-contact handshakes from the same single-port peer (for example, over IPv4 and IPv6) can then hash to different mutex buckets and race to create duplicate link groups after smc_server_lgr_pending is released. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202131243.6643= 08-1-ermenson.sec@gmail.com?part=3D1