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=1796213037; b=5QVbCKbrMzT++bitWEPew+1EKQHJq4pCuTdFNAsQTh0saCNI7qnDQRvjWRYiC3l4DrgM mxIBOfkRM6JQLZ/xZFPXivhGoxQYrMFZJjjaf8ebOMFBNa7YE/5PWEZSXjSToq1ztRNcQ Xzx/IHjXuA73aCV/otFTVOYNcgMrMezeYTxseYfQdjrPp1zQtoQ5pKDLvpiklJMVnKYq+ 4/bUQY7/unH3SQdEWVxRxQUgWsn+AbalW2AHyINDVzT0UDo9d9LwDVkl+2RMujHL5HXt5 My2Vmx7hXrbeCSWlqgCJfK84kz/dIC+jLjhlxvpEexDhNfqiiyJy15PA5uLqfnlGDKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796213037; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=3i4RiTut0JqxT/uKf1RkSR9LvAo5GN94rR4/8G6klQ0=; b=N+8M5QVfKg/SaSGZkRtHTJLLfOgQPok7U12oV9sr0MaOLDR8DQTQXbagJSIR4HUk61Ih fewE+h79wqpVZO1+pUoGLDi2/diwIHF6GvWFOPytpeQnoWzHx87MMrdIXO4Wn+rGeRw7P cSoQECUmzqartzeTRbfueLt1P4EclmRcKZkCZo8Ux+7EJSpGRcFnzRPPJUdt2w67JSbfT j532GP39pGbpNOPDJ3V9FdnUXhzRzyQGDHAuRYI+jkHYsKf/0rJqs7Q4USvaaPQpgbu8h nWfCOL8BWMYR3N6A78qc81sACWSB0Ti8/BNPPByroD6NftOnKKMiaD3UmRWpTxCGAdQ== 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=Xcq3Mfmc; 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 62F2D606A323 for ; Wed, 2 Dec 2026 12:03:57 +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=Xcq3Mfmc Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED6371F000C1; Wed, 2 Dec 2026 12:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796213037; bh=3i4RiTut0JqxT/uKf1RkSR9LvAo5GN94rR4/8G6klQ0=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=Xcq3Mfmc8pgM4U9bxncLEb5KD0IDVPTlPBdK131iYVHxXqdRTO50aTenImk7qFJfX Ck1ByL3X5LTDkHgxv4WEBBL7Ha21vBDaymTAPzd3NIjf31oFsdaHJ2sOAFkYqY0QXK EK9TKZeHn4LNgpLO0zdOpgWRj5+Q/kpd0U3LmVuMye034WLIv6bCISrce1u3Tqvo05 EwkCPzviSOh0IRF23Zs+KG+dQfOp9j4bVxQFU+NGXszifsgPhFHYbGNSfUwOq6oe9k rorjmSbMWMyfs4igMqSvbTOAC+w7KOIokGKO5xnj4/S9Yu0H9c15oXKmmSdlrxDbnC 9p8DQZ3SgC2wA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net v2] net/rds: do not leave ic->i_cm_id pointing at a freed cm_id Reply-To: sashiko-reviews@lists.linux.dev To: "Piyus Kedia" , linux-rdma@vger.kernel.org In-Reply-To: <20261201120335.3527546-1-piyus@iiitd.ac.in> References: <20261201120335.3527546-1-piyus@iiitd.ac.in> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 12:03:56 +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/rds: transient ERR_PTR in ic->i_cm_id in rds_ib_conn_path_connect() -- commit 4e0ce09e70c35a382957e4408ddec7b9d686e123 Author: Piyus Kedia net/rds: do not leave ic->i_cm_id pointing at a freed cm_id This commit clears ic->i_cm_id with WRITE_ONCE() before calling rdma_destroy_id() and reads it with READ_ONCE() in the FRMR registration and invalidation paths, adding a NULL check in rds_ib_post_reg_frmr(). Link: https://lore.kernel.org/all/20261128033737.467966-1-piyus@iiitd.ac.in/ > diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c > index 16bfeaaf3b974..1de3866b1ab62 100644 > --- a/net/rds/ib_cm.c > +++ b/net/rds/ib_cm.c > @@ -978,6 +978,7 @@ int rds_ib_conn_path_connect(struct rds_conn_path *cp) > struct sockaddr_storage src, dest; > rdma_cm_event_handler handler; > struct rds_ib_connection *ic; > + struct rdma_cm_id *cm_id; > int ret; > =20 > ic =3D conn->c_transport_data; > @@ -994,7 +995,7 @@ int rds_ib_conn_path_connect(struct rds_conn_path *cp) > RDMA_PS_TCP, IB_QPT_RC); > if (IS_ERR(ic->i_cm_id)) { > ret =3D PTR_ERR(ic->i_cm_id); > - ic->i_cm_id =3D NULL; > + WRITE_ONCE(ic->i_cm_id, NULL); > rdsdebug("rdma_create_id() failed: %d\n", ret); > goto out; > } [Severity: Medium] Can a lockless reader observe an ERR_PTR in ic->i_cm_id when rdma_create_id() fails? rds_ib_conn_path_connect() assigns the return value of rdma_create_id() directly to ic->i_cm_id before checking IS_ERR(ic->i_cm_id) and clearing it with WRITE_ONCE(ic->i_cm_id, NULL). Because the lockless readers in rds_ib_get_mr(), rds_ib_post_reg_frmr() and rds_ib_post_inv() only check !i_cm_id before dereferencing i_cm_id->qp, a concurrent reader can sample the error pointer during that window and fault: CPU0 CPU1 rds_ib_conn_path_connect() ic->i_cm_id =3D rdma_create_id(...) /* returns ERR_PTR(-ENOMEM) */ rds_ib_post_inv() i_cm_id =3D READ_ONCE(ibmr->ic->i= _cm_id) if (!i_cm_id || !i_cm_id->qp ...) /* faults on ERR_PTR->qp */ if (IS_ERR(ic->i_cm_id)) WRITE_ONCE(ic->i_cm_id, NULL) Storing the result of rdma_create_id() in the local cm_id variable and only publishing it to ic->i_cm_id with WRITE_ONCE() after IS_ERR(cm_id) succeeds would avoid exposing an error pointer to readers. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201120335.3527= 546-1-piyus@iiitd.ac.in?part=3D1