[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20110727003457.133ED2403FF@tassilo.jf.intel.com>
Date: Tue, 26 Jul 2011 17:34:57 -0700 (PDT)
From: Andi Kleen <andi@...stfloor.org>
To: segoon@...nwall.com, airlied@...hat.com, ak@...ux.intel.com,
linux-kernel@...r.kernel.org, stable@...nel.org,
tim.bird@...sony.com, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: [PATCH] [5/98] agp: fix arbitrary kernel memory writes
2.6.35-longterm review patch. If anyone has any objections, please let me know.
------------------
From: Vasiliy Kulikov <segoon@...nwall.com>
[ upstream commit 194b3da873fd334ef183806db751473512af29ce ]
pg_start is copied from userspace on AGPIOC_BIND and AGPIOC_UNBIND ioctl
cmds of agp_ioctl() and passed to agpioc_bind_wrap(). As said in the
comment, (pg_start + mem->page_count) may wrap in case of AGPIOC_BIND,
and it is not checked at all in case of AGPIOC_UNBIND. As a result, user
with sufficient privileges (usually "video" group) may generate either
local DoS or privilege escalation.
Signed-off-by: Vasiliy Kulikov <segoon@...nwall.com>
Signed-off-by: Dave Airlie <airlied@...hat.com>
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
Index: linux-2.6.35.y/drivers/char/agp/generic.c
===================================================================
--- linux-2.6.35.y.orig/drivers/char/agp/generic.c
+++ linux-2.6.35.y/drivers/char/agp/generic.c
@@ -1122,8 +1122,8 @@ int agp_generic_insert_memory(struct agp
return -EINVAL;
}
- /* AK: could wrap */
- if ((pg_start + mem->page_count) > num_entries)
+ if (((pg_start + mem->page_count) > num_entries) ||
+ ((pg_start + mem->page_count) < pg_start))
return -EINVAL;
j = pg_start;
@@ -1157,7 +1157,7 @@ int agp_generic_remove_memory(struct agp
{
size_t i;
struct agp_bridge_data *bridge;
- int mask_type;
+ int mask_type, num_entries;
bridge = mem->bridge;
if (!bridge)
@@ -1169,6 +1169,11 @@ int agp_generic_remove_memory(struct agp
if (type != mem->type)
return -EINVAL;
+ num_entries = agp_num_entries();
+ if (((pg_start + mem->page_count) > num_entries) ||
+ ((pg_start + mem->page_count) < pg_start))
+ return -EINVAL;
+
mask_type = bridge->driver->agp_type_to_mask_type(bridge, type);
if (mask_type != 0) {
/* The generic routines know nothing of memory types */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists