linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] fbcon: Avoid showing softcursor if font not available
Date: Sat, 27 May 2023 19:26:52 +0200	[thread overview]
Message-ID: <ffe2dc05-b099-107b-adf0-593f2df12bea@gmx.de> (raw)
In-Reply-To: <20230527101807.GA1101718@ravnborg.org>

On 5/27/23 12:18, Sam Ravnborg wrote:
> Hi Helge,
>
> On Sat, May 27, 2023 at 11:19:02AM +0200, Helge Deller wrote:
>> syzbot repored this bug in the softcursor code:
>>
>> BUG: KASAN: null-ptr-deref in soft_cursor+0x384/0x6b4 drivers/video/fbdev/core/softcursor.c:70
>> Read of size 16 at addr 0000000000000200 by task kworker/u4:1/12
>>
>> CPU: 0 PID: 12 Comm: kworker/u4:1 Not tainted 6.4.0-rc3-syzkaller-geb0f1697d729 #0
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
>> Workqueue: events_power_efficient fb_flashcursor
>> Call trace:
>>   dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:233
>>   show_stack+0x2c/0x44 arch/arm64/kernel/stacktrace.c:240
>>   __dump_stack lib/dump_stack.c:88 [inline]
>>   dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106
>>   print_report+0xe4/0x514 mm/kasan/report.c:465
>>   kasan_report+0xd4/0x130 mm/kasan/report.c:572
>>   kasan_check_range+0x264/0x2a4 mm/kasan/generic.c:187
>>   __asan_memcpy+0x3c/0x84 mm/kasan/shadow.c:105
>>   soft_cursor+0x384/0x6b4 drivers/video/fbdev/core/softcursor.c:70
>>   bit_cursor+0x113c/0x1a64 drivers/video/fbdev/core/bitblit.c:377
>>   fb_flashcursor+0x35c/0x54c drivers/video/fbdev/core/fbcon.c:380
>>   process_one_work+0x788/0x12d4 kernel/workqueue.c:2405
>>   worker_thread+0x8e0/0xfe8 kernel/workqueue.c:2552
>>   kthread+0x288/0x310 kernel/kthread.c:379
>>   ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:853
>>
>> This fix let bit_cursor() bail out early when a font bitmap
>> isn't available yet.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>> Cc: stable@kernel.org
>> Reported-by: syzbot+d910bd780e6efac35869@syzkaller.appspotmail.com
>> ---
>>   drivers/video/fbdev/core/bitblit.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c
>> index f98e8f298bc1..8587c9da0670 100644
>> --- a/drivers/video/fbdev/core/bitblit.c
>> +++ b/drivers/video/fbdev/core/bitblit.c
>> @@ -247,6 +247,9 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
>>
>>   	cursor.set = 0;
>>
>> +	if (!vc->vc_font.data)
>> +		return;
>> +
>>    	c = scr_readw((u16 *) vc->vc_pos);
>>   	attribute = get_attribute(info, c);
>>   	src = vc->vc_font.data + ((c & charmask) * (w * vc->vc_font.height));
>
> When browsing the code I noticed another use of vc->vc_font.data.
>
> bit_putcs_{un}aligned() access vc->vc_font.data too, so I wonder if
> bit_putcs() should also check for vc->vc_font.data?
> bit_putcs() is the only user of bit_putcs_{un}aligned.

I think the font is set before any char is printed, so we should
probably be safe there.

> The actual patch here looks good from a quick browsing around, but I
> cannot claim I did a review. But you have my:
> Acked-by: Sam Ravnborg <sam@ravnborg.org>

Thank you!
Helge

      reply	other threads:[~2023-05-27 17:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-27  9:19 [PATCH] fbcon: Avoid showing softcursor if font not available Helge Deller
2023-05-27 10:18 ` Sam Ravnborg
2023-05-27 17:26   ` Helge Deller [this message]

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=ffe2dc05-b099-107b-adf0-593f2df12bea@gmx.de \
    --to=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=sam@ravnborg.org \
    /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;
as well as URLs for NNTP newsgroup(s).