diff mbox

drm/etnaviv: Fix off-by-one error in reloc checking

Message ID 1500986016-10540-1-git-send-email-laanwj@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wladimir J. van der Laan July 25, 2017, 12:33 p.m. UTC
A relocation pointing to the last four bytes of a buffer can
legitimately happen in the case of small vertex buffers.

Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Philipp Zabel July 25, 2017, 3:49 p.m. UTC | #1
On Tue, 2017-07-25 at 14:33 +0200, Wladimir J. van der Laan wrote:
> A relocation pointing to the last four bytes of a buffer can
> legitimately happen in the case of small vertex buffers.
> 
> Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>
> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index de80ee1..21be4dc 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -270,8 +270,8 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
>  		if (ret)
>  			return ret;
>  
> -		if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) {
> -			DRM_ERROR("relocation %u outside object", i);
> +		if (r->reloc_offset > bo->obj->base.size - sizeof(*ptr)) {
> +			DRM_ERROR("relocation %u outside object\n", i);
>  			return -EINVAL;
>  		}
>  

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp
Christian Gmeiner Aug. 4, 2017, 12:51 p.m. UTC | #2
2017-07-25 14:33 GMT+02:00 Wladimir J. van der Laan <laanwj@gmail.com>:
> A relocation pointing to the last four bytes of a buffer can
> legitimately happen in the case of small vertex buffers.
>
> Signed-off-by: Wladimir J. van der Laan <laanwj@gmail.com>

Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index de80ee1..21be4dc 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -270,8 +270,8 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
>                 if (ret)
>                         return ret;
>
> -               if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) {
> -                       DRM_ERROR("relocation %u outside object", i);
> +               if (r->reloc_offset > bo->obj->base.size - sizeof(*ptr)) {
> +                       DRM_ERROR("relocation %u outside object\n", i);
>                         return -EINVAL;
>                 }
>
> --
> 2.7.4
>

greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info
diff mbox

Patch

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index de80ee1..21be4dc 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -270,8 +270,8 @@  static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
 		if (ret)
 			return ret;
 
-		if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) {
-			DRM_ERROR("relocation %u outside object", i);
+		if (r->reloc_offset > bo->obj->base.size - sizeof(*ptr)) {
+			DRM_ERROR("relocation %u outside object\n", i);
 			return -EINVAL;
 		}