misc: tegra-profiler: Do not expose kernel IPs
Igor Nabirushkin [Mon, 19 Aug 2013 12:32:24 +0000 (16:32 +0400)]
In Tegra Profiler misc driver, do not expose kernel-space IPs
for security purposes (for non-root users).

Bug 1312406
Bug 1349673

Change-Id: Ie3b89a555296359c8578ec39a00161d3e63a34ad
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/263320
(cherry picked from commit 935daea80d24f621a9328642d025762af26ffb55)
Reviewed-on: http://git-master/r/264803
GVS: Gerrit_Virtual_Submit
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Daniel Horowitz <dhorowitz@nvidia.com>
Reviewed-by: Bo Yan <byan@nvidia.com>

drivers/misc/tegra-profiler/hrt.c
drivers/misc/tegra-profiler/main.c
drivers/misc/tegra-profiler/quadd.h
drivers/misc/tegra-profiler/version.h

index 56d8b84..6a9c39f 100644 (file)
@@ -240,6 +240,7 @@ static void read_source(struct quadd_event_source_interface *source,
        unsigned int extra_length = 0, callchain_nr = 0;
        struct quadd_cpu_context *cpu_ctx = this_cpu_ptr(hrt.cpu_ctx);
        struct quadd_callchain *callchain_data = &cpu_ctx->callchain_data;
+       struct quadd_ctx *quadd_ctx = hrt.quadd_ctx;
 
        if (!source)
                return;
@@ -269,6 +270,11 @@ static void read_source(struct quadd_event_source_interface *source,
                record_data.cpu_mode = user_mode(regs) ?
                        QUADD_CPU_MODE_USER : QUADD_CPU_MODE_KERNEL;
 
+               /* For security reasons, hide IPs from the kernel space. */
+               if (record_data.cpu_mode == QUADD_CPU_MODE_KERNEL &&
+                   !quadd_ctx->collect_kernel_ips)
+                       record_data.sample.ip = 0;
+
                record_data.sample.callchain_nr = callchain_nr;
 
                if (pid > 0) {
index 71b9554..dc46c6d 100644 (file)
@@ -170,6 +170,9 @@ static int set_parameters(struct quadd_parameters *param, uid_t *debug_app_uid)
                        *debug_app_uid = uid;
                        pr_info("debug_app_uid: %u\n", uid);
                }
+               ctx.collect_kernel_ips = 0;
+       } else {
+               ctx.collect_kernel_ips = 1;
        }
 
        for (i = 0; i < param->nr_pids; i++)
index 743482d..4bcbb81 100644 (file)
@@ -57,6 +57,8 @@ struct quadd_ctx {
        struct quadd_mmap_ctx *mmap;
 
        atomic_t started;
+
+       int collect_kernel_ips;
 };
 
 #endif /* __QUADD_H */
index acc278b..efaa135 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.26"
+#define QUADD_MODULE_VERSION           "1.27"
 #define QUADD_MODULE_BRANCH            "Blackrock2"
 
 #endif /* __QUADD_VERSION_H */