linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: dimadrumspro@gmail.com
To: dimadrumspro@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c
Date: Thu,  2 Nov 2023 12:39:26 +0100	[thread overview]
Message-ID: <20231102113926.2019-1-dimadrumspro@gmail.com> (raw)

From: Dima <dimadrumspro@gmail.com>

The previous code lacked proper synchronization, leading to potential data corruption and crashes. Added a spin lock to protect shared variable 'scrollback_delta' to prevent concurrent access.

Signed-off-by: Dima <dimadrumspro@gmail.com>
---
 drivers/tty/vt/vt.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 5c47f77804f0..29cf7fe11662 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -301,12 +301,13 @@ static inline unsigned short *screenpos(const struct vc_data *vc, int offset,
 }
 
 /* Called  from the keyboard irq path.. */
+static DEFINE_SPINLOCK(scrolldelta_lock);
+
 static inline void scrolldelta(int lines)
 {
-	/* FIXME */
-	/* scrolldelta needs some kind of consistency lock, but the BKL was
-	   and still is not protecting versus the scheduled back end */
+	spin_lock(&scrolldelta_lock);
 	scrollback_delta += lines;
+	spin_unlock(&scrolldelta_lock);
 	schedule_console_callback();
 }
 
-- 
2.42.0


             reply	other threads:[~2023-11-02 11:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 11:39 dimadrumspro [this message]
2023-11-02 11:42 ` [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2023-11-01 23:53 dimadrumspro
2023-11-02  5:45 ` Greg KH

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=20231102113926.2019-1-dimadrumspro@gmail.com \
    --to=dimadrumspro@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.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).