Patch "drm: Use size_t type for len variable in drm_copy_field()" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drm: Use size_t type for len variable in drm_copy_field()

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-use-size_t-type-for-len-variable-in-drm_copy_fie.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 256123fd0dd631be31870e0ac94f38637ae9d5d1
Author: Javier Martinez Canillas <javierm@xxxxxxxxxx>
Date:   Tue Jul 5 12:02:13 2022 +0200

    drm: Use size_t type for len variable in drm_copy_field()
    
    [ 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@xxxxxxxxxx>
    Tested-by: Peter Robinson <pbrobinson@xxxxxxxxx>
    Reviewed-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220705100215.572498-2-javierm@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 8faad23dc1d8..e1b9a03e619c 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -472,7 +472,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);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux