diff options
author | Vegard Nossum <vegard.nossum@gmail.com> | 2008-12-02 04:38:47 +0100 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2008-12-29 08:47:22 +0100 |
commit | 1147c9cdd0f60f09a98702a9f865176af18a989f (patch) | |
tree | 4f3c33102566475cd145cf0235c1738d07b8b715 /drivers/gpu/drm/drm_stub.c | |
parent | drm: move to kref per-master structures. (diff) | |
download | linux-1147c9cdd0f60f09a98702a9f865176af18a989f.tar.xz linux-1147c9cdd0f60f09a98702a9f865176af18a989f.zip |
drm: fix leak of uninitialized data to userspace
...so drm_getunique() is trying to copy some uninitialized data to
userspace. The ECX register contains the number of words that are
left to copy -- so there are 5 * 4 = 20 bytes left. The offset of the
first uninitialized byte (counting from the start of the string) is
also 20 (i.e. 0xf65d2294&((1 << 5)-1) == 20). So somebody tried to
copy 40 bytes when the string was only 19 long.
In drm_set_busid() we have this code:
dev->unique_len = 40;
dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
...
len = snprintf(dev->unique, dev->unique_len, pci:%04x:%02x:%02x.%d",
...so it seems that dev->unique is never updated to reflect the
actual length of the string. The remaining bytes (20 in this case)
are random uninitialized bytes that are copied into userspace.
This patch fixes the problem by setting dev->unique_len after the
snprintf().
airlied- I've had to fix this up to store the alloced size so
we have it for drm_free later.
Reported-by: Sitsofe Wheeler <sitsofe@yahoo.com>
Signed-off-by: Vegard Nossum <vegardno@thuin.ifi.uio.no>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_stub.c')
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 0f24c2dcd517..f7985c303cb0 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -117,7 +117,7 @@ static void drm_master_destroy(struct kref *kref) dev->driver->master_destroy(dev, master); if (master->unique) { - drm_free(master->unique, strlen(master->unique) + 1, DRM_MEM_DRIVER); + drm_free(master->unique, master->unique_size, DRM_MEM_DRIVER); master->unique = NULL; master->unique_len = 0; } |