drm/nouveau: fix another off-by-one in nvbios_addr
Subsystems (3)
PATCH 1/1 drm/nouveau: fix another off-by-one in nvbios_addr
This check determines whether a given address is part of image 0 or image 1. Image 1 starts at offset image0_size, so that address should be included.
Fixes 4d4e9907ff572 ("drm/nouveau/bios: guard against out-of-bounds accesses to image")
Signed-off-by Timur Tabi <[email protected]>
--- drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c +1 -1
@@ -33,7 +33,7 @@ nvbios_addr(struct nvkm_bios *bios, u32 *addr, u8 size) {u32 p = *addr; -if (*addr > bios->image0_size && bios->imaged_addr) { +if (*addr >= bios->image0_size && bios->imaged_addr) { *addr -= bios->image0_size; *addr += bios->imaged_addr; }
Signature · 1 line
2.36.0
Quoted 25 lines · Timur Tabi
This check determines whether a given address is part of image 0 or image 1. Image 1 starts at offset
image0_size, so that address should be included.Fixes 4d4e9907ff572 ("drm/nouveau/bios: guard against out-of-bounds accesses to image")Signed-off-by Timur Tabi <[email protected]>--- drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c +1
-2@@ -33,7 +33,7 @@ nvbios_addr(struct nvkm_bios *bios, u32 *addr, u8 size) {u32 p = *addr; -if (*addr > bios->image0_size && bios->imaged_addr) { +if (*addr >= bios->image0_size && bios->imaged_addr) { *addr -= bios->image0_size; *addr += bios->imaged_addr; } --
Quoted 2 lines
2.36.0
Reviewed-by Karol Herbst <[email protected]>
I don't like how this could fail for values spanning both images, but at least this looks more correct.
I think in the future we should keep a copy without that gap on the host side to make access to the vbios image cheaper. What do you say Ben?