Skip to contentSkip to conversation

gpu/i915: fix error return in mmap_offset_attach()

PATCH In review Alexandr Sapozhnkiov 6 participants 7 messages Oct 2, 2025 – Oct 7, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu/i915: fix error return in mmap_offset_attach()

From: Alexandr Sapozhnikov <[email protected]>

In the drm_vma_node_allow function, kmalloc may return NULL, in which case the file element will not be added to the mmo->vma_node list. It would be good to not ignore this event, but at least log an error message.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +5 -2
index a2195e28b625..adaef8f09d59 100644
@@ -706,8 +706,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)
+			goto err;
+	}
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
#1 lore raw

✗ LGCI.VerificationFailed: failure for gpu/i915: fix error return in mmap_offset_attach() (rev2)

== Series Details ==

== Series Details ==

Series: gpu/i915: fix error return in mmap_offset_attach() (rev2)
URL : https://patchwork.freedesktop.org/series/154966/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!

maintainer
#2 lore raw
In reply to Alexandr Sapozhnkiov
Quoted 1 line · Alexandr Sapozhnkiov

From: Alexandr Sapozhnikov <[email protected]>

About the subject, this is not just a 5.10 kernel issue. This code is the current code in our tip.
So this needs to target drm-tip branch, and then Cc stable and perhaps a Fixes: tag.

Quoted 18 lines

In the drm_vma_node_allow function, kmalloc may return NULL, in which case the file element will not be added to the mmo->vma_node list. It would be good to not ignore this event, but at least log an error message.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
index a2195e28b625..adaef8f09d59 100644

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 711

Quoted 8 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +3 -2
@@ -706,8 +706,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)

perhaps we also need to drm_vma_offset_remove here?
I mean... honest question, doubt here. Is there any further clean-up needed?

Quoted 8 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +2 -0
+			goto err;
+	}
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
#3 lore raw
Quoted 21 lines · Rodrigo Vivi
Quoted 1 line · Alexandr Sapozhnkiov

From: Alexandr Sapozhnikov <[email protected]>

About the subject, this is not just a 5.10 kernel issue. This code is the current code in our tip.
So this needs to target drm-tip branch, and then Cc stable and perhaps a Fixes: tag.

Quoted 13 lines

In the drm_vma_node_allow function, kmalloc may return NULL, in which case the file element will not be added to the mmo->vma_node list. It would be good to not ignore this event, but at least log an error message.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 16 lines

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 711

Quoted 13 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +3 -2
index a2195e28b625..adaef8f09d59 100644
@@ -706,8 +706,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)

perhaps we also need to drm_vma_offset_remove here?
I mean... honest question, doubt here. Is there any further clean-up needed?

Yeah, mmo->vma_node has already been linked to varius places here. So this will lead to use-after-free in short order.

With the current code if this fails then I think all that ends up happening is that subsequent mmap() will fail. Maybe that's just fine?

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +2 -0
+			goto err;
+	}
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
Signature · 2 lines
Ville Syrjälä
Intel
#4 lore raw
Quoted 39 lines · Ville Syrjälä
Quoted 21 lines · Rodrigo Vivi
Quoted 1 line · Alexandr Sapozhnkiov

From: Alexandr Sapozhnikov <[email protected]>

About the subject, this is not just a 5.10 kernel issue. This code is the current code in our tip.
So this needs to target drm-tip branch, and then Cc stable and perhaps a Fixes: tag.

Quoted 13 lines

In the drm_vma_node_allow function, kmalloc may return NULL, in which case the file element will not be added to the mmo->vma_node list. It would be good to not ignore this event, but at least log an error message.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Quoted 16 lines

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 711

Quoted 13 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +3 -2
index a2195e28b625..adaef8f09d59 100644
@@ -706,8 +706,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)

perhaps we also need to drm_vma_offset_remove here?
I mean... honest question, doubt here. Is there any further clean-up needed?

Quoted 6 lines

Yeah, mmo->vma_node has already been linked to varius places here. So this will lead to use-after-free in short order.

With the current code if this fails then I think all that ends up happening is that subsequent mmap() will fail. Maybe that's just fine?

Hmm, or maybe it would be better to just directly return an error here without freeing/cleaning up anything. Looks to me like that should work fine as well, and userspace would get the error immediately instead of later.

Quoted 14 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +2 -0
+			goto err;
+	}
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
Signature · 2 lines
Ville Syrjälä
Intel
Signature · 2 lines
Ville Syrjälä
Intel
#5 lore raw
In reply to Alexandr Sapozhnkiov

Hi,

Quoted 19 lines · Alexandr Sapozhnkiov

From: Alexandr Sapozhnikov <[email protected]>

In the drm_vma_node_allow function, kmalloc may return NULL, in which case the file element will not be added to the mmo->vma_node list. It would be good to not ignore this event, but at least log an error message.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
index a2195e28b625..adaef8f09d59 100644

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 713

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +5 -2
@@ -706,8 +706,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)
+			goto err;
+	}

NACK here! You have received several reviews on this patch and didn't react to them. Please, read carefully the reviews you received and send a second version of the patch.

Please do use versioning properly in your title and add a changelog.

Before sending patches, please read the documentation[*].

Andi

[*] https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html

Quoted 6 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
#6 lore raw
Quoted 37 lines

Hi,

Quoted 19 lines · Alexandr Sapozhnkiov

From: Alexandr Sapozhnikov <[email protected]>

In the drm_vma_node_allow function, kmalloc may return NULL, in which case the file element will not be added to the mmo->vma_node list. It would be good to not ignore this event, but at least log an error message.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
index a2195e28b625..adaef8f09d59 100644

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 713

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +5 -2
@@ -706,8 +706,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)
+			goto err;
+	}

NACK here! You have received several reviews on this patch and didn't react to them. Please, read carefully the reviews you received and send a second version of the patch.

Quoted 8 lines

Please do use versioning properly in your title and add a changelog.

Before sending patches, please read the documentation[*].

Andi

[*] https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html

Maybe read the latest version.
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

Kind regards,
Petr

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
 	return mmo;
 
 err:
Signature · 1 line
2.43.0