All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] speakup: Add spinlock in synth_direct_store
@ 2016-09-05 13:17 Pavel Andrianov
  2016-09-05 21:55 ` Samuel Thibault
  2016-09-06  3:29 ` Vaishali Thakkar
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Andrianov @ 2016-09-05 13:17 UTC (permalink / raw)
  To: Samuel Thibault
  Cc: Pavel Andrianov, William Hubbs, Chris Brannon, Kirk Reiser,
	Greg Kroah-Hartman, Shraddha Barke, Dilek Uzulmez, speakup,
	devel, linux-kernel, vaishali.thakkar, ldv-project

All operations with synth buffer should be protected,
as there are global pointers, which should be modified atomically.

Found by Linux Driver Verification project (linuxtesting.org)

Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>
---
 drivers/staging/speakup/kobjects.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index 528cbdc..7fedee3 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -411,11 +411,13 @@ static ssize_t synth_direct_store(struct kobject *kobj,
 	int len;
 	int bytes;
 	const char *ptr = buf;
+	unsigned long flags;
 
 	if (!synth)
 		return -EPERM;
 
 	len = strlen(buf);
+	spin_lock_irqsave(&speakup_info.spinlock, flags);
 	while (len > 0) {
 		bytes = min_t(size_t, len, 250);
 		strncpy(tmp, ptr, bytes);
@@ -425,6 +427,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
 		ptr += bytes;
 		len -= bytes;
 	}
+	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
 	return count;
 }
 
-- 
2.7.4

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

* Re: [PATCH] speakup: Add spinlock in synth_direct_store
  2016-09-05 13:17 [PATCH] speakup: Add spinlock in synth_direct_store Pavel Andrianov
@ 2016-09-05 21:55 ` Samuel Thibault
  2016-09-06  3:29 ` Vaishali Thakkar
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2016-09-05 21:55 UTC (permalink / raw)
  To: Pavel Andrianov
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, Greg Kroah-Hartman,
	Shraddha Barke, Dilek Uzulmez, speakup, devel, linux-kernel,
	vaishali.thakkar, ldv-project

Pavel Andrianov, on Mon 05 Sep 2016 16:17:47 +0300, wrote:
> All operations with synth buffer should be protected,
> as there are global pointers, which should be modified atomically.
> 
> Found by Linux Driver Verification project (linuxtesting.org)
> 
> Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  drivers/staging/speakup/kobjects.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index 528cbdc..7fedee3 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -411,11 +411,13 @@ static ssize_t synth_direct_store(struct kobject *kobj,
>  	int len;
>  	int bytes;
>  	const char *ptr = buf;
> +	unsigned long flags;
>  
>  	if (!synth)
>  		return -EPERM;
>  
>  	len = strlen(buf);
> +	spin_lock_irqsave(&speakup_info.spinlock, flags);
>  	while (len > 0) {
>  		bytes = min_t(size_t, len, 250);
>  		strncpy(tmp, ptr, bytes);
> @@ -425,6 +427,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
>  		ptr += bytes;
>  		len -= bytes;
>  	}
> +	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
>  	return count;
>  }
>  
> -- 
> 2.7.4
> 

-- 
Samuel
Linux, c'est simple : ça s'adresse à une machine qui est parfois un peu
maraboutée mais qui d'habitude n'a pas d'états d'âme. Sur Usenet y'a
plein d'humains et de primates, et ça devient vraiment gore par moment.
-+- TP in : Guide du linuxien pervers - "Le linuxien a-t-il une âme ?" -+-

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

* Re: [PATCH] speakup: Add spinlock in synth_direct_store
  2016-09-05 13:17 [PATCH] speakup: Add spinlock in synth_direct_store Pavel Andrianov
  2016-09-05 21:55 ` Samuel Thibault
@ 2016-09-06  3:29 ` Vaishali Thakkar
  1 sibling, 0 replies; 3+ messages in thread
From: Vaishali Thakkar @ 2016-09-06  3:29 UTC (permalink / raw)
  To: Pavel Andrianov, Samuel Thibault
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, Greg Kroah-Hartman,
	Shraddha Barke, Dilek Uzulmez, speakup, devel, linux-kernel,
	ldv-project



On Monday 05 September 2016 06:47 PM, Pavel Andrianov wrote:
> All operations with synth buffer should be protected,
> as there are global pointers, which should be modified atomically.
> 
> Found by Linux Driver Verification project (linuxtesting.org)
> 
> Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>

Acked-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>

> ---
>  drivers/staging/speakup/kobjects.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index 528cbdc..7fedee3 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -411,11 +411,13 @@ static ssize_t synth_direct_store(struct kobject *kobj,
>  	int len;
>  	int bytes;
>  	const char *ptr = buf;
> +	unsigned long flags;
>  
>  	if (!synth)
>  		return -EPERM;
>  
>  	len = strlen(buf);
> +	spin_lock_irqsave(&speakup_info.spinlock, flags);
>  	while (len > 0) {
>  		bytes = min_t(size_t, len, 250);
>  		strncpy(tmp, ptr, bytes);
> @@ -425,6 +427,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
>  		ptr += bytes;
>  		len -= bytes;
>  	}
> +	spin_unlock_irqrestore(&speakup_info.spinlock, flags);
>  	return count;
>  }
>  
> 

-- 
Vaishali

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

end of thread, other threads:[~2016-09-06  3:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-05 13:17 [PATCH] speakup: Add spinlock in synth_direct_store Pavel Andrianov
2016-09-05 21:55 ` Samuel Thibault
2016-09-06  3:29 ` Vaishali Thakkar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.