Bug 621435 (CVE-2010-2803)

Summary: CVE-2010-2803 kernel: drm ioctls infoleak
Product: [Other] Security Response Reporter: Eugene Teo (Security Response) <eteo>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: airlied, arozansk, bhu, jkacur, lgoncalv, lwang, peterm, security-response-team, tcallawa, williams
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-22 13:26:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 621436, 621437, 626319    
Bug Blocks:    

Description Eugene Teo (Security Response) 2010-08-05 03:46:39 UTC
Description of problem:
There is a problem with the ioctl subsystem for drm, though it is most explicitly exposed by the intel GEM driver. Under driver-defined ioctls, drm does not sanitize the ioctl command, allowing the caller to specify how much memory should be kmalloc'd and copied back to the caller, regardless of what the driver ioctl actually does (it doesn't even need to succeed).

drivers/gpu/drm/drm_drv.c

long drm_ioctl(struct file *filp,
              unsigned int cmd, unsigned long arg)
...
       unsigned int nr = DRM_IOCTL_NR(cmd);
...
       if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END) &&
           (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls))
               ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
...
               if (cmd & (IOC_IN | IOC_OUT)) {
                       if (_IOC_SIZE(cmd) <= sizeof(stack_kdata)) {
                               kdata = stack_kdata;
                       } else {
                               kdata = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
...
                       }
               }
...
               retcode = func(dev, kdata, file_priv);
...
               if (cmd & IOC_OUT) {
                       if (copy_to_user((void __user *)arg, kdata,
                                        _IOC_SIZE(cmd)) != 0)
                               retcode = -EFAULT;
               }



"cmd" is caller-controlled, and can do whatever it likes for _IOC_SIZE(cmd), IOC_IN and IOC_OUT, resulting in leakage of previously freed kernel heap memory contents up to 16K in size.

Comment 2 Eugene Teo (Security Response) 2010-08-05 03:54:15 UTC
Acknowledgements:

Red Hat would like to thank Kees Cook for reporting this issue.

Comment 3 Eugene Teo (Security Response) 2010-08-05 03:58:16 UTC
Statement:

This issue did not affect the version of Linux kernel as shipped with Red Hat
Enterprise Linux 3, 4, 5 and Red Hat Enterprise MRG as they did not include
support for GPU DRM.

Comment 5 Eugene Teo (Security Response) 2010-08-05 04:04:25 UTC
To exploit this, the user has to log in under X or otherwise has r/w access to the dri path (group "video").

Comment 10 errata-xmlrpc 2010-11-10 19:09:38 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 6

Via RHSA-2010:0842 https://rhn.redhat.com/errata/RHSA-2010-0842.html

Comment 11 errata-xmlrpc 2010-11-22 19:35:28 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 6

Via RHSA-2010:0842 https://rhn.redhat.com/errata/RHSA-2010-0842.html