perf: Treat attr.config as u64 in perf_swevent_init()
Preetham Chandru R [Wed, 15 May 2013 11:31:46 +0000 (16:31 +0530)]
Trinity discovered that we fail to check all 64 bits of
attr.config passed by user space, resulting to out-of-bounds
access of the perf_swevent_enabled array in
sw_perf_event_destroy().

Introduced in commit b0a873ebb ("perf: Register PMU
implementations").

Bug 1289245

Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
Signed-off-by: Preetham Chandru R <pchandru@nvidia.com>
(cherry picked from commit 8176cced706b5e5d15887584150764894e94e02f)
Change-Id: Idde0330d7430f2ba1645f4dfed063c5df9bbb44a
Reviewed-on: http://git-master/r/228851
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Kiran Adduri <kadduri@nvidia.com>
Reviewed-by: Bo Yan <byan@nvidia.com>

kernel/events/core.c

index 0f85778..25a977a 100644 (file)
@@ -5072,7 +5072,7 @@ static void sw_perf_event_destroy(struct perf_event *event)
 
 static int perf_swevent_init(struct perf_event *event)
 {
-       int event_id = event->attr.config;
+       u64 event_id = event->attr.config;
 
        if (event->attr.type != PERF_TYPE_SOFTWARE)
                return -ENOENT;