* fix for crashes provoked by UMS mode
@ 2013-01-07 23:21 Ilija Hadzic
2013-01-07 23:21 ` [PATCH 1/3] drm/radeon: fix NULL pointer dereference in " Ilija Hadzic
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Ilija Hadzic @ 2013-01-07 23:21 UTC (permalink / raw)
To: dri-devel
At Dave's request I ran some regression tests on my CS-refactoring
patches [1] against old UMS userspace. The tests have revealed
that the current kernel can be provoked into crashing in UMS mode
(and the problem is unrelated to refactoring of CS code; it has
been here before).
The following patches will fix the problem that I discovered
while testing (and they should probably go to drm-fixes branch).
First two patches are the fix for the acute problem, while
the third patch is a fix for an incidental finding uncovered
while debugging the problem.
[1] http://lists.freedesktop.org/archives/dri-devel/2013-January/032814.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] drm/radeon: fix NULL pointer dereference in UMS mode
2013-01-07 23:21 fix for crashes provoked by UMS mode Ilija Hadzic
@ 2013-01-07 23:21 ` Ilija Hadzic
2013-01-07 23:21 ` [PATCH 2/3] drm/radeon: fix a bogus kfree Ilija Hadzic
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Ilija Hadzic @ 2013-01-07 23:21 UTC (permalink / raw)
To: dri-devel
In UMS mode parser->rdev is NULL, so dereferencing
will cause an oops.
Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
---
drivers/gpu/drm/radeon/radeon_cs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 396baba0..45151c4 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -279,7 +279,7 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
p->chunks[p->chunk_ib_idx].length_dw);
return -EINVAL;
}
- if ((p->rdev->flags & RADEON_IS_AGP)) {
+ if (p->rdev && (p->rdev->flags & RADEON_IS_AGP)) {
p->chunks[p->chunk_ib_idx].kpage[0] = kmalloc(PAGE_SIZE, GFP_KERNEL);
p->chunks[p->chunk_ib_idx].kpage[1] = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (p->chunks[p->chunk_ib_idx].kpage[0] == NULL ||
@@ -583,7 +583,8 @@ static int radeon_cs_update_pages(struct radeon_cs_parser *p, int pg_idx)
struct radeon_cs_chunk *ibc = &p->chunks[p->chunk_ib_idx];
int i;
int size = PAGE_SIZE;
- bool copy1 = (p->rdev->flags & RADEON_IS_AGP) ? false : true;
+ bool copy1 = (p->rdev && (p->rdev->flags & RADEON_IS_AGP)) ?
+ false : true;
for (i = ibc->last_copied_page + 1; i < pg_idx; i++) {
if (DRM_COPY_FROM_USER(p->ib.ptr + (i * (PAGE_SIZE/4)),
--
1.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] drm/radeon: fix a bogus kfree
2013-01-07 23:21 fix for crashes provoked by UMS mode Ilija Hadzic
2013-01-07 23:21 ` [PATCH 1/3] drm/radeon: fix NULL pointer dereference in " Ilija Hadzic
@ 2013-01-07 23:21 ` Ilija Hadzic
2013-01-07 23:21 ` [PATCH 3/3] drm/radeon: fix error path in kpage allocation Ilija Hadzic
2013-01-08 13:56 ` fix for crashes provoked by UMS mode Alex Deucher
3 siblings, 0 replies; 5+ messages in thread
From: Ilija Hadzic @ 2013-01-07 23:21 UTC (permalink / raw)
To: dri-devel
parser->chunks[.].kpage[.] is not always kmalloc-ed
by the parser initialization, so parser_fini should
not try to kfree it if it didn't allocate it.
This patch fixes a kernel oops that can be provoked
in UMS mode.
Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
---
drivers/gpu/drm/radeon/r600_cs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c
index 9ea13d0..f8adb01 100644
--- a/drivers/gpu/drm/radeon/r600_cs.c
+++ b/drivers/gpu/drm/radeon/r600_cs.c
@@ -2476,8 +2476,10 @@ static void r600_cs_parser_fini(struct radeon_cs_parser *parser, int error)
kfree(parser->relocs);
for (i = 0; i < parser->nchunks; i++) {
kfree(parser->chunks[i].kdata);
- kfree(parser->chunks[i].kpage[0]);
- kfree(parser->chunks[i].kpage[1]);
+ if (parser->rdev && (parser->rdev->flags & RADEON_IS_AGP)) {
+ kfree(parser->chunks[i].kpage[0]);
+ kfree(parser->chunks[i].kpage[1]);
+ }
}
kfree(parser->chunks);
kfree(parser->chunks_array);
--
1.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] drm/radeon: fix error path in kpage allocation
2013-01-07 23:21 fix for crashes provoked by UMS mode Ilija Hadzic
2013-01-07 23:21 ` [PATCH 1/3] drm/radeon: fix NULL pointer dereference in " Ilija Hadzic
2013-01-07 23:21 ` [PATCH 2/3] drm/radeon: fix a bogus kfree Ilija Hadzic
@ 2013-01-07 23:21 ` Ilija Hadzic
2013-01-08 13:56 ` fix for crashes provoked by UMS mode Alex Deucher
3 siblings, 0 replies; 5+ messages in thread
From: Ilija Hadzic @ 2013-01-07 23:21 UTC (permalink / raw)
To: dri-devel
Index into chunks[] array doesn't look right.
Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
---
drivers/gpu/drm/radeon/radeon_cs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 45151c4..469661f 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -284,8 +284,8 @@ int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data)
p->chunks[p->chunk_ib_idx].kpage[1] = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (p->chunks[p->chunk_ib_idx].kpage[0] == NULL ||
p->chunks[p->chunk_ib_idx].kpage[1] == NULL) {
- kfree(p->chunks[i].kpage[0]);
- kfree(p->chunks[i].kpage[1]);
+ kfree(p->chunks[p->chunk_ib_idx].kpage[0]);
+ kfree(p->chunks[p->chunk_ib_idx].kpage[1]);
return -ENOMEM;
}
}
--
1.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: fix for crashes provoked by UMS mode
2013-01-07 23:21 fix for crashes provoked by UMS mode Ilija Hadzic
` (2 preceding siblings ...)
2013-01-07 23:21 ` [PATCH 3/3] drm/radeon: fix error path in kpage allocation Ilija Hadzic
@ 2013-01-08 13:56 ` Alex Deucher
3 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2013-01-08 13:56 UTC (permalink / raw)
To: Ilija Hadzic; +Cc: dri-devel
On Mon, Jan 7, 2013 at 6:21 PM, Ilija Hadzic
<ihadzic@research.bell-labs.com> wrote:
> At Dave's request I ran some regression tests on my CS-refactoring
> patches [1] against old UMS userspace. The tests have revealed
> that the current kernel can be provoked into crashing in UMS mode
> (and the problem is unrelated to refactoring of CS code; it has
> been here before).
>
> The following patches will fix the problem that I discovered
> while testing (and they should probably go to drm-fixes branch).
> First two patches are the fix for the acute problem, while
> the third patch is a fix for an incidental finding uncovered
> while debugging the problem.
I've applied the series to my -fixes tree.
Thanks!
Alex
>
>
> [1] http://lists.freedesktop.org/archives/dri-devel/2013-January/032814.html
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-08 13:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 23:21 fix for crashes provoked by UMS mode Ilija Hadzic
2013-01-07 23:21 ` [PATCH 1/3] drm/radeon: fix NULL pointer dereference in " Ilija Hadzic
2013-01-07 23:21 ` [PATCH 2/3] drm/radeon: fix a bogus kfree Ilija Hadzic
2013-01-07 23:21 ` [PATCH 3/3] drm/radeon: fix error path in kpage allocation Ilija Hadzic
2013-01-08 13:56 ` fix for crashes provoked by UMS mode Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).