Message ID | 20230315071831.3833948-1-harperchen1110@gmail.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | fbdev: nvidia: Fix potential divide by zero | expand |
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;
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;
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(+)