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: <202405181321.BE7CB28587@keescook>
Date: Sat, 18 May 2024 13:21:55 -0700
From: Kees Cook <keescook@...omium.org>
To: Guenter Roeck <linux@...ck-us.net>
Cc: David Airlie <airlied@...il.com>, Karol Herbst <kherbst@...hat.com>,
	Lyude Paul <lyude@...hat.com>, Daniel Vetter <daniel@...ll.ch>,
	dri-devel@...ts.freedesktop.org, nouveau@...ts.freedesktop.org,
	linux-kernel@...r.kernel.org,
	Javier Martinez Canillas <javierm@...hat.com>,
	Jani Nikula <jani.nikula@...el.com>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	Danilo Krummrich <dakr@...hat.com>,
	Maxime Ripard <mripard@...nel.org>,
	Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: Re: [PATCH v2] drm/nouveau/nvif: Avoid build error due to potential
 integer overflows

On Sat, May 18, 2024 at 11:29:23AM -0700, Guenter Roeck wrote:
> Trying to build parisc:allmodconfig with gcc 12.x or later results
> in the following build error.
> 
> drivers/gpu/drm/nouveau/nvif/object.c: In function 'nvif_object_mthd':
> drivers/gpu/drm/nouveau/nvif/object.c:161:9: error:
> 	'memcpy' accessing 4294967264 or more bytes at offsets 0 and 32 overlaps 6442450881 bytes at offset -2147483617 [-Werror=restrict]
>   161 |         memcpy(data, args->mthd.data, size);
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/nouveau/nvif/object.c: In function 'nvif_object_ctor':
> drivers/gpu/drm/nouveau/nvif/object.c:298:17: error:
> 	'memcpy' accessing 4294967240 or more bytes at offsets 0 and 56 overlaps 6442450833 bytes at offset -2147483593 [-Werror=restrict]
>   298 |                 memcpy(data, args->new.data, size);
> 
> gcc assumes that 'sizeof(*args) + size' can overflow, which would result
> in the problem.
> 
> The problem is not new, only it is now no longer a warning but an error
> since W=1 has been enabled for the drm subsystem and since Werror is
> enabled for test builds.
> 
> Rearrange arithmetic and use check_add_overflow() for validating the
> allocation size to avoid the overflow.
> 
> Fixes: a61ddb4393ad ("drm: enable (most) W=1 warnings by default across the subsystem")
> Cc: Javier Martinez Canillas <javierm@...hat.com>
> Cc: Jani Nikula <jani.nikula@...el.com>
> Cc: Thomas Zimmermann <tzimmermann@...e.de>
> Cc: Danilo Krummrich <dakr@...hat.com>
> Cc: Maxime Ripard <mripard@...nel.org>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> Signed-off-by: Guenter Roeck <linux@...ck-us.net>

Yeah, looks good to me. Thanks!

Reviewed-by: Kees Cook <keescook@...omium.org>

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ