dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: korantwork@gmail.com
To: bskeggs@redhat.com, kherbst@redhat.com, airlied@gmail.com,
	daniel@ffwll.ch
Cc: nouveau@lists.freedesktop.org, loydlv <loydlv@tencent.com>,
	Xinghui Li <korantli@tencent.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH] drm/nouveau/mmu: Fix an UAF issue in NVKM
Date: Thu, 12 Jan 2023 15:18:42 +0800	[thread overview]
Message-ID: <20230112071842.819123-1-korantwork@gmail.com> (raw)

From: Xinghui Li <korantli@tencent.com>

In nvkm_mem_new_host, the mem is be alloced. And mem->memory is
assigned to pmemory. During this process, the mem will be free if
the error occurs. But the *pmemory still points to the &mem->memory
which has been relased.Laterly, the nvkm_memory_unref will put the
memory which points to the pmemory again.So, we set the *pmemory to
NULL to avoid UAF issue.

Reported-by: loydlv <loydlv@tencent.com>
Signed-off-by: Xinghui Li <korantli@tencent.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
index 92e363dbbc5a..ab30eb1fc0a3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
@@ -185,6 +185,7 @@ nvkm_mem_new_host(struct nvkm_mmu *mmu, int type, u8 page, u64 size,
 	} else
 	if ( (ret = nvif_unvers(ret, &argv, &argc, args->vn))) {
 		kfree(mem);
+		*pmemory = NULL;
 		return ret;
 	}
 
-- 
2.31.1


             reply	other threads:[~2023-01-12  8:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12  7:18 korantwork [this message]
2023-02-03  9:49 ` [PATCH] drm/nouveau/mmu: Fix an UAF issue in NVKM Xinghui Li

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=20230112071842.819123-1-korantwork@gmail.com \
    --to=korantwork@gmail.com \
    --cc=airlied@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kherbst@redhat.com \
    --cc=korantli@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loydlv@tencent.com \
    --cc=nouveau@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