From: Felix Kuehling <felix.kuehling@amd.com>
To: Philip Yang <Philip.Yang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2] drm/amdgpu: fix fdinfo race with process exit
Date: Tue, 3 Aug 2021 12:11:09 -0400 [thread overview]
Message-ID: <62ce2ca5-7ef5-e334-a7e3-d715336cd37d@amd.com> (raw)
In-Reply-To: <20210730021321.7953-1-Philip.Yang@amd.com>
Am 2021-07-29 um 10:13 p.m. schrieb Philip Yang:
> Get process vm root BO ref in case process is exiting and root BO is
> freed, to avoid NULL pointer dereference backtrace:
>
> BUG: unable to handle kernel NULL pointer dereference at
> 0000000000000000
> Call Trace:
> amdgpu_show_fdinfo+0xfe/0x2a0 [amdgpu]
> seq_show+0x12c/0x180
> seq_read+0x153/0x410
> vfs_read+0x91/0x140[ 3427.206183] ksys_read+0x4f/0xb0
> do_syscall_64+0x5b/0x1a0
> entry_SYSCALL_64_after_hwframe+0x65/0xca
>
> v2: rebase to staging
>
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
The patch is
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
> index d94c5419ec25..5a6857c44bb6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fdinfo.c
> @@ -59,6 +59,7 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f)
> uint64_t vram_mem = 0, gtt_mem = 0, cpu_mem = 0;
> struct drm_file *file = f->private_data;
> struct amdgpu_device *adev = drm_to_adev(file->minor->dev);
> + struct amdgpu_bo *root;
> int ret;
>
> ret = amdgpu_file_to_fpriv(f, &fpriv);
> @@ -69,13 +70,19 @@ void amdgpu_show_fdinfo(struct seq_file *m, struct file *f)
> dev = PCI_SLOT(adev->pdev->devfn);
> fn = PCI_FUNC(adev->pdev->devfn);
>
> - ret = amdgpu_bo_reserve(fpriv->vm.root.bo, false);
> + root = amdgpu_bo_ref(fpriv->vm.root.bo);
> + if (!root)
> + return;
> +
> + ret = amdgpu_bo_reserve(root, false);
> if (ret) {
> DRM_ERROR("Fail to reserve bo\n");
> return;
> }
> amdgpu_vm_get_memory(&fpriv->vm, &vram_mem, >t_mem, &cpu_mem);
> - amdgpu_bo_unreserve(fpriv->vm.root.bo);
> + amdgpu_bo_unreserve(root);
> + amdgpu_bo_unref(&root);
> +
> seq_printf(m, "pdev:\t%04x:%02x:%02x.%d\npasid:\t%u\n", domain, bus,
> dev, fn, fpriv->vm.pasid);
> seq_printf(m, "vram mem:\t%llu kB\n", vram_mem/1024UL);
prev parent reply other threads:[~2021-08-03 16:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-30 2:13 [PATCH v2] drm/amdgpu: fix fdinfo race with process exit Philip Yang
2021-08-03 14:06 ` philip yang
2021-08-04 9:04 ` Christian König
2021-08-04 15:01 ` philip yang
2021-08-03 16:11 ` Felix Kuehling [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=62ce2ca5-7ef5-e334-a7e3-d715336cd37d@amd.com \
--to=felix.kuehling@amd.com \
--cc=Philip.Yang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox