Skip to content

Commit fddcd00

Browse files
committed
drm/i915: Force the slow path after a user-write error
If we fail to write the user relocation back when it is changed, force ourselves to take the slow relocation path where we can handle faults in the write path. There is still an element of dubiousness as having patched up the batch to use the correct offset, it no longer matches the presumed_offset in the relocation, so a second pass may miss any changes in layout. Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Joonas Lahtinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent aae7c06 commit fddcd00

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/gpu/drm/i915/i915_gem_execbuffer.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,8 +1491,10 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
14911491
* can read from this userspace address.
14921492
*/
14931493
offset = gen8_canonical_addr(offset & ~UPDATE);
1494-
__put_user(offset,
1495-
&urelocs[r-stack].presumed_offset);
1494+
if (unlikely(__put_user(offset, &urelocs[r-stack].presumed_offset))) {
1495+
remain = -EFAULT;
1496+
goto out;
1497+
}
14961498
}
14971499
} while (r++, --count);
14981500
urelocs += ARRAY_SIZE(stack);
@@ -1577,7 +1579,6 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb)
15771579

15781580
relocs = kvmalloc_array(size, 1, GFP_KERNEL);
15791581
if (!relocs) {
1580-
kvfree(relocs);
15811582
err = -ENOMEM;
15821583
goto err;
15831584
}
@@ -1591,6 +1592,7 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb)
15911592
if (__copy_from_user((char *)relocs + copied,
15921593
(char __user *)urelocs + copied,
15931594
len)) {
1595+
end_user:
15941596
kvfree(relocs);
15951597
err = -EFAULT;
15961598
goto err;
@@ -1614,7 +1616,6 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb)
16141616
unsafe_put_user(-1,
16151617
&urelocs[copied].presumed_offset,
16161618
end_user);
1617-
end_user:
16181619
user_access_end();
16191620

16201621
eb->exec[i].relocs_ptr = (uintptr_t)relocs;

0 commit comments

Comments
 (0)