linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c
@ 2023-11-01 23:53 dimadrumspro
  2023-11-02  5:45 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: dimadrumspro @ 2023-11-01 23:53 UTC (permalink / raw)
  To: dimaac; +Cc: linux-kernel, linux-serial, dimaaac

From: dimaaac <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: dimaaac <dimaac@bk.ru>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c
  2023-11-01 23:53 dimadrumspro
@ 2023-11-02  5:45 ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2023-11-02  5:45 UTC (permalink / raw)
  To: dimadrumspro; +Cc: dimaac, linux-kernel, linux-serial

On Thu, Nov 02, 2023 at 12:53:32AM +0100, dimadrumspro@gmail.com wrote:
> From: dimaaac <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: dimaaac <dimaac@bk.ru>
> ---
>  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
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/process/submitting-patches.rst for what is needed in
  order to properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/process/submitting-patches.rst for what a proper
  Subject: line should look like.

- It looks like you did not use your "real" name for the patch on either
  the Signed-off-by: line, or the From: line (both of which have to
  match).  Please read the kernel file,
  Documentation/process/submitting-patches.rst for how to do this
  correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c
@ 2023-11-02 11:39 dimadrumspro
  2023-11-02 11:42 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: dimadrumspro @ 2023-11-02 11:39 UTC (permalink / raw)
  To: dimadrumspro; +Cc: linux-kernel, linux-serial

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c
  2023-11-02 11:39 [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c dimadrumspro
@ 2023-11-02 11:42 ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2023-11-02 11:42 UTC (permalink / raw)
  To: dimadrumspro; +Cc: linux-kernel, linux-serial

Where is patch 1/2?

On Thu, Nov 02, 2023 at 12:39:26PM +0100, dimadrumspro@gmail.com wrote:
> From: Dima <dimadrumspro@gmail.com>

Is that your full name?

> 
> 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.

Please wrap your lines properly, as your editor hinted that you should.

And always run scripts/checkpatch.pl on your patch before submitting it.

> 
> 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);

How exactly did you test this?  This patch does not do anything that I
can determine.

And what "crashes" have you fixed here?  What "data corruption"?  Your
changelog text does not match this actual change at all from what I can
tell.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-02 11:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 11:39 [PATCH 2/2] drivers: tty: vt: vt.c: fixed segmentation fault in vt.c dimadrumspro
2023-11-02 11:42 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2023-11-01 23:53 dimadrumspro
2023-11-02  5:45 ` Greg KH

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).