Skip to contentSkip to conversation

fbdev: sstfb: Error out if pixclock equals zero

PATCH Superseded Xue Haolin 3 participants 4 messages Nov 17 – Nov 18

Subsystems (2)
lore
Share & tools
lore

Xue Haolin

author
#0 lore raw

PATCH 1/1 fbdev: sstfb: Error out if pixclock equals zero

From: xuehaolin <[email protected]>

The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of pixclock, it may cause divide-by-zero error.

sstfb_check_var() calls PICOS2KHZ(var->pixclock) which expands to 1000000000UL / var->pixclock. If var->pixclock is zero, this causes a divide-by-zero exception.

Fix this by checking whether pixclock is zero at the beginning of sstfb_check_var(), before it is used as a divisor.

This is similar to CVE-2022-3061 in i740fb which was fixed by commit 15cf0b82271b ("video: fbdev: i740fb: Error out if 'pixclock' equals zero"), and the fix in savagefb by
commit 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero").

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 drivers/video/fbdev/sstfb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/video/fbdev/sstfb.c +3 -0
index 8e2c2421028d..de0769eb4a2f 100644
@@ -359,6 +359,9 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
 	int tiles_in_X, real_length;
 	unsigned int freq;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
 		printk(KERN_ERR "sstfb: Pixclock at %ld KHZ out of range\n",
 				PICOS2KHZ(var->pixclock));
Signature · 1 line
2.43.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] fbdev: sstfb: single-word username in Signed-off-by trailer - [Low] fbdev: sstfb: unresolvable…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] fbdev: sstfb: single-word username in Signed-off-by trailer
- [Low] fbdev: sstfb: unresolvable commit SHA in Fixes trailer --

commit e66c7f16c1f32c41672200f2d9995e82c7ac0132
Author: xuehaolin <[email protected]>

Quoted 13 lines

fbdev: sstfb: Error out if pixclock equals zero

The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of pixclock, it may cause divide-by-zero error.

sstfb_check_var() calls PICOS2KHZ(var->pixclock) which expands to 1000000000UL / var->pixclock. If var->pixclock is zero, this causes a divide-by-zero exception.

Fix this by checking whether pixclock is zero at the beginning of sstfb_check_var(), before it is used as a divisor.

Quoted 6 lines

This is similar to CVE-2022-3061 in i740fb which was fixed by commit 15cf0b82271b ("video: fbdev: i740fb: Error out if 'pixclock' equals zero"), and the fix in savagefb by
commit 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero").

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

[Severity: Low]
Commit 1da177e4c3f4 ("Linux-2.6.12-rc2") cannot be resolved in the repository (or only exists in an unfetched historical tree).

Quoted 2 lines

[Severity: High]
The Author and Signed-off-by lines use a single-word username (xuehaolin) rather than a full legal human name, which does not meet the Developer's Certificate of Origin sign-off requirements in Documentation/process/submitting-patches.rst.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author
#2 lore raw

PATCH v2 1/1 fbdev: sstfb: Error out if pixclock equals zero

In reply to Xue Haolin

The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of pixclock, it may cause divide-by-zero error.

sstfb_check_var() calls PICOS2KHZ(var->pixclock) which expands to 1000000000UL / var->pixclock. If var->pixclock is zero, this causes a divide-by-zero exception.

Fix this by checking whether pixclock is zero at the beginning of sstfb_check_var(), before it is used as a divisor.

This is similar to CVE-2022-3061 in i740fb which was fixed by commit 15cf0b82271b ("video: fbdev: i740fb: Error out if 'pixclock' equals zero"), and the fix in savagefb by
commit 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero").

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")

---
Changes in v2:
- Fix sign-off to use real name "Xue Haolin" to satisfy DCO.

 drivers/video/fbdev/sstfb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/video/fbdev/sstfb.c +3 -0
index 8e2c2421028d..de0769eb4a2f 100644
@@ -359,6 +359,9 @@ static int sstfb_check_var(struct fb_var_screeninfo *var,
 	int tiles_in_X, real_length;
 	unsigned int freq;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
 		printk(KERN_ERR "sstfb: Pixclock at %ld KHZ out of range\n",
 				PICOS2KHZ(var->pixclock));
Signature · 1 line
2.43.0
maintainer Applied
#3 lore raw
Quoted 19 lines · Xue Haolin

The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of pixclock, it may cause divide-by-zero error.

sstfb_check_var() calls PICOS2KHZ(var->pixclock) which expands to 1000000000UL / var->pixclock. If var->pixclock is zero, this causes a divide-by-zero exception.

Fix this by checking whether pixclock is zero at the beginning of sstfb_check_var(), before it is used as a divisor.

This is similar to CVE-2022-3061 in i740fb which was fixed by commit 15cf0b82271b ("video: fbdev: i740fb: Error out if 'pixclock' equals zero"), and the fix in savagefb by
commit 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero").

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Quoted 6 lines

---
Changes in v2:
- Fix sign-off to use real name "Xue Haolin" to satisfy DCO.

  drivers/video/fbdev/sstfb.c | 3 +++
  1 file changed, 3 insertions(+)

applied.

Thanks!
Helge