From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 29F85BE4F for ; Sun, 9 Jun 2024 08:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921503; cv=none; b=nVuoLhrpm8FOK2Y0q0fjNYRVe6isBZwP3wN7QnRrOEnEdL+0P13QMpzl+8nFsVdXtgWcGdx8KrU/E9sUBMzhkX61cDYUT1YepMRzHVkadlUglP1TvXTEa7YwWoIfCyEyKNayMENIe12rDqZmRjrY8BiQGw38tm6iZjQuQmzk9+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921503; c=relaxed/simple; bh=g3+xLmhQyYah+bh00/4xl+QNJSsrj1dXs8Rc3x2kvXk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=i17x0O41fSqpyTZ1uu/SlTzLohEzoYFhRPL9pEayukNAO5OgLM1DysaoZsmGhDvLVFAYrN7E+rQr5A90BtZHsOLzJAuOnJbFGPVHm3iO0L3e4jkGW+9Eq68L7XJZM4NNc0xgDOjjo3LKhh94yDOCL1rz++u/8Sr4ZeUStvCMbYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CyEZRszC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CyEZRszC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2726DC2BD10; Sun, 9 Jun 2024 08:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717921502; bh=g3+xLmhQyYah+bh00/4xl+QNJSsrj1dXs8Rc3x2kvXk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CyEZRszCbC207wkoLXvgbCMC5ZF5GOJJ2aGt2whZvpdrn3MW6ODnt62Szz5v8XOyM n5Dp2TSR91cGop2UY6aFHXpoO/F4HeUB/9rj/ItesGTkXKTAZ8EiS4aYM+4eo36g6j hfusfAvoClnU4ThnPoIwyH13ZvGlEsMy36SefenavRXk6NEC2RZbTSqR96PvMbwALz R4VXHcpIBlxVpz7aCQux87YPDvfh3gcxrSi6jwR0vcsswZvoYxD8nMt+owOHvmTDlg oxYVFDfQrtpqIywEvjUxuSZS7lQ1rc2aWHlf/MScpp9bIeh3/1SttNZwYCn2EoT5kb 3hNLDh/fb642w== Date: Sun, 9 Jun 2024 11:24:57 +0300 From: Leon Romanovsky To: Bart Van Assche Cc: Jason Gunthorpe , Shinichiro Kawasaki , Zhu Yanjun , linux-rdma@vger.kernel.org, Zhu Yanjun , Jason Gunthorpe , Luis Chamberlain , Joel Granados Subject: Re: [PATCH 5/5] RDMA/iwcm: Fix a use-after-free related to destroying CM IDs Message-ID: <20240609082457.GA8976@unreal> References: <20240605145117.397751-1-bvanassche@acm.org> <20240605145117.397751-6-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240605145117.397751-6-bvanassche@acm.org> On Wed, Jun 05, 2024 at 08:51:01AM -0600, Bart Van Assche wrote: > iw_conn_req_handler() associates a new struct rdma_id_private (conn_id) with > an existing struct iw_cm_id (cm_id) as follows: > > conn_id->cm_id.iw = cm_id; > cm_id->context = conn_id; > cm_id->cm_handler = cma_iw_handler; > > rdma_destroy_id() frees both the cm_id and the struct rdma_id_private. Make > sure that cm_work_handler() does not trigger a use-after-free by only > freeing of the struct rdma_id_private after all pending work has finished. > > Cc: stable This is not right way to mark a patch for stable. I added the following to the commit message and applied the patch: Cc: stable@vger.kernel.org Fixes: 59c68ac31e15 ("iw_cm: free cm_id resources on the last deref") There is no clear Fixes tag which I can use, so I used the latest significant commit that touch that area. Thanks > Reviewed-by: Zhu Yanjun > Tested-by: Shin'ichiro Kawasaki > Signed-off-by: Bart Van Assche > --- > drivers/infiniband/core/iwcm.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-)