[patch 15/45] perf_counter: Fix buffer overflow in perf_copy_attr()

From: Greg KH
Date: Wed Sep 16 2009 - 18:45:23 EST


2.6.31-stable review patch. If anyone has any objections, please let us know.

------------------
From: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxxxxx>

commit b3e62e35058fc744ac794611f4e79bcd1c5a4b83 upstream.

If we pass a big size data over perf_counter_open() syscall,
the kernel will copy this data to a small buffer, it will
cause kernel crash.

This bug makes the kernel unsafe and non-root local user can
trigger it.

Signed-off-by: Xiao Guangrong <xiaoguangrong@xxxxxxxxxxxxxx>
Acked-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Acked-by: Paul Mackerras <paulus@xxxxxxxxx>
LKML-Reference: <4AAF37D4.5010706@xxxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
kernel/perf_counter.c | 1 +
1 file changed, 1 insertion(+)

--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -4171,6 +4171,7 @@ static int perf_copy_attr(struct perf_co
if (val)
goto err_size;
}
+ size = sizeof(*attr);
}

ret = copy_from_user(attr, uattr, size);


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/