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]
Date:   Mon, 7 May 2018 20:28:34 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Jia-Ju Bai <baijiaju1990@...il.com>, morbidrsa@...il.com,
        wim@...ux-watchdog.org
Cc:     linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] watchdog: mena21_wdt: Fix a possible data race in
 a21_wdt_set_timeout

On 05/07/2018 08:18 PM, Jia-Ju Bai wrote:
> The write operation to "wdt->timeout" is protected by
> the lock on line 118, but the read operation to
> this data on line 105 is not protected by the lock.
> Thus, there may exist a data race for "wdt->timeout".
> 
> To fix this data race, the read operation to "wdt->timeout"
> should be also protected by the lock.
> 

There is no race. There is already a mutex in the watchdog core which serializes
calls to the various API functions. It would make more sense to drop drv->lock
from the driver.

Guenter

> Signed-off-by: Jia-Ju Bai <baijiaju1990@...il.com>
> ---
>   drivers/watchdog/mena21_wdt.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
> index 25d5d2b8cfbe..05ca69042829 100644
> --- a/drivers/watchdog/mena21_wdt.c
> +++ b/drivers/watchdog/mena21_wdt.c
> @@ -102,14 +102,15 @@ static int a21_wdt_set_timeout(struct watchdog_device *wdt,
>   		return -EINVAL;
>   	}
>   
> +	mutex_lock(&drv->lock);
> +
>   	if (timeout == 30 && wdt->timeout == 1) {
> +		mutex_unlock(&drv->lock);
>   		dev_err(wdt->parent,
>   			"Transition from fast to slow mode not allowed\n");
>   		return -EINVAL;
>   	}
>   
> -	mutex_lock(&drv->lock);
> -
>   	if (timeout == 1)
>   		gpio_set_value(drv->gpios[GPIO_WD_FAST], 1);
>   	else
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ