All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sang-Heon Jeon" <ekffu200098@gmail.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: fix wrong unit of vf2pf_work delay
Date: Tue, 24 Nov 2026 08:44:21 +0000	[thread overview]
Message-ID: <sashiko-outbox-230735@kernel.org> (raw)
In-Reply-To: <20261123175513.2144018-1-ekffu200098@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/amdgpu: uncanceled vf2pf_work in
  amdgpu_virt_fini_data_exchange() [1]
--

commit a187e6fa4054f858fa9ab261be0ca76b1509f22d
Author: Sang-Heon Jeon <ekffu200098@gmail.com>

drm/amdgpu: fix wrong unit of vf2pf_work delay

This commit converts adev->virt.vf2pf_update_interval_ms to jiffies via
msecs_to_jiffies() when rescheduling adev->virt.vf2pf_work in
amdgpu_virt_update_vf2pf_work_item().

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index 915e2a069bafb..f93d5df51528c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -797,7 +797,8 @@ static void amdgpu_virt_update_vf2pf_work_item(struct work_struct *work)
>  	amdgpu_virt_write_vf2pf_data(adev);
>  
>  out:
> -	schedule_delayed_work(&(adev->virt.vf2pf_work), adev->virt.vf2pf_update_interval_ms);
> +	schedule_delayed_work(&(adev->virt.vf2pf_work),
> +			      msecs_to_jiffies(adev->virt.vf2pf_update_interval_ms));
>  }
>  
>  static int amdgpu_virt_read_exchange_data_from_mem(struct amdgpu_device *adev, uint32_t *pfvf_data)

[Severity: Critical]
This problem wasn't introduced by this patch, but can [1] leave
adev->virt.vf2pf_work running after amdgpu_virt_fini_data_exchange() if
amdgpu_virt_read_pf2vf_data() fails?

amdgpu_virt_init_data_exchange() resets adev->virt.vf2pf_update_interval_ms
to 0, calls amdgpu_virt_exchange_data() -> amdgpu_virt_read_pf2vf_data()
without checking its return value, and schedules adev->virt.vf2pf_work:

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c:amdgpu_virt_fini_data_exchange() {
	if (adev->virt.vf2pf_update_interval_ms != 0) {
		dev_info(adev->dev, "clean up the vf2pf work item\n");
		cancel_delayed_work_sync(&adev->virt.vf2pf_work);
		adev->virt.vf2pf_update_interval_ms = 0;
	}
}

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c:amdgpu_virt_init_data_exchange() {
    ...
	adev->virt.vf2pf_update_interval_ms = 0;
    ...
	} else if (fw_va || drv_va) {
		/* go through this logic in ip_init and reset to init workqueue*/
		amdgpu_virt_exchange_data(adev);

		schedule_delayed_work(&(adev->virt.vf2pf_work), msecs_to_jiffies(adev->virt.vf2pf_update_interval_ms));
    ...
}

When PF2VF header validation fails in amdgpu_virt_read_pf2vf_data(),
vf2pf_update_interval_ms stays 0 while vf2pf_work is scheduled and
rescheduled here with a zero delay.  Because
amdgpu_virt_fini_data_exchange() only cancels vf2pf_work when
vf2pf_update_interval_ms is non-zero, teardown leaves the delayed work
running in a tight zero-delay loop, leading to accesses to unmapped VRAM and
a use-after-free on struct amdgpu_device.

[1] https://sashiko.dev/#/bug/linux-904ad1aa-33f1-44b8-a83c-632c07b49537

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123175513.2144018-1-ekffu200098@gmail.com?part=1

      reply	other threads:[~2026-11-24  8:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 17:55 [PATCH] drm/amdgpu: fix wrong unit of vf2pf_work delay Sang-Heon Jeon
2026-11-24  8:44 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-230735@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ekffu200098@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.