misc: tegra_profiler: fix dwarf unwinding
Igor Nabirushkin [Wed, 30 Nov 2016 09:29:26 +0000 (13:29 +0400)]
Problem is that on systems with a 64-bit kernel and 32 bit userspace,
read_user_data function reads 32-bit value into 64-bit uninitialized
variable, so high half of the variable might be dirty.
Use 32-bit temporary variable in such cases.

Bug 1846986

Change-Id: I2b024a00da536ad95e12e354597bde9811ca7998
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/1262234
(cherry picked from commit d58031aa0cb381ecc5a8c11d08b81a141c435244)
Reviewed-on: http://git-master/r/1274707
(cherry picked from commit 8b990d05eb94c305642dc2fbd8f79bc00bce0308)

drivers/misc/tegra-profiler/dwarf_unwind.c

index 4ec5238..fabfa2f 100644 (file)
@@ -1890,12 +1890,17 @@ unwind_frame(struct ex_region_info *ri,
                        if (!validate_stack_addr(addr, vma_sp, user_reg_size))
                                return -QUADD_URC_SP_INCORRECT;
 
-                       if (mode == DW_MODE_ARM32)
-                               err = read_user_data(&val, (void __user *)addr,
+                       if (mode == DW_MODE_ARM32) {
+                               u32 val32;
+
+                               err = read_user_data(&val32,
+                                                    (void __user *)addr,
                                                     sizeof(u32));
-                       else
+                               val = val32;
+                       } else {
                                err = read_user_data(&val, (void __user *)addr,
                                                     sizeof(unsigned long));
+                       }
 
                        if (err < 0)
                                return err;