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=1796282220; b=KL6zVPVHKvqu289MyQ/wcScKNOUh7euCm+hasnarJz4lf8H7Z7CHnlhzNt9TSW5Dlbp1 b2pWqdjge5D0UM0SSsi9GfzzAJ4guGEjGGaoJhl4wPMN7BgW1nptrOnpJ09r4BiCGxx5U Mh2c3bGniGD05hsGb8EtJp6R4pjdTEVxoA+qDZa6MY/kbgw3umlbMmDChkaZZxAB8AOTs 5v00PazYjDD84CRglOOWeqaWrwaD3vbc5WX6CO2SaHTAgZhGhhPogEWW+gly9mM4t83xY CoPZVgX/wwNV/uX7lj6CjfiVvUireuQmieB8cyl7y1iLRIgEEc4n8EDZjmKYxSGFX0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796282220; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=UyD3Vs9SvlShj/3vgHI96PDc61P3ULPb5uDSlG5oUjU=; b=YYRf3rrBwugoa7uvrKVbl8e0q0C9l/MRYY7j/Gs37ErZnXb5GIrrvo+79/3oxZyMqQ9V De1ZEqnp9BPs6XQ5wZf5oOABqC0bzdTdT/nxSH2qbBOOkGRMwCv+L42MZQ4IPvKwKcR1S ACZcxnyzYvNrXzjyhQ8PmMsY7N6+YTuZm9zE2ZhMk+H8xReJ7q3W7QHbkvW77Q2+vLDcz zkigyeuzz/CI+NzQ3HNV9pYLzc9ZmCA08QXEL/kizs2kevwN3BrSK4UH8kVKDStTZvVII ytBjp8jVQqBoPje3gEDIFezBn8XgodGvjn9/HXIXOD+Gu5uvDFdT0r2JxYYmmL9e/sA== 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=RbFxLJo1; 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 B6449606A322 for ; Thu, 3 Dec 2026 07:17:00 +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=RbFxLJo1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CD6E1F00896; Thu, 3 Dec 2026 07:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796282220; bh=UyD3Vs9SvlShj/3vgHI96PDc61P3ULPb5uDSlG5oUjU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=RbFxLJo1EWdHInnP3IkuA64LUHtH2Ilk0PpZ5RJaSpIXCu5fNp/TVwYsONE7U1SMB GDrMBfQCeMCoBD+LgqpbgEuu+uBHiVpwcTY1CVin9IVZTtvoUr2W1kgIMQeLCm8zh2 TkX09YtM0u59H2qnJUFv5mlvIAWnwmSqJcp9/u0p1j0YU9KLIKaEhDxl9Nf4SVdlst ylDSJeOCiCu0MNH6xOlhhaRa40+SBvl9YE2QhXWRM4FdLUSceBLSfECU/H3Zsq/sTs ShzQrQUjfkg8NiEp40O+luEvzQEH9+LGZ0rHDEQeS1ezGdV2TrDVYhYZm3cfKTuoxZ AjhT6JE1fQIbA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v9] cxl/core: Create EINJ debugfs files when EINJ is initialized Reply-To: sashiko-reviews@lists.linux.dev To: "Yongxin Yang" Cc: linux-cxl@vger.kernel.org In-Reply-To: <20261203065904.1554483-1-yangyongxin@kylinos.cn> References: <20261203065904.1554483-1-yangyongxin@kylinos.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:16:59 +0000 X-Mailing-List: linux-cxl@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 2 potential issues to consider: - [Medium] cxl/core: missing root host lock in cxl_einj_debugfs_create_dport_dirs() - [Low] ACPI: APEI: EINJ: undocumented constraints on einj_cxl_register_ready_cb() -- commit 63612c001bb6f8f3cf3912f918dc83156766933d Author: Yongxin Yang cxl/core: Create EINJ debugfs files when EINJ is initialized This commit defers CXL EINJ debugfs file creation to a callback invoked once EINJ is initialized, and walks cxl_bus_type to create any dport debugfs directories that were skipped before EINJ came up. Link: https://lore.kernel.org/all/20261104061256.1449275-1-yangyongxin@kyli= nos.cn/ > diff --git a/drivers/acpi/apei/einj-cxl.c b/drivers/acpi/apei/einj-cxl.c > index e70a416ec9256..93003fe4527e6 100644 > --- a/drivers/acpi/apei/einj-cxl.c > +++ b/drivers/acpi/apei/einj-cxl.c [ ... ] > +static void (*einj_cxl_ready_cb)(void); > + > +/** > + * einj_cxl_register_ready_cb - run a callback once EINJ is initialized > + * @cb: callback to invoke, or NULL to cancel a pending registration > + * > + * cxl_core cannot tell at init time whether EINJ will come up. If EINJ= is > + * already initialized, @cb runs immediately. > + */ > +void einj_cxl_register_ready_cb(void (*cb)(void)) > +{ > + if (cb && einj_cxl_is_initialized()) { > + cb(); > + return; > + } > + > + einj_cxl_ready_cb =3D cb; > +} > +EXPORT_SYMBOL_NS_GPL(einj_cxl_register_ready_cb, "CXL"); [Severity: Low] Should the kernel-doc for einj_cxl_register_ready_cb() document its single-registrant and serialization constraints? Because it is exported and updates an unlocked global pointer without checking whether one is already registered, a second caller would silently overwrite the existing callback, and callers rely on initcall and module dependency ordering to avoid racing with einj_cxl_notify_ready(). [ ... ] > diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c > index 625e4aa427db0..4f6137651ca4c 100644 > --- a/drivers/cxl/core/port.c > +++ b/drivers/cxl/core/port.c [ ... ] > +static int cxl_einj_debugfs_create_dport_dirs(struct device *dev, void *= data) > +{ > + struct cxl_dport *dport; > + struct cxl_port *port; > + unsigned long index; > + > + if (!is_cxl_port(dev)) > + return 0; > + > + port =3D to_cxl_port(dev); > + > + guard(device)(dev); > + xa_for_each(&port->dports, index, dport) > + cxl_debugfs_create_dport_dir(dport); > + > + return 0; > +} [Severity: Medium] Can iterating port->dports under only device_lock(&port->dev) race with root-port dport teardown and cause a use-after-free on struct cxl_dport? For a CXL root port, dport_to_host() hosts cxl_dport_remove() and free_dport() on port->uport_dev rather than &port->dev, and __devm_cxl_add_dport() drops &port->dev right after add_dport(). With driver_async_probe, cxl_acpi_probe() can run alongside einj_init(): CPU0 (cxl_acpi_probe) CPU1 (einj_init) device_lock(port->uport_dev) __devm_cxl_add_dport() cond_cxl_root_lock(port) add_dport(port, dport) cond_cxl_root_unlock(port) cxl_einj_debugfs_create_dport_dirs() guard(device)(&port->dev) xa_for_each(&port->dports, ..., dport) cxl_debugfs_create_dport_dir(dport) probe fails -> devres unwind cxl_dport_remove(dport) free_dport(dport) -> kfree() debugfs_create_file(..., dport, ...) <-- use-after-free This dereferences a freed dport and can leave einj_inject pointing to freed memory. Because __devm_cxl_add_dport() also creates the debugfs directory without &port->dev held, both threads can race past debugfs_lookup() and collide creating the same directory for a CXL 1.1 RCH dport. Acquiring guard(device)(port_to_host(port)) before guard(device)(dev), as find_or_add_dport() does, would serialize against root-port dport setup, debugfs creation, and devres teardown. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203065904.1554= 483-1-yangyongxin@kylinos.cn?part=3D1