* [PATCH] fbcon: Avoid showing softcursor if font not available
@ 2023-05-27 9:19 Helge Deller
2023-05-27 10:18 ` Sam Ravnborg
0 siblings, 1 reply; 3+ messages in thread
From: Helge Deller @ 2023-05-27 9:19 UTC (permalink / raw)
To: linux-fbdev, dri-devel
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));
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fbcon: Avoid showing softcursor if font not available
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
0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2023-05-27 10:18 UTC (permalink / raw)
To: Helge Deller; +Cc: linux-fbdev, dri-devel
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.
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>
Sam
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fbcon: Avoid showing softcursor if font not available
2023-05-27 10:18 ` Sam Ravnborg
@ 2023-05-27 17:26 ` Helge Deller
0 siblings, 0 replies; 3+ messages in thread
From: Helge Deller @ 2023-05-27 17:26 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux-fbdev, dri-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-27 17:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).