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:   Sat, 6 Apr 2019 11:47:21 +0200
From:   Hans de Goede <hdegoede@...hat.com>
To:     Sidong Yang <realwakka@...il.com>
Cc:     David Airlie <airlied@...ux.ie>, Daniel Vetter <daniel@...ll.ch>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/vboxvideo: Avoid double check buffer_overflow in
 vbva_write()

Hi,

On 06-04-19 10:18, Sidong Yang wrote:
> In vbva_write(), We do not need to double check available chunk size if
> chunk is smaller than available buffer. Put the second if clause in the
> first if clause and avoid check twice.
> 
> Signed-off-by: Sidong Yang <realwakka@...il.com>

The code pattern of checking some condition, then fixing it up
and checking again without putting the second check inside the
first check's if block is quite normal and IMHO is more readable
then the nested version with all the extra indentation.

I"m sure the compiler is more then smart enough to just optimize
away the second check if the first one succeeds.

So I see no benefits to this patch, so nack from me.

Regards,

Hans


> ---
>   drivers/gpu/drm/vboxvideo/vbva_base.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vboxvideo/vbva_base.c b/drivers/gpu/drm/vboxvideo/vbva_base.c
> index 36bc9824ec3f..a0c185acf37a 100644
> --- a/drivers/gpu/drm/vboxvideo/vbva_base.c
> +++ b/drivers/gpu/drm/vboxvideo/vbva_base.c
> @@ -80,14 +80,14 @@ bool vbva_write(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx,
>   		if (chunk >= available) {
>   			vbva_buffer_flush(ctx);
>   			available = vbva_buffer_available(vbva);
> -		}
> -
> -		if (chunk >= available) {
> -			if (WARN_ON(available <= vbva->partial_write_tresh)) {
> -				vbva_ctx->buffer_overflow = true;
> -				return false;
> +			if (chunk >= available) {
> +				if (WARN_ON(available <= vbva->partial_write_tresh)) {
> +					vbva_ctx->buffer_overflow = true;
> +					return false;
> +				}
> +				chunk = available - vbva->partial_write_tresh;
>   			}
> -			chunk = available - vbva->partial_write_tresh;
> +
>   		}
>   
>   		vbva_buffer_place_data_at(vbva_ctx, p, chunk,
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ