From: Osama Abdelkader <osama.abdelkader@gmail.com>
To: Zsolt Kajtar <soci@c64.rulez.org>,
Simona Vetter <simona@ffwll.ch>, Helge Deller <deller@gmx.de>,
Osama Abdelkader <osama.abdelkader@gmail.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Cc: syzbot+7a63ce155648954e749b@syzkaller.appspotmail.com
Subject: [PATCH] fbdev: sys_fillrect: Add bounds checking to prevent vmalloc-out-of-bounds
Date: Sun, 18 Jan 2026 01:18:48 +0100 [thread overview]
Message-ID: <20260118001852.70173-1-osama.abdelkader@gmail.com> (raw)
The sys_fillrect function was missing bounds validation, which could lead
to vmalloc-out-of-bounds writes when the rectangle coordinates extend
beyond the framebuffer's virtual resolution. This was detected by KASAN
and reported by syzkaller.
Add validation to:
1. Check that width and height are non-zero
2. Verify that dx and dy are within virtual resolution bounds
3. Clip the rectangle dimensions to fit within virtual resolution if needed
This follows the same pattern used in other framebuffer drivers like
pm2fb_fillrect.
Reported-by: syzbot+7a63ce155648954e749b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7a63ce155648954e749b
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
drivers/video/fbdev/core/sysfillrect.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/core/sysfillrect.c b/drivers/video/fbdev/core/sysfillrect.c
index 12eea3e424bb..73fc322ff8fd 100644
--- a/drivers/video/fbdev/core/sysfillrect.c
+++ b/drivers/video/fbdev/core/sysfillrect.c
@@ -7,6 +7,7 @@
#include <linux/module.h>
#include <linux/fb.h>
#include <linux/bitrev.h>
+#include <linux/string.h>
#include <asm/types.h>
#ifdef CONFIG_FB_SYS_REV_PIXELS_IN_BYTE
@@ -18,10 +19,28 @@
void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
{
+ struct fb_fillrect modded;
+ int vxres, vyres;
+
if (!(p->flags & FBINFO_VIRTFB))
fb_warn_once(p, "%s: framebuffer is not in virtual address space.\n", __func__);
- fb_fillrect(p, rect);
+ vxres = p->var.xres_virtual;
+ vyres = p->var.yres_virtual;
+
+ /* Validate and clip rectangle to virtual resolution */
+ if (!rect->width || !rect->height ||
+ rect->dx >= vxres || rect->dy >= vyres)
+ return;
+
+ memcpy(&modded, rect, sizeof(struct fb_fillrect));
+
+ if (modded.dx + modded.width > vxres)
+ modded.width = vxres - modded.dx;
+ if (modded.dy + modded.height > vyres)
+ modded.height = vyres - modded.dy;
+
+ fb_fillrect(p, &modded);
}
EXPORT_SYMBOL(sys_fillrect);
--
2.43.0
next reply other threads:[~2026-01-18 0:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-18 0:18 Osama Abdelkader [this message]
2026-01-19 7:38 ` [PATCH] fbdev: sys_fillrect: Add bounds checking to prevent vmalloc-out-of-bounds Thomas Zimmermann
2026-01-24 16:53 ` Osama Abdelkader
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260118001852.70173-1-osama.abdelkader@gmail.com \
--to=osama.abdelkader@gmail.com \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=soci@c64.rulez.org \
--cc=syzbot+7a63ce155648954e749b@syzkaller.appspotmail.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox