Test divide err in drm

Message ID tencent_9E786E6C4C2DF96F4097BCEA5AED66CEBC0A@qq.com
State New
Headers
Series Test divide err in drm |

Commit Message

Edward Adam Davis Feb. 12, 2024, 12:07 p.m. UTC
  please test divide err in drm

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
  

Comments

syzbot Feb. 12, 2024, 12:30 p.m. UTC | #1
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+0d7a3627fb6a42cf0863@syzkaller.appspotmail.com

Tested on:

commit:         ae00c445 Add linux-next specific files for 20240212
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=154105ec180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=4eb3a27eddb32a14
dashboard link: https://syzkaller.appspot.com/bug?extid=0d7a3627fb6a42cf0863
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=160d0724180000

Note: testing is done by a robot and is best-effort only.
  

Patch

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index ac9a406250c5..60739d861da2 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -36,6 +36,7 @@ 
 #include <linux/list.h>
 #include <linux/list_sort.h>
 #include <linux/of.h>
+#include <linux/overflow.h>
 
 #include <video/of_display_timing.h>
 #include <video/of_videomode.h>
@@ -1297,8 +1298,10 @@  int drm_mode_vrefresh(const struct drm_display_mode *mode)
 		num *= 2;
 	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
 		den *= 2;
-	if (mode->vscan > 1)
-		den *= mode->vscan;
+	if (mode->vscan > 1) {
+		if (unlikely(check_mul_overflow(den, mode->vscan, &den)))
+			return 0;
+	}
 
 	return DIV_ROUND_CLOSEST_ULL(mul_u32_u32(num, 1000), den);
 }