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:   Wed, 18 Jan 2023 18:26:50 +0300
From:   Dan Carpenter <error27@...il.com>
To:     Brent Pappas <bpappas@...pasbrent.com>
Cc:     ailus@...ux.intel.com, andy.shevchenko@...il.com,
        gregkh@...uxfoundation.org, hdegoede@...hat.com,
        linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
        linux-staging@...ts.linux.dev, mchehab@...nel.org
Subject: Re: [PATCH v5] media: atomisp: pci: Replace bytes macros with
 functions

On Wed, Jan 18, 2023 at 10:16:56AM -0500, Brent Pappas wrote:
> Replace the function-like macros FPNTBL_BYTES(), SCTBL_BYTES(), and
> MORPH_PLANE_BYTES() with functions to comply with Linux coding style
> standards.
> Replace multiplication with calls to array_size() and array3_size()
> to prevent accidental arithmetic overflow.
> 
> Signed-off-by: Brent Pappas <bpappas@...pasbrent.com>
> ---
> Changelog:
> V1 -> V2: Use size_mul() to perform size_t multiplication without risk of
> 		  overflow.
> 		  Remove the inline keyword from function definitions.
> 
> V2 -> V3: Add commit message.
> 
> V3 -> V4: Use array_size() and array3_size() for multiplication.
> 
> V4 -> V5: Fix indentation.
> 
>  .../staging/media/atomisp/pci/sh_css_params.c | 38 +++++++++++--------
>  1 file changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/sh_css_params.c b/drivers/staging/media/atomisp/pci/sh_css_params.c
> index f08564f58242..7e111df5c09d 100644
> --- a/drivers/staging/media/atomisp/pci/sh_css_params.c
> +++ b/drivers/staging/media/atomisp/pci/sh_css_params.c
> @@ -98,17 +98,27 @@
>  #include "sh_css_frac.h"
>  #include "ia_css_bufq.h"
>  
> -#define FPNTBL_BYTES(binary) \
> -	(sizeof(char) * (binary)->in_frame_info.res.height * \
> -	 (binary)->in_frame_info.padded_width)
> +static size_t fpntbl_bytes(const struct ia_css_binary *binary)
> +{
> +	return array3_size(sizeof(char),
> +					   binary->in_frame_info.res.height,
> +					   binary->in_frame_info.padded_width);

Nope.

> +}
>  
> -#define SCTBL_BYTES(binary) \
> -	(sizeof(unsigned short) * (binary)->sctbl_height * \
> -	 (binary)->sctbl_aligned_width_per_color * IA_CSS_SC_NUM_COLORS)
> +static size_t sctbl_bytes(const struct ia_css_binary *binary)
> +{
> +	return array_size(sizeof(unsigned short),
> +					  array3_size(binary->sctbl_height,
> +						      binary->sctbl_aligned_width_per_color,
> +								  IA_CSS_SC_NUM_COLORS));

Also nope.

> +}
>  
> -#define MORPH_PLANE_BYTES(binary) \
> -	(SH_CSS_MORPH_TABLE_ELEM_BYTES * (binary)->morph_tbl_aligned_width * \
> -	 (binary)->morph_tbl_height)
> +static size_t morph_plane_bytes(const struct ia_css_binary *binary)
> +{
> +	return array3_size(SH_CSS_MORPH_TABLE_ELEM_BYTES,
> +					   binary->morph_tbl_aligned_width,
> +					   binary->morph_tbl_height);

Nope.

> +}

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ