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]
Date:	Wed, 10 Sep 2014 15:29:53 +0300
From:	Sakari Ailus <sakari.ailus@....fi>
To:	Maciej Matraszek <m.matraszek@...sung.com>
Cc:	linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
	Mauro Carvalho Chehab <m.chehab@...sung.com>,
	Hans Verkuil <hans.verkuil@...co.com>,
	Lars-Peter Clausen <lars@...afoo.de>,
	Sylwester Nawrocki <s.nawrocki@...sung.com>,
	stable@...r.kernel.org,
	Krzysztof Kozlowski <k.kozlowski@...sung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
Subject: Re: [PATCH] [media] v4l2-common: fix overflow in
 v4l_bound_align_image()

Hi Maciej,

Thanks for the patch!

On Tue, Sep 09, 2014 at 05:16:41PM +0200, Maciej Matraszek wrote:
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index ccaa38f65cf1..506cf8b7763b 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -435,16 +435,13 @@ static unsigned int clamp_align(unsigned int x, unsigned int min,
>  	/* Bits that must be zero to be aligned */
>  	unsigned int mask = ~((1 << align) - 1);
>  
> +	/* Clamp to aligned min and max */
> +	x = clamp_t(unsigned int, x, (min + ~mask) & mask, max & mask);

I think you could use just clamp() since all the arguments are unsigned int.
With that considered,

Acked-by: Sakari Ailus <sakari.ailus@...ux.intel.com>

> +
>  	/* Round to nearest aligned value */
>  	if (align)
>  		x = (x + (1 << (align - 1))) & mask;
> 
> -	/* Clamp to aligned value of min and max */
> -	if (x < min)
> -		x = (min + ~mask) & mask;
> -	else if (x > max)
> -		x = max & mask;
> -
>  	return x;
>  }
>  

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@....fi	XMPP: sailus@...iisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ