From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 543BB3939B3; Sat, 12 Sep 2026 19:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789239904; cv=none; b=kSbC5+m33cR+P0IoCADQjnYTQsOaHokKsGN2mqGjEZPU9kJF+b9Kj6PteFxxmxp0S8crVHP3qel42Ekz5JR43FgFQoQPFkheRnah/t3iP2rYSQuyp6KJI4KcCqOH15QJsJKwzJPyvTRIClwCnfwjR8eVWwYihFU2MpqNDhytmPM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789239904; c=relaxed/simple; bh=WgaWKiK75gMEWBMbmENSrfJvPnfwJRRyeDWfGQcGTgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q6B1a5qi4vjiJrLbLpP88xi0BMRiOiPdgm5gz+IhizZFuskcMEmgW40o7UYPg2N45XEEsjpAXdz+IVGfoW0qkpH358JnvS181NzsQgzFP7IE1ufkdy+QBzrsBqfwo7JhdaSPZ66s45b0JqJ01vvJWUuF3P59hABtz0hvzSIVz1Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iJpRgJt/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="iJpRgJt/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 043971F000FF; Sat, 12 Sep 2026 19:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789239902; bh=ADViIh3YMJ76vvZyqtT0x5pokTNuOnin1QKXLWMWsO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iJpRgJt/1OyLegAux6XjWYyU1CNTAmtaIcyFw+26vEZuFvQFy9WKbJ8uc8Qp7o67a xhX04fxAlaCd3O/yTPO1iU8gtVAXW2Zi9Lv7wYKDIs+entjbuQQKbL+kLvce7qNs/s +zBw4uRJUkxWJKyfOK67IjKmPy2yqRcAhkQy+kQc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shuangpeng Bai , Leon Romanovsky , Sasha Levin Subject: [PATCH 5.15 722/935] RDMA/siw: Fix use-after-free in siw_accept() Date: Sat, 12 Sep 2026 09:02:32 +0200 Message-ID: <20260912065543.393702291@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065526.833703348@linuxfoundation.org> References: <20260912065526.833703348@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shuangpeng Bai [ Upstream commit a9394971825933074032794a5feee5211509c774 ] siw_accept() looks up the QP supplied by userspace. If that QP is already in RTS, the function jumps to error cleanup before associating the incoming CEP with it. The cleanup tests whether qp->cep is non-NULL and assumes the current call installed the association. However, qp->cep can point to the CEP of an existing connection. The cleanup then drops a reference from the incoming cep, not qp->cep. Once the incoming endpoint loses its remaining references, this can free it before the subsequent cep->qp store, causing a use-after-free. It also clears the existing QP association. Only release the association reference when qp->cep is the incoming CEP. This preserves an existing association and avoids accessing the freed endpoint. Fixes: 6c52fdc244b5 ("rdma/siw: connection management") Signed-off-by: Shuangpeng Bai Link: https://patch.msgid.link/20260801213632.1086548-1-shuangpeng.kernel@gmail.com Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/sw/siw/siw_cm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c index 8b5c916619a1d..884c1e72bc7ec 100644 --- a/drivers/infiniband/sw/siw/siw_cm.c +++ b/drivers/infiniband/sw/siw/siw_cm.c @@ -1712,7 +1712,7 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) cep->state = SIW_EPSTATE_CLOSED; siw_free_cm_id(cep); - if (qp->cep) { + if (qp->cep == cep) { siw_cep_put(cep); qp->cep = NULL; } -- 2.53.0