[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260123031133.3059291-2-kuba@kernel.org>
Date: Thu, 22 Jan 2026 19:11:34 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: itazur@...zon.com
Cc: Jakub Kicinski <kuba@...nel.org>,
graf@...zon.de,
itazur@...zon.co.uk,
conor+dt@...nel.org,
dwmw2@...radead.org,
devicetree@...r.kernel.org,
xmarcalx@...zon.co.uk,
linux-kernel@...r.kernel.org,
edumazet@...gle.com,
robh@...nel.org,
richardcochran@...il.com,
andrew+netdev@...n.ch,
mzxreary@...inter.de,
pabeni@...hat.com,
dwmw@...zon.co.uk,
netdev@...r.kernel.org,
krzk+dt@...nel.org,
davem@...emloft.net,
mail@...alios.io
Subject: Re: [v6,2/7] ptp: vmclock: support device notifications
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ptp: vmclock: support device notifications
This patch adds optional device notification support to VMClock, allowing
the hypervisor to notify the driver when seq_count changes. It also adds
poll() support to propagate these notifications to userspace.
> diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c
> index b3a83b03d9c1..38b2bacb755e 100644
> --- a/drivers/ptp/ptp_vmclock.c
> +++ b/drivers/ptp/ptp_vmclock.c
[ ... ]
> +static void
> +vmclock_acpi_notification_handler(acpi_handle __always_unused handle,
> + u32 __always_unused event, void *dev)
> +{
> + struct device *device = dev;
> + struct vmclock_state *st = device->driver_data;
> +
> + wake_up_interruptible(&st->disrupt_wait);
> +}
> +
> +static int vmclock_setup_notification(struct device *dev, struct vmclock_state *st)
> +{
[ ... ]
> + status = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY,
> + vmclock_acpi_notification_handler,
> + dev);
Since acpi_install_notify_handler() is called here, should there be a
corresponding acpi_remove_notify_handler() in vmclock_remove()? Currently
the handler remains registered after device removal, which could lead to
a use-after-free if the hypervisor sends a notification after the driver
state has been freed.
[ ... ]
> @@ -549,6 +653,11 @@ static int vmclock_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + init_waitqueue_head(&st->disrupt_wait);
> + ret = vmclock_setup_notification(dev, st);
> + if (ret)
> + return ret;
[ ... ]
> @@ -581,6 +690,8 @@ static int vmclock_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> + dev->driver_data = st;
Is there a race window here? The ACPI notification handler is installed
in vmclock_setup_notification() which runs earlier in vmclock_probe(),
but the handler accesses device->driver_data. If the hypervisor sends a
notification between vmclock_setup_notification() and this assignment,
vmclock_acpi_notification_handler() would dereference NULL or garbage.
I see this is fixed later in the series by commit 47fdd294385e which
moves dev->driver_data = st before vmclock_setup_notification().
--
pw-bot: cr
Powered by blists - more mailing lists