public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Qiujun Huang <hqjagain@gmail.com>
To: b.zolnierkie@samsung.com
Cc: daniel.vetter@ffwll.ch, maarten.lankhorst@linux.intel.com,
	sam@ravnborg.org, daniel.thompson@linaro.org, ghalat@redhat.com,
	dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Qiujun Huang <hqjagain@gmail.com>
Subject: [PATCH] fbcon: fix null-ptr-deref in fbcon_switch
Date: Sat, 28 Mar 2020 23:15:10 +0800	[thread overview]
Message-ID: <20200328151511.22932-1-hqjagain@gmail.com> (raw)

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


             reply	other threads:[~2020-03-28 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-28 15:15 Qiujun Huang [this message]
2020-03-28 16:31 ` [PATCH] fbcon: fix null-ptr-deref in fbcon_switch Daniel Vetter
2020-03-28 16:57   ` Qiujun Huang
2020-03-28 18:12 ` Sam Ravnborg
2020-03-29  1:04   ` Qiujun Huang

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=20200328151511.22932-1-hqjagain@gmail.com \
    --to=hqjagain@gmail.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ghalat@redhat.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --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