linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fbdev: nvidia: Fix potential divide by zero
@ 2023-03-15  7:18 Wei Chen
  2023-03-16 13:34 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Chen @ 2023-03-15  7:18 UTC (permalink / raw)
  To: adaplas; +Cc: deller, linux-fbdev, dri-devel, linux-kernel, Wei Chen

variable var->pixclock can be set by user. In case it
equals to zero, divide by zero would occur in nvidiafb_set_par.

Similar crashes have happened in other fbdev drivers. There
is no check and modification on var->pixclock along the call
chain to nvidia_check_var and nvidiafb_set_par. We believe it
could also be triggered in driver nvidia from user site.

Signed-off-by: Wei Chen <harperchen1110@gmail.com>
---
 drivers/video/fbdev/nvidia/nvidia.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
index e60a276b4855..ea4ba3dfb96b 100644
--- a/drivers/video/fbdev/nvidia/nvidia.c
+++ b/drivers/video/fbdev/nvidia/nvidia.c
@@ -764,6 +764,8 @@ static int nvidiafb_check_var(struct fb_var_screeninfo *var,
 	int pitch, err = 0;
 
 	NVTRACE_ENTER();
+	if (!var->pixclock)
+		return -EINVAL;
 
 	var->transp.offset = 0;
 	var->transp.length = 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fbdev: nvidia: Fix potential divide by zero
  2023-03-15  7:18 [PATCH] fbdev: nvidia: Fix potential divide by zero Wei Chen
@ 2023-03-16 13:34 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2023-03-16 13:34 UTC (permalink / raw)
  To: Wei Chen, adaplas; +Cc: linux-fbdev, dri-devel, linux-kernel

On 3/15/23 08:18, Wei Chen wrote:
> variable var->pixclock can be set by user. In case it
> equals to zero, divide by zero would occur in nvidiafb_set_par.
>
> Similar crashes have happened in other fbdev drivers. There
> is no check and modification on var->pixclock along the call
> chain to nvidia_check_var and nvidiafb_set_par. We believe it
> could also be triggered in driver nvidia from user site.
>
> Signed-off-by: Wei Chen <harperchen1110@gmail.com>

applied all four patches.

Thanks!
Helge

> ---
>   drivers/video/fbdev/nvidia/nvidia.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c
> index e60a276b4855..ea4ba3dfb96b 100644
> --- a/drivers/video/fbdev/nvidia/nvidia.c
> +++ b/drivers/video/fbdev/nvidia/nvidia.c
> @@ -764,6 +764,8 @@ static int nvidiafb_check_var(struct fb_var_screeninfo *var,
>   	int pitch, err = 0;
>
>   	NVTRACE_ENTER();
> +	if (!var->pixclock)
> +		return -EINVAL;
>
>   	var->transp.offset = 0;
>   	var->transp.length = 0;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-16 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  7:18 [PATCH] fbdev: nvidia: Fix potential divide by zero Wei Chen
2023-03-16 13:34 ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).