From: Dan Carpenter <dan.carpenter@oracle.com>
To: David Airlie <airlied@linux.ie>,
Ilja Van Sprundel <ivansprundel@ioactive.com>
Cc: security@kernel.org, dri-devel@lists.freedesktop.org,
yanyang1 <young.yang@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Ken Wang" <Qingqing.Wang@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>
Subject: [patch 2/4] drm/amdgpu: integer overflow in amdgpu_info_ioctl()
Date: Wed, 23 Sep 2015 14:00:12 +0300 [thread overview]
Message-ID: <20150923110012.GB16158@mwanda> (raw)
In-Reply-To: <13E61BCA7787794E89BDF39B8DE40C024D12E9F63F@ioaexchange.ioactive.local>
The "alloc_size" calculation can overflow leading to memory corruption.
Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
The amdgpu_asic_read_register() functions seem likely to be slow. They
iterate through all the registers to find the correct register to read.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 2236793..8c735f5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -390,7 +390,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
min((size_t)size, sizeof(vram_gtt))) ? -EFAULT : 0;
}
case AMDGPU_INFO_READ_MMR_REG: {
- unsigned n, alloc_size = info->read_mmr_reg.count * 4;
+ unsigned n, alloc_size;
uint32_t *regs;
unsigned se_num = (info->read_mmr_reg.instance >>
AMDGPU_INFO_MMR_SE_INDEX_SHIFT) &
@@ -406,9 +406,10 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
sh_num = 0xffffffff;
- regs = kmalloc(alloc_size, GFP_KERNEL);
+ regs = kmalloc_array(info->read_mmr_reg.count, sizeof(*regs), GFP_KERNEL);
if (!regs)
return -ENOMEM;
+ alloc_size = info->read_mmr_reg.count * sizeof(*regs);
for (i = 0; i < info->read_mmr_reg.count; i++)
if (amdgpu_asic_read_register(adev, se_num, sh_num,
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-09-23 11:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <13E61BCA7787794E89BDF39B8DE40C024D12E9F63F@ioaexchange.ioactive.local>
2015-09-23 10:59 ` [patch 1/4] drm/amdgpu: unwind properly in amdgpu_cs_parser_init() Dan Carpenter
2015-09-23 14:16 ` Christian König
2015-09-23 17:13 ` Alex Deucher
2015-09-24 7:56 ` Dan Carpenter
2015-09-24 12:56 ` Deucher, Alexander
2015-09-25 11:36 ` [patch] drm/amdgpu: signedness bug " Dan Carpenter
2015-09-25 11:36 ` Dan Carpenter
2015-09-29 17:44 ` Alex Deucher
2015-09-29 17:44 ` Alex Deucher
2015-09-23 11:00 ` Dan Carpenter [this message]
2015-09-23 11:00 ` [patch 3/4] drm/amdgpu: info leak in amdgpu_gem_metadata_ioctl() Dan Carpenter
2015-09-23 11:00 ` [patch 4/4] drm/amdgpu: integer overflow in amdgpu_mode_dumb_create() Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150923110012.GB16158@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Qingqing.Wang@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ivansprundel@ioactive.com \
--cc=security@kernel.org \
--cc=young.yang@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.