From: Helge Deller <deller@gmx.de>
To: Osama Abdelkader <osama.abdelkader@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Thomas Zimmermann <tzimmermann@suse.de>,
Lee Jones <lee@kernel.org>,
"Daniel Thompson (RISCstar)" <danielt@kernel.org>,
Murad Masimov <m.masimov@mt-integration.ru>,
Quanmin Yan <yanquanmin1@huawei.com>,
Yongzhen Zhang <zhangyongzhen@kylinos.cn>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Cc: syzbot+55e03490a0175b8dd81d@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] fbdev: avoid out-of-bounds read in fb_pad_unaligned_buffer()
Date: Tue, 27 Jan 2026 18:57:32 +0100 [thread overview]
Message-ID: <889fd11b-80ea-4c23-b47f-4e6b17536b0f@gmx.de> (raw)
In-Reply-To: <20260124164633.20444-1-osama.abdelkader@gmail.com>
On 1/24/26 17:46, Osama Abdelkader wrote:
> fb_pad_unaligned_buffer() unconditionally reads and advances the source
> pointer for the final byte of each row, even when no bits from that byte
> are actually consumed.
>
> When shift_high >= mod, the remaining bits do not cross a byte boundary,
> but the code still accesses the next source byte. This can lead to
> out-of-bounds reads under malformed geometry, as reported by syzbot.
>
> Fix this by only accessing and consuming the final source byte when it
> contributes bits (shift_high < mod).
>
> This fixes the KASAN slab-out-of-bounds read reported by syzkaller:
> https://syzkaller.appspot.com/bug?extid=55e03490a0175b8dd81d
>
> Reported-by: syzbot+55e03490a0175b8dd81d@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=55e03490a0175b8dd81d
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> ---
> v2: address the real issue (shift_high >= mod) condition.
> ---
> drivers/video/fbdev/core/fbmem.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
> index eff757ebbed1..d125c3db37a1 100644
> --- a/drivers/video/fbdev/core/fbmem.c
> +++ b/drivers/video/fbdev/core/fbmem.c
> @@ -100,7 +100,7 @@ EXPORT_SYMBOL(fb_pad_aligned_buffer);
> void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 height,
> u32 shift_high, u32 shift_low, u32 mod)
> {
> - u8 mask = (u8) (0xfff << shift_high), tmp;
> + u8 mask = (u8) (0xff << shift_high), tmp;
This part is correct, but shouldn't be part of this patch.
> int i, j;
>
> for (i = height; i--; ) {
> @@ -113,15 +113,18 @@ void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx, u32 height,
> dst[j+1] = tmp;
> src++;
> }
> - tmp = dst[idx];
> - tmp &= mask;
> - tmp |= *src >> shift_low;
> - dst[idx] = tmp;
> +
> + /* Only consume another source byte if it contributes bits */
> if (shift_high < mod) {
> + tmp = dst[idx];
> + tmp &= mask;
> + tmp |= *src >> shift_low;
> + dst[idx] = tmp;
> tmp = *src << shift_high;
> dst[idx+1] = tmp;
> + src++;
> }
> - src++;
Above you moved the src pointer inside the if(), so every line
processed may miss a ptr increment. This means the source would need to
be different too, but it hasn't changed, as it's still used from
bit_putcs_unaligned() which prints a char from the character fonts.
So, I believe this part at least is wrong.
Did you test it?
Helge
next prev parent reply other threads:[~2026-01-27 17:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-24 16:46 [PATCH v2] fbdev: avoid out-of-bounds read in fb_pad_unaligned_buffer() Osama Abdelkader
2026-01-27 17:57 ` Helge Deller [this message]
2026-01-27 19:40 ` 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=889fd11b-80ea-4c23-b47f-4e6b17536b0f@gmx.de \
--to=deller@gmx.de \
--cc=danielt@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lee@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.masimov@mt-integration.ru \
--cc=osama.abdelkader@gmail.com \
--cc=simona@ffwll.ch \
--cc=syzbot+55e03490a0175b8dd81d@syzkaller.appspotmail.com \
--cc=tzimmermann@suse.de \
--cc=yanquanmin1@huawei.com \
--cc=zhangyongzhen@kylinos.cn \
/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