Dan Carpenter
2023-Sep-15 12:59 UTC
[Nouveau] [PATCH] nouveau/u_memcpya: fix NULL vs error pointer bug
The u_memcpya() function is supposed to return error pointers on error. Returning NULL will lead to an Oops. Fixes: 68132cc6d1bc ("nouveau/u_memcpya: use vmemdup_user") Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org> --- drivers/gpu/drm/nouveau/nouveau_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 3666a7403e47..52a708a98915 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h @@ -193,7 +193,7 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) size_t bytes; if (unlikely(check_mul_overflow(nmemb, size, &bytes))) - return NULL; + return ERR_PTR(-ENOMEM); return vmemdup_user(userptr, bytes); } -- 2.39.2
Danilo Krummrich
2023-Sep-15 23:41 UTC
[Nouveau] [PATCH] nouveau/u_memcpya: fix NULL vs error pointer bug
Hi Dan, On 9/15/23 14:59, Dan Carpenter wrote:> The u_memcpya() function is supposed to return error pointers on > error. Returning NULL will lead to an Oops. > > Fixes: 68132cc6d1bc ("nouveau/u_memcpya: use vmemdup_user") > Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org> > --- > drivers/gpu/drm/nouveau/nouveau_drv.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h > index 3666a7403e47..52a708a98915 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_drv.h > +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h > @@ -193,7 +193,7 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) > size_t bytes; > > if (unlikely(check_mul_overflow(nmemb, size, &bytes))) > - return NULL; > + return ERR_PTR(-ENOMEM);I plan to replace this function with an upcoming vmemdup_array_user() helper, which returns -EOVERFLOW instead, hence mind using that? Unless you disagree, no need to resubmit the patch, I can change it before applying the patch. - Danilo> return vmemdup_user(userptr, bytes); > } >
Lyude Paul
2023-Sep-18 22:24 UTC
[Nouveau] [PATCH] nouveau/u_memcpya: fix NULL vs error pointer bug
Reviewed-by: Lyude Paul <lyude at redhat.com> I assume you need me to push this to drm-misc? On Fri, 2023-09-15 at 15:59 +0300, Dan Carpenter wrote:> The u_memcpya() function is supposed to return error pointers on > error. Returning NULL will lead to an Oops. > > Fixes: 68132cc6d1bc ("nouveau/u_memcpya: use vmemdup_user") > Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org> > --- > drivers/gpu/drm/nouveau/nouveau_drv.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h > index 3666a7403e47..52a708a98915 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_drv.h > +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h > @@ -193,7 +193,7 @@ u_memcpya(uint64_t user, unsigned int nmemb, unsigned int size) > size_t bytes; > > if (unlikely(check_mul_overflow(nmemb, size, &bytes))) > - return NULL; > + return ERR_PTR(-ENOMEM); > return vmemdup_user(userptr, bytes); > } >-- Cheers, Lyude Paul (she/her) Software Engineer at Red Hat