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] [day] [month] [year] [list]
Message-ID: <20191012141551.761178d8@archlinux>
Date:   Sat, 12 Oct 2019 14:15:51 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Alexandru Ardelean <alexandru.ardelean@...log.com>
Cc:     <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <jonathan.cameron@...wei.com>, <dan.carpenter@...cle.com>
Subject: Re: [PATCH v2] iio: imu: adis16480: make sure provided frequency is
 positive

On Tue, 8 Oct 2019 17:15:37 +0300
Alexandru Ardelean <alexandru.ardelean@...log.com> wrote:

> It could happen that either `val` or `val2` [provided from userspace] is
> negative. In that case the computed frequency could get a weird value.
> 
> Fix this by checking that neither of the 2 variables is negative, and check
> that the computed result is not-zero.
> 
> Fixes: e4f959390178 ("iio: imu: adis16480 switch sampling frequency attr to core support")
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan
> ---
> 
> Changelog v1 -> v2:
> * also check that val & val2 are not negative (in addition to checking if
>  't' is zero
> 
>  drivers/iio/imu/adis16480.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index 01dae50e985b..0bec1fea823d 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -317,8 +317,11 @@ static int adis16480_set_freq(struct iio_dev *indio_dev, int val, int val2)
>  	struct adis16480 *st = iio_priv(indio_dev);
>  	unsigned int t, reg;
>  
> +	if (val < 0 || val2 < 0)
> +		return -EINVAL;
> +
>  	t =  val * 1000 + val2 / 1000;
> -	if (t <= 0)
> +	if (t == 0)
>  		return -EINVAL;
>  
>  	/*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ