mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luis Henriques <luis.henriques@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Kapileshwar Singh <kapileshwar.singh@arm.com>,
	David Ahern <dsahern@gmail.com>,
	Javi Merino <javi.merino@arm.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Luis Henriques <luis.henriques@canonical.com>
Subject: [PATCH 3.16.y-ckt 067/104] tools lib traceevent: Fix string handling in heterogeneous arch environments
Date: Mon, 26 Oct 2015 13:42:49 +0000	[thread overview]
Message-ID: <1445867006-18048-68-git-send-email-luis.henriques@canonical.com> (raw)
In-Reply-To: <1445867006-18048-1-git-send-email-luis.henriques@canonical.com>

3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kapileshwar Singh <kapileshwar.singh@arm.com>

commit c2e4b24ff848bb180f9b9cd873a38327cd219ad2 upstream.

When a trace recorded on a 32-bit device is processed with a 64-bit
binary, the higher 32-bits of the address need to ignored.

The lack of this results in the output of the 64-bit pointer
value to the trace as the 32-bit address lookup fails in find_printk().

Before:

  burn-1778  [003]   548.600305: bputs:   0xc0046db2s: 2cec5c058d98c

After:

  burn-1778  [003]   548.600305: bputs:   0xc0046db2s: RT throttling activated

The problem occurs in PRINT_FIELD when the field is recognized as a
pointer to a string (of the type const char *)

Heterogeneous architectures cases below can arise and should be handled:

* Traces recorded using 32-bit addresses processed on a 64-bit machine
* Traces recorded using 64-bit addresses processed on a 32-bit machine

Reported-by: Juri Lelli <juri.lelli@arm.com>
Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1442928123-13824-1-git-send-email-kapileshwar.singh@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 tools/lib/traceevent/event-parse.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 93825a17dcce..7959d66e1048 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3658,7 +3658,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 	struct format_field *field;
 	struct printk_map *printk;
 	unsigned long long val, fval;
-	unsigned long addr;
+	unsigned long long addr;
 	char *str;
 	unsigned char *hex;
 	int print;
@@ -3691,13 +3691,30 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 		 */
 		if (!(field->flags & FIELD_IS_ARRAY) &&
 		    field->size == pevent->long_size) {
-			addr = *(unsigned long *)(data + field->offset);
+
+			/* Handle heterogeneous recording and processing
+			 * architectures
+			 *
+			 * CASE I:
+			 * Traces recorded on 32-bit devices (32-bit
+			 * addressing) and processed on 64-bit devices:
+			 * In this case, only 32 bits should be read.
+			 *
+			 * CASE II:
+			 * Traces recorded on 64 bit devices and processed
+			 * on 32-bit devices:
+			 * In this case, 64 bits must be read.
+			 */
+			addr = (pevent->long_size == 8) ?
+				*(unsigned long long *)(data + field->offset) :
+				(unsigned long long)*(unsigned int *)(data + field->offset);
+
 			/* Check if it matches a print format */
 			printk = find_printk(pevent, addr);
 			if (printk)
 				trace_seq_puts(s, printk->printk);
 			else
-				trace_seq_printf(s, "%lx", addr);
+				trace_seq_printf(s, "%llx", addr);
 			break;
 		}
 		str = malloc(len + 1);

  parent reply	other threads:[~2015-10-26 13:57 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26 13:41 [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 002/104] CIFS: fix type confusion in copy offload ioctl Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 003/104] hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 004/104] x86/apic: Serialize LVTT and TSC_DEADLINE writes Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 005/104] arm64: head.S: initialise mdcr_el2 in el2_setup Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 006/104] kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 007/104] kvm: factor out core eventfd assign/deassign logic Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 008/104] kvm: fix double free for fast mmio eventfd Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 009/104] kvm: fix zero length mmio searching Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 010/104] ARM: fix Thumb2 signal handling when ARMv6 is enabled Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 011/104] powerpc/boot: Specify ABI v2 when building an LE boot wrapper Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 012/104] powerpc/mm: Recompute hash value after a failed update Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 013/104] x86/platform: Fix Geode LX timekeeping in the generic x86 build Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 014/104] arm64: compat: fix vfp save/restore across signal handlers in big-endian Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 015/104] arm64: errata: add module build workaround for erratum #843419 Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 016/104] arm64: KVM: Disable virtual timer even if the guest is not using it Luis Henriques
2015-10-26 13:41 ` [PATCH 3.16.y-ckt 017/104] arm: " Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 018/104] hp-wmi: Add missing __init annotations to initialization code Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 019/104] hp-wmi: limit hotkey enable Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 020/104] zram: fix possible use after free in zcomp_create() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 021/104] perf header: Fixup reading of HEADER_NRCPUS feature Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 022/104] dcache: Handle escaped paths in prepend_path Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 023/104] vfs: Test for and handle paths that are unreachable from their mnt_root Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 024/104] spi: spi-pxa2xx: Check status register to determine if SSSR_TINT is disabled Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 025/104] spi: Fix documentation of spi_alloc_master() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 026/104] USB: option: add ZTE PIDs Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 027/104] drm/vmwgfx: Fix up user_dmabuf refcounting Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 028/104] ARM: dts: omap3-beagle: make i2c3, ddc and tfp410 gpio work again Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 029/104] Btrfs: fix read corruption of compressed and shared extents Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 030/104] btrfs: skip waiting on ordered range for special files Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 031/104] usb: chipidea: udc: using the correct stall implementation Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 032/104] net: mvneta: fix DMA buffer unmapping in mvneta_rx() Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 033/104] iser-target: remove command with state ISTATE_REMOVE Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 034/104] staging: ion: fix corruption of ion_import_dma_buf Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 035/104] KVM: x86: trap AMD MSRs for the TSeg base and mask Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 036/104] usb: Use the USB_SS_MULT() macro to get the burst multiplier Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 037/104] xhci: give command abortion one more chance before killing xhci Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 038/104] usb: xhci: Clear XHCI_STATE_DYING on start Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 039/104] usb: xhci: Allow usb_add/remove_hcd() to be called repeatedly Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 040/104] xhci: change xhci 1.0 only restrictions to support xhci 1.1 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 041/104] xhci-mem: Use setup_timer Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 042/104] xhci: init command timeout timer earlier to avoid deleting it uninitialized Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 043/104] spi: xtensa-xtfpga: fix register endianness Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 044/104] disabling oplocks/leases via module parm enable_oplocks broken for SMB3 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 045/104] cifs: use server timestamp for ntlmv2 authentication Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 046/104] x86/paravirt: Replace the paravirt nop with a bona fide empty function Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 047/104] x86/nmi/64: Fix a paravirt stack-clobbering bug in the NMI code Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 048/104] ASoC: pxa: pxa2xx-ac97: fix dma requestor lines Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 049/104] ocfs2/dlm: fix deadlock when dispatch assert master Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 050/104] drm/i915/bios: handle MIPI Sequence Block v3+ gracefully Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 051/104] USB: whiteheat: fix potential null-deref at probe Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 052/104] drm/qxl: only report first monitor as connected if we have no state Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 053/104] PCI: Fix devfn for VPD access through function 0 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 054/104] PCI: Use function 0 VPD for identical functions, regular VPD for others Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 055/104] netfilter: nft_compat: skip family comparison in case of NFPROTO_UNSPEC Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 056/104] ASoC: fix broken pxa SoC support Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 057/104] ARM: dts: omap5-uevm.dts: fix i2c5 pinctrl offsets Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 058/104] vxlan: set needed headroom correctly Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 059/104] Revert "ARM: orion5x: fix legacy orion5x IRQ numbers" Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 060/104] jbd2: avoid infinite loop when destroying aborted journal Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 061/104] asix: Don't reset PHY on if_up for ASIX 88772 Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 062/104] asix: Do full reset during ax88772_bind Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 063/104] fib_rules: Fix dump_rules() not to exit early Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 064/104] net/xen-netfront: only napi_synchronize() if running Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 065/104] cpufreq: intel_pstate: Remove unnecessary type casting in div_s64() call Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 066/104] intel_pstate: Fix overflow in busy_scaled due to long delay Luis Henriques
2015-10-26 13:42 ` Luis Henriques [this message]
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 068/104] perf tools: Fix copying of /proc/kcore Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 069/104] m68k: Define asmlinkage_protect Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 070/104] UBI: Validate data_size Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 071/104] UBI: return ENOSPC if no enough space available Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 072/104] drm/radeon: Restore LCD backlight level on resume (>= R5xx) Luis Henriques
2015-10-27  2:10   ` Michel Dänzer
2015-10-28 10:45     ` Luis Henriques
2015-11-02  7:52       ` Michel Dänzer
2015-11-11 15:43         ` Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 073/104] MIPS: dma-default: Fix 32-bit fall back to GFP_DMA Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 074/104] MIPS: CPS: Stop dangling delay slot from has_mt Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 075/104] MIPS: CPS: Don't include MT code in non-MT kernels Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 076/104] MIPS: CPS: #ifdef on CONFIG_MIPS_MT_SMP rather than CONFIG_MIPS_MT Luis Henriques
2015-10-26 13:42 ` [PATCH 3.16.y-ckt 077/104] Initialize msg/shm IPC objects before doing ipc_addid() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 078/104] drm/qxl: recreate the primary surface when the bo is not primary Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 079/104] genirq: Fix race in register_irq_proc() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 080/104] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 081/104] Use WARN_ON_ONCE for missing X86_FEATURE_NRIPS Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 082/104] mm: hugetlbfs: skip shared VMAs when unmapping private pages to satisfy a fault Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 083/104] x86/mm: Set NX on gap between __ex_table and rodata Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 084/104] clocksource: Fix abs() usage w/ 64bit values Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 085/104] dmaengine: dw: properly read DWC_PARAMS register Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 086/104] mm/slab: fix unexpected index mapping result of kmalloc_size(INDEX_NODE+1) Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 087/104] drm/vmwgfx: Fix kernel NULL pointer dereference on older hardware Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 088/104] fs: if a coredump already exists, unlink and recreate with O_EXCL Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 089/104] sctp: donot reset the overall_error_count in SHUTDOWN_RECEIVE state Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 090/104] ipc/sem.c: fully initialize sem_array before making it visible Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 091/104] drivers: usb :fsl: Implement Workaround for USB Erratum A007792 Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 092/104] drivers: usb: fsl: Workaround for USB erratum-A005275 Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 093/104] l2tp: protect tunnel->del_work by ref_count Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 094/104] af_unix: Convert the unix_sk macro to an inline function for type safety Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 095/104] af_unix: return data from multiple SKBs on recv() with MSG_PEEK flag Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 096/104] net/unix: fix logic about sk_peek_offset Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 097/104] skbuff: Fix skb checksum flag on skb pull Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 098/104] skbuff: Fix skb checksum partial check Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 099/104] net: add pfmemalloc check in sk_add_backlog() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 100/104] ppp: don't override sk->sk_state in pppoe_flush_dev() Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 101/104] ethtool: Use kcalloc instead of kmalloc for ethtool_get_strings Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 102/104] ovs: do not allocate memory from offline numa node Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 103/104] netlink: Trim skb to alloc size to avoid MSG_TRUNC Luis Henriques
2015-10-26 13:43 ` [PATCH 3.16.y-ckt 104/104] net: add length argument to skb_copy_and_csum_datagram_iovec Luis Henriques
2015-10-26 19:02 ` [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques
2015-10-28 16:51   ` Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 105/107] KEYS: Fix race between key destruction and finding a keyring by name Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 106/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring Luis Henriques
2015-10-26 19:05 ` [PATCH 3.16.y-ckt 107/107] KEYS: Don't permit request_key() to construct a new keyring Luis Henriques
2015-10-28 16:52 ` [PATCH 3.16.y-ckt 108/108] Btrfs: update fix for read corruption of compressed and shared extents Luis Henriques

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445867006-18048-68-git-send-email-luis.henriques@canonical.com \
    --to=luis.henriques@canonical.com \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=javi.merino@arm.com \
    --cc=jolsa@kernel.org \
    --cc=kapileshwar.singh@arm.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®