lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200803115328.GA955269@kroah.com>
Date:   Mon, 3 Aug 2020 13:53:28 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     madhuparnabhowmik10@...il.com
Cc:     arnd@...db.de, linux-kernel@...r.kernel.org, andrianov@...ras.ru,
        ldv-project@...uxtesting.org
Subject: Re: [PATCH] drivers: char: applicom.c: Add lock for protecting
 DeviceErrorCount

On Mon, Aug 03, 2020 at 04:20:49PM +0530, madhuparnabhowmik10@...il.com wrote:
> From: Madhuparna Bhowmik <madhuparnabhowmik10@...il.com>
> 
> The variable DeviceErrorCount is used to keep track of the number of
> errors in read, write and interrupt routines, however it was not
> protected by proper locking.
> Therefore, this patch adds a spinlock: error_lock to protect the
> variable.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@...il.com>
> ---
>  drivers/char/applicom.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
> index 14b2d8034c51..6df7450b8b99 100644
> --- a/drivers/char/applicom.c
> +++ b/drivers/char/applicom.c
> @@ -106,6 +106,7 @@ static DECLARE_WAIT_QUEUE_HEAD(FlagSleepRec);
>  static unsigned int WriteErrorCount;	/* number of write error      */
>  static unsigned int ReadErrorCount;	/* number of read error       */
>  static unsigned int DeviceErrorCount;	/* number of device error     */
> +DEFINE_SPINLOCK(error_lock);		/* lock to protect error count variables */

That's a horrible global name, shouldn't it be static?

>  
>  static ssize_t ac_read (struct file *, char __user *, size_t, loff_t *);
>  static ssize_t ac_write (struct file *, const char __user *, size_t, loff_t *);
> @@ -428,7 +429,9 @@ static ssize_t ac_write(struct file *file, const char __user *buf, size_t count,
>  		spin_unlock_irqrestore(&apbs[IndexCard].mutex, flags);
>  		printk(KERN_WARNING "APPLICOM driver write error board %d, DataFromPcReady = %d\n",
>  		       IndexCard,(int)readb(apbs[IndexCard].RamIO + DATA_FROM_PC_READY));
> +		spin_lock_irqsave(&error_lock, flags);

Why all of these irqsave?

>  		DeviceErrorCount++;

Does this really matter?  Who cares if we drop one of these, or any
other of these debugging-only values?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ