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=1796139005; b=DfVn63eZaVBqFIBNgYsHvgyHGXa1oVdX5SebYf6MhwnEbls5+dxPIlvzZp5eV6oxbHko FKfQ0RS3DlccLZ5As7rKtHq6k86l0Vxlxfx8WLVsoDsxT7F/ATjzA5HmoSWhzr+CbtWFQ bkn+Y5PgvYROfZ9n875I/HIZ9hrS4Q+xA0EbMHKvYP1HfP9qypOPwiqH5boSpwdRpPhsz LWMVpjiArNdOCEt7H6yK/dhlq3KuZflPWTVEfLzJtZRmT4zQ778dIfms0DSItc1pg+Wjq PNk/zwsZ6itT845tsuI+ElbK3iP/eIaZdDhdsTnvF6lsnrqZTLAXX8XMHwBgycGkPjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796139005; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=xx0A/PrVXmDqtHODNO1hHDmuLO7LubAJFk0V2T6FoQw=; b=Ri0BwqhbL+h7B9KODyloGHFhAjW/XVI2gtwvrXDIPxRJPA3lR7uvMBQbZunkOnWBatm3 tcKYs3M6kL2L/ngQC/nN26iJP7cqmm32PEoU6jNQr3zIkcUA2KEW1mQfyZiOJRIENXkGv klMrfzDyHgMhtmMXcjn7PDU1XjLz4ipHLQCkQDLwmhNAIxE/96ty3kw2in58Zf5UDBIX3 ZR2ATCoJgI2jRbbDnZcqItxJpAA7n1vv319xQ6kW4b6tKrVIl1OHkKStlIo9Msp4OzKnf GD/UkeSoBWJMn419Nc0CiXGihBkCtwwVq0l5PNOxZ5JeAQ4Cfuil4qHU9siNSwOl/3A== 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=FYzdbrfb; 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 04E09606A322; Tue, 1 Dec 2026 15:30:04 +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=FYzdbrfb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17B821F00893; Tue, 1 Dec 2026 15:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796139004; bh=xx0A/PrVXmDqtHODNO1hHDmuLO7LubAJFk0V2T6FoQw=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=FYzdbrfbIxpgeqMCG8by584HNzVSjqk6Yhw4RnU+BPem8N73sT5LiwWpH/mpl4zAY mL+KuAh2SUw41qdvpIKPyICQVvG/fgAlLkCZ7/QhmwgQ/VProB3IhElYYWcYAU6+LX yDEvSbssTHZrcvDMapd16FbsfBwH8+FclDgXVDtI+bnZPiEL4EKBFu3JtBDMRwxEbI 5N4R/UPusKlrLKjtnH3eRxhmY0vFWHM7MGUt1x/euDLFtFOqO2tfa6+s9HBidDs5dJ LM9ApiJxQvBIj/VR2kvQOOK7r2YIgg4W8Ymcjk8dM3LKZxgLLUa8W1PlhagUULVTy+ RcXyQrdaEOccw== Date: Tue, 1 Dec 2026 17:30:00 +0200 From: Leon Romanovsky To: Jaeyeong Lee Cc: Jason Gunthorpe , Artemy Kovalyov , Yishai Hadas , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3] RDMA/mlx5: Preserve DEVX objects after failed output copy Message-ID: <20261201153000.GG31440@unreal> References: <20261111105346.3220427-1-lee@jaeyeong.cc> <20261115135123.GD42525@unreal> <20261122103715.51731-1-lee@jaeyeong.cc> <179574905000.68536.2524255610860968331@jaeyeong.cc> X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <179574905000.68536.2524255610860968331@jaeyeong.cc> On Fri, Nov 27, 2026 at 03:10:55AM +0000, Jaeyeong Lee wrote: > A DEVX create command can succeed before indirect mkey registration or > copying the command output to userspace fails. The current unwind path > destroys the hardware object directly, ignores a destroy failure, and > frees struct devx_obj. > > If the object cannot be destroyed, How can this happen? This is exactly why your reproducer is invalid, it does not account for how real hardware behaves. Thanks > it remains live while its software wrapper is gone. A later event or > cleanup can then access the freed wrapper. > > Mark the uobject as containing a valid hardware object once all state > required by devx_obj_cleanup() is initialized. Return later errors > directly so the uverbs abort path runs devx_obj_cleanup(). If destruction > fails, rdma_alloc_abort_uobject() commits the uobject and keeps it alive > for another cleanup attempt at file close. > > This also routes indirect mkey registration failures through the same > cleanup path and removes the duplicate manual unwind. > > Fixes: 7efce3691d33 ("IB/mlx5: Add obj create and destroy functionality") > Cc: stable@vger.kernel.org > Signed-off-by: Finder16 > Signed-off-by: Jaeyeong Lee > --- > Changes in v3: > - Finalize the uobject before indirect mkey registration and output copy. > - Route both failure paths through the uverbs abort cleanup. > - Remove the manual obj_destroy unwind. > - Describe the generic failed-destroy lifetime issue instead of relying on > the DCT-specific reproducer. > > drivers/infiniband/hw/mlx5/devx.c | 23 +++++++++-------------- > 1 file changed, 9 insertions(+), 14 deletions(-) > > diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c > index 5ba783bc7f9b7..b6ba6d7aa5c8f 100644 > --- a/drivers/infiniband/hw/mlx5/devx.c > +++ b/drivers/infiniband/hw/mlx5/devx.c > @@ -1535,7 +1535,6 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_CREATE)( > struct mlx5_ib_ucontext *c = rdma_udata_to_drv_context( > &attrs->driver_udata, struct mlx5_ib_ucontext, ibucontext); > struct mlx5_ib_dev *dev = to_mdev(c->ibucontext.device); > - u32 out[MLX5_ST_SZ_DW(general_obj_out_cmd_hdr)]; > struct devx_obj *obj; > u16 obj_type = 0; > int err, err2 = 0; > @@ -1614,29 +1613,25 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_CREATE)( > &obj_id); > WARN_ON(obj->dinlen > MLX5_MAX_DESTROY_INBOX_SIZE_DW * sizeof(u32)); > > - err = uverbs_copy_to(attrs, MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_OUT, cmd_out, cmd_out_len); > - if (err) > - goto obj_destroy; > - > if (opcode == MLX5_CMD_OP_CREATE_GENERAL_OBJECT) > obj_type = MLX5_GET(general_obj_in_cmd_hdr, cmd_in, obj_type); > obj->obj_id = get_enc_obj_id(opcode | obj_type << 16, obj_id); > + uverbs_finalize_uobj_create(attrs, > + MLX5_IB_ATTR_DEVX_OBJ_CREATE_HANDLE); > > if (obj->flags & DEVX_OBJ_FLAGS_INDIRECT_MKEY) { > err = devx_handle_mkey_indirect(obj, dev, cmd_in, cmd_out); > if (err) > - goto obj_destroy; > + return err; > } > + > + err = uverbs_copy_to(attrs, MLX5_IB_ATTR_DEVX_OBJ_CREATE_CMD_OUT, > + cmd_out, cmd_out_len); > + if (err) > + return err; > + > return 0; > > -obj_destroy: > - if (obj->flags & DEVX_OBJ_FLAGS_DCT) > - mlx5_core_destroy_dct(obj->ib_dev, &obj->core_dct); > - else if (obj->flags & DEVX_OBJ_FLAGS_CQ) > - mlx5_core_destroy_cq(obj->ib_dev->mdev, &obj->core_cq); > - else > - mlx5_cmd_exec(obj->ib_dev->mdev, obj->dinbox, obj->dinlen, out, > - sizeof(out)); > obj_free: > kfree(obj); > return err2 ?: err; > > base-commit: 94e81a1f3ffabb388f7d0a9674bb1d3acc067e00 > -- > 2.43.0 > > >