Skip to content

Commit fa297e9

Browse files
committed
drm/nouveau: fix u32 overflow in pushbuf reloc bounds check
commit 2fc87d3 upstream. nouveau_gem_pushbuf_reloc_apply() validates each relocation with if (r->reloc_bo_offset + 4 > nvbo->bo.base.size) but reloc_bo_offset is __u32 (uapi/drm/nouveau_drm.h) and the integer literal 4 promotes to unsigned int, so the addition is performed in 32 bits and wraps before the comparison against the size_t bo size. Cast to u64 so the addition happens in 64-bit arithmetic. Cc: Lyude Paul <lyude@redhat.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: David Airlie <airlied@gmail.com> Cc: Simona Vetter <simona@ffwll.ch> Reported-by: Anthropic Cc: stable <stable@kernel.org> Assisted-by: gkh_clanker_t1000 Fixes: a1606a9 ("drm/nouveau: new gem pushbuf interface, bump to 0.0.16") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [ Add Fixes: tag. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8775fa6 commit fa297e9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
679679
}
680680
nvbo = (void *)(unsigned long)bo[r->reloc_bo_index].user_priv;
681681

682-
if (unlikely(r->reloc_bo_offset + 4 >
682+
if (unlikely((u64)r->reloc_bo_offset + 4 >
683683
nvbo->bo.base.size)) {
684684
NV_PRINTK(err, cli, "reloc outside of bo\n");
685685
ret = -EINVAL;

0 commit comments

Comments
 (0)