Skip to contentSkip to conversation

Patch "perf annotate: Fix objdump comment parsing for Intel mov dissassembly" has been added to the 4.15-stable tree

PATCH [email protected] 1 participant 1 message Mar 16, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

perf annotate: Fix objdump comment parsing for Intel mov dissassembly

to the 4.15-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
perf-annotate-fix-objdump-comment-parsing-for-intel-mov-dissassembly.patch
and it can be found in the queue-4.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Fri Mar 16 15:11:07 CET 2018

From: Thomas Richter <[email protected]>
Date: Tue, 28 Nov 2017 08:56:32 +0100
Subject: perf annotate: Fix objdump comment parsing for Intel mov dissassembly

From: Thomas Richter <[email protected]>

[ Upstream commit 35a8a148d8c1ee9e5ae18f9565a880490f816f89 ]

The command 'perf annotate' parses the output of objdump and also investigates the comments produced by objdump. For example the output of objdump produces (on x86):

23eee: 4c 8b 3d 13 01 21 00 mov 0x210113(%rip),%r15

                                # 234008 <stderr@@GLIBC_2.2.5+0x9a8>

and the function mov__parse() is called to investigate the complete line. Mov__parse() breaks this line into several parts and finally calls function comment__symbol() to parse the data after the comment character '#'. Comment__symbol() expects a hexadecimal address followed by a symbol in '<' and '>' brackets.

However the 2nd parameter given to function comment__symbol() always points to the comment character '#'. The address parsing always returns 0 because the character '#' is not a digit and strtoull() fails without being noticed.

Fix this by advancing the second parameter to function comment__symbol() by one byte before invocation and add an error check after strtoull() has been called.

---
 tools/perf/util/annotate.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tools/perf/util/annotate.c +5 -3
@@ -322,6 +322,8 @@ static int comment__symbol(char *raw, ch
 		return 0;
 
 	*addrp = strtoull(comment, &endptr, 16);
+	if (endptr == comment)
+		return 0;
 	name = strchr(endptr, '<');
 	if (name == NULL)
 		return -1;
@@ -435,8 +437,8 @@ static int mov__parse(struct arch *arch,
 		return 0;
 
 	comment = ltrim(comment);
-	comment__symbol(ops->source.raw, comment, &ops->source.addr, &ops->source.name);
-	comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name);
+	comment__symbol(ops->source.raw, comment + 1, &ops->source.addr, &ops->source.name);
+	comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name);
 
 	return 0;
 
@@ -480,7 +482,7 @@ static int dec__parse(struct arch *arch
 		return 0;
 
 	comment = ltrim(comment);
-	comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name);
+	comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name);
 
 	return 0;
 }

Patches currently in stable-queue which might be from [email protected] are

queue-4.15/perf-annotate-fix-unnecessary-memory-allocation-for-s390x.patch queue-4.15/perf-annotate-fix-objdump-comment-parsing-for-intel-mov-dissassembly.patch