* [PATCH] fbcon: fix null-ptr-deref in fbcon_switch
@ 2020-03-28 15:15 Qiujun Huang
2020-03-28 16:31 ` Daniel Vetter
2020-03-28 18:12 ` Sam Ravnborg
0 siblings, 2 replies; 5+ messages in thread
From: Qiujun Huang @ 2020-03-28 15:15 UTC (permalink / raw)
To: b.zolnierkie
Cc: daniel.thompson, daniel.vetter, linux-fbdev, dri-devel,
linux-kernel, ghalat, sam, Qiujun Huang
Add check for vc_cons[logo_shown].d, as it can be released by
vt_ioctl(VT_DISALLOCATE).
Reported-by: syzbot+732528bae351682f1f27@syzkaller.appspotmail.com
Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
---
drivers/video/fbdev/core/fbcon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index bb6ae995c2e5..7ee0f7b55829 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2254,7 +2254,7 @@ static int fbcon_switch(struct vc_data *vc)
fbcon_update_softback(vc);
}
- if (logo_shown >= 0) {
+ if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
struct vc_data *conp2 = vc_cons[logo_shown].d;
if (conp2->vc_top == logo_lines
@@ -2852,7 +2852,7 @@ static void fbcon_scrolldelta(struct vc_data *vc, int lines)
return;
if (vc->vc_mode != KD_TEXT || !lines)
return;
- if (logo_shown >= 0) {
+ if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
struct vc_data *conp2 = vc_cons[logo_shown].d;
if (conp2->vc_top == logo_lines
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] fbcon: fix null-ptr-deref in fbcon_switch
2020-03-28 15:15 [PATCH] fbcon: fix null-ptr-deref in fbcon_switch Qiujun Huang
@ 2020-03-28 16:31 ` Daniel Vetter
2020-03-28 16:57 ` Qiujun Huang
2020-03-28 18:12 ` Sam Ravnborg
1 sibling, 1 reply; 5+ messages in thread
From: Daniel Vetter @ 2020-03-28 16:31 UTC (permalink / raw)
To: Qiujun Huang
Cc: Daniel Thompson, Bartlomiej Zolnierkiewicz,
Linux Fbdev development list, dri-devel,
Linux Kernel Mailing List, ghalat, Sam Ravnborg
On Sat, Mar 28, 2020 at 4:15 PM Qiujun Huang <hqjagain@gmail.com> wrote:
> Add check for vc_cons[logo_shown].d, as it can be released by
> vt_ioctl(VT_DISALLOCATE).
Can you pls link to the syzbot report and distill the essence of the
crash/issue here in the commit message? As-is a bit unclear what's
going on. Patch itself looks correct.
Thanks, Daniel
> Reported-by: syzbot+732528bae351682f1f27@syzkaller.appspotmail.com
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> ---
> drivers/video/fbdev/core/fbcon.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index bb6ae995c2e5..7ee0f7b55829 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -2254,7 +2254,7 @@ static int fbcon_switch(struct vc_data *vc)
> fbcon_update_softback(vc);
> }
>
> - if (logo_shown >= 0) {
> + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> struct vc_data *conp2 = vc_cons[logo_shown].d;
>
> if (conp2->vc_top == logo_lines
> @@ -2852,7 +2852,7 @@ static void fbcon_scrolldelta(struct vc_data *vc, int lines)
> return;
> if (vc->vc_mode != KD_TEXT || !lines)
> return;
> - if (logo_shown >= 0) {
> + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> struct vc_data *conp2 = vc_cons[logo_shown].d;
>
> if (conp2->vc_top == logo_lines
> --
> 2.17.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fbcon: fix null-ptr-deref in fbcon_switch
2020-03-28 16:31 ` Daniel Vetter
@ 2020-03-28 16:57 ` Qiujun Huang
0 siblings, 0 replies; 5+ messages in thread
From: Qiujun Huang @ 2020-03-28 16:57 UTC (permalink / raw)
To: Daniel Vetter
Cc: Daniel Thompson, Bartlomiej Zolnierkiewicz,
Linux Fbdev development list, dri-devel,
Linux Kernel Mailing List, ghalat, Sam Ravnborg
On Sun, Mar 29, 2020 at 12:31 AM Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>
> On Sat, Mar 28, 2020 at 4:15 PM Qiujun Huang <hqjagain@gmail.com> wrote:
> > Add check for vc_cons[logo_shown].d, as it can be released by
> > vt_ioctl(VT_DISALLOCATE).
>
> Can you pls link to the syzbot report and distill the essence of the
> crash/issue here in the commit message? As-is a bit unclear what's
> going on. Patch itself looks correct.
https://lkml.org/lkml/2020/3/27/403
Thanks.
>
> Thanks, Daniel
>
> > Reported-by: syzbot+732528bae351682f1f27@syzkaller.appspotmail.com
> > Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> > ---
> > drivers/video/fbdev/core/fbcon.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> > index bb6ae995c2e5..7ee0f7b55829 100644
> > --- a/drivers/video/fbdev/core/fbcon.c
> > +++ b/drivers/video/fbdev/core/fbcon.c
> > @@ -2254,7 +2254,7 @@ static int fbcon_switch(struct vc_data *vc)
> > fbcon_update_softback(vc);
> > }
> >
> > - if (logo_shown >= 0) {
> > + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> > struct vc_data *conp2 = vc_cons[logo_shown].d;
> >
> > if (conp2->vc_top == logo_lines
> > @@ -2852,7 +2852,7 @@ static void fbcon_scrolldelta(struct vc_data *vc, int lines)
> > return;
> > if (vc->vc_mode != KD_TEXT || !lines)
> > return;
> > - if (logo_shown >= 0) {
> > + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> > struct vc_data *conp2 = vc_cons[logo_shown].d;
> >
> > if (conp2->vc_top == logo_lines
> > --
> > 2.17.1
> >
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fbcon: fix null-ptr-deref in fbcon_switch
2020-03-28 15:15 [PATCH] fbcon: fix null-ptr-deref in fbcon_switch Qiujun Huang
2020-03-28 16:31 ` Daniel Vetter
@ 2020-03-28 18:12 ` Sam Ravnborg
2020-03-29 1:04 ` Qiujun Huang
1 sibling, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2020-03-28 18:12 UTC (permalink / raw)
To: Qiujun Huang
Cc: daniel.thompson, b.zolnierkie, daniel.vetter, linux-fbdev,
dri-devel, linux-kernel, ghalat
Hi Qiujun
Thanks for looking into the sysbot bugs.
On Sat, Mar 28, 2020 at 11:15:10PM +0800, Qiujun Huang wrote:
> Add check for vc_cons[logo_shown].d, as it can be released by
> vt_ioctl(VT_DISALLOCATE).
>
> Reported-by: syzbot+732528bae351682f1f27@syzkaller.appspotmail.com
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> ---
> drivers/video/fbdev/core/fbcon.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index bb6ae995c2e5..7ee0f7b55829 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -2254,7 +2254,7 @@ static int fbcon_switch(struct vc_data *vc)
> fbcon_update_softback(vc);
> }
>
> - if (logo_shown >= 0) {
> + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> struct vc_data *conp2 = vc_cons[logo_shown].d;
>
> if (conp2->vc_top == logo_lines
> @@ -2852,7 +2852,7 @@ static void fbcon_scrolldelta(struct vc_data *vc, int lines)
> return;
> if (vc->vc_mode != KD_TEXT || !lines)
> return;
> - if (logo_shown >= 0) {
> + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> struct vc_data *conp2 = vc_cons[logo_shown].d;
>
> if (conp2->vc_top == logo_lines
I am not familiar with this code.
But it looks like you try to avoid the sympton
which is that logo_shown has a wrong value after a
vc is deallocated, and do not fix the root cause.
We have:
vt_ioctl(VT_DISALLOCATE)
|
+- vc_deallocate()
|
+- visual_deinit()
|
+- vc->vc_sw->con_deinit(vc)
|
+- fbcon_deinit()
Would it be better to update logo_shown
in fbcon_deinit()?
Then we will not try to do anything with
the logo in fbcon_switch().
fbcon_deinit() is called with console locked
so there should not be any races.
I did not stare long enough on the code to come up with a patch,
but this may be a better way to fix it.
Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] fbcon: fix null-ptr-deref in fbcon_switch
2020-03-28 18:12 ` Sam Ravnborg
@ 2020-03-29 1:04 ` Qiujun Huang
0 siblings, 0 replies; 5+ messages in thread
From: Qiujun Huang @ 2020-03-29 1:04 UTC (permalink / raw)
To: Sam Ravnborg
Cc: Daniel Thompson, Bartlomiej Zolnierkiewicz, Daniel Vetter,
Linux Fbdev development list, dri-devel, LKML, ghalat
On Sun, Mar 29, 2020 at 2:13 AM Sam Ravnborg <sam@ravnborg.org> wrote:
>
> Hi Qiujun
>
> Thanks for looking into the sysbot bugs.
>
> On Sat, Mar 28, 2020 at 11:15:10PM +0800, Qiujun Huang wrote:
> > Add check for vc_cons[logo_shown].d, as it can be released by
> > vt_ioctl(VT_DISALLOCATE).
> >
> > Reported-by: syzbot+732528bae351682f1f27@syzkaller.appspotmail.com
> > Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> > ---
> > drivers/video/fbdev/core/fbcon.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> > index bb6ae995c2e5..7ee0f7b55829 100644
> > --- a/drivers/video/fbdev/core/fbcon.c
> > +++ b/drivers/video/fbdev/core/fbcon.c
> > @@ -2254,7 +2254,7 @@ static int fbcon_switch(struct vc_data *vc)
> > fbcon_update_softback(vc);
> > }
> >
> > - if (logo_shown >= 0) {
> > + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> > struct vc_data *conp2 = vc_cons[logo_shown].d;
> >
> > if (conp2->vc_top == logo_lines
> > @@ -2852,7 +2852,7 @@ static void fbcon_scrolldelta(struct vc_data *vc, int lines)
> > return;
> > if (vc->vc_mode != KD_TEXT || !lines)
> > return;
> > - if (logo_shown >= 0) {
> > + if (logo_shown >= 0 && vc_cons_allocated(logo_shown)) {
> > struct vc_data *conp2 = vc_cons[logo_shown].d;
> >
> > if (conp2->vc_top == logo_lines
>
> I am not familiar with this code.
>
> But it looks like you try to avoid the sympton
> which is that logo_shown has a wrong value after a
> vc is deallocated, and do not fix the root cause.
>
> We have:
>
> vt_ioctl(VT_DISALLOCATE)
> |
> +- vc_deallocate()
> |
> +- visual_deinit()
> |
> +- vc->vc_sw->con_deinit(vc)
> |
> +- fbcon_deinit()
>
> Would it be better to update logo_shown
> in fbcon_deinit()?
> Then we will not try to do anything with
> the logo in fbcon_switch().
>
> fbcon_deinit() is called with console locked
> so there should not be any races.
Get that, thanks.
>
> I did not stare long enough on the code to come up with a patch,
> but this may be a better way to fix it.
>
> Sam
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-30 7:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-28 15:15 [PATCH] fbcon: fix null-ptr-deref in fbcon_switch Qiujun Huang
2020-03-28 16:31 ` Daniel Vetter
2020-03-28 16:57 ` Qiujun Huang
2020-03-28 18:12 ` Sam Ravnborg
2020-03-29 1:04 ` Qiujun Huang
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).