public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.19 01/10] drm: Use size_t type for len variable in drm_copy_field()
@ 2022-10-09 23:57 Sasha Levin
  2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 02/10] drm: Prevent drm_copy_field() to attempt copying a NULL pointer Sasha Levin
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Sasha Levin @ 2022-10-09 23:57 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Javier Martinez Canillas, Peter Robinson, Thomas Zimmermann,
	Sasha Levin, maarten.lankhorst, mripard, airlied, daniel,
	dri-devel

From: Javier Martinez Canillas <javierm@redhat.com>

[ Upstream commit 94dc3471d1b2b58b3728558d0e3f264e9ce6ff59 ]

The strlen() function returns a size_t which is an unsigned int on 32-bit
arches and an unsigned long on 64-bit arches. But in the drm_copy_field()
function, the strlen() return value is assigned to an 'int len' variable.

Later, the len variable is passed as copy_from_user() third argument that
is an unsigned long parameter as well.

In theory, this can lead to an integer overflow via type conversion. Since
the assignment happens to a signed int lvalue instead of a size_t lvalue.

In practice though, that's unlikely since the values copied are set by DRM
drivers and not controlled by userspace. But using a size_t for len is the
correct thing to do anyways.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Peter Robinson <pbrobinson@gmail.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220705100215.572498-2-javierm@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/drm_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index babd7ebabfef..4fea6519510c 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -458,7 +458,7 @@ EXPORT_SYMBOL(drm_invalid_op);
  */
 static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
 {
-	int len;
+	size_t len;
 
 	/* don't overflow userbuf */
 	len = strlen(value);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-10-13 18:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-09 23:57 [PATCH AUTOSEL 4.19 01/10] drm: Use size_t type for len variable in drm_copy_field() Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 02/10] drm: Prevent drm_copy_field() to attempt copying a NULL pointer Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 03/10] drm/amd/display: fix overflow on MIN_I64 definition Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 04/10] drm: hide unregistered connectors from GETCONNECTOR IOCTL Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 05/10] drm/vc4: vec: Fix timings for VEC modes Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 06/10] ACPI: video: Change disable_backlight_sysfs_if quirks to acpi_backlight=native Sasha Levin
2022-10-10  7:36   ` Hans de Goede
2022-10-13 17:59     ` Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 07/10] drm: panel-orientation-quirks: Add quirk for Anbernic Win600 Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 08/10] platform/x86: msi-laptop: Change DMI match / alias strings to fix module autoloading Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 09/10] drm/amdgpu: fix initial connector audio value Sasha Levin
2022-10-09 23:57 ` [PATCH AUTOSEL 4.19 10/10] drm/exynos: Fix return type for mixer_mode_valid and hdmi_mode_valid Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox