linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] objtool: Fix off-by-one in symbol_by_offset()
@ 2020-04-03 13:17 Julien Thierry
  2020-04-03 14:50 ` Josh Poimboeuf
  2020-04-06  9:11 ` Miroslav Benes
  0 siblings, 2 replies; 4+ messages in thread
From: Julien Thierry @ 2020-04-03 13:17 UTC (permalink / raw)
  To: linux-kernel; +Cc: jpoimboe, peterz, mbenes, Julien Thierry

Sometimes, WARN_FUNC() and other users of symbol_by_offset() will
associate the first instruction of a symbol with the symbol preceding
it.
This is because symbol->offset + symbol->len is already outside of the
symbol's range.

Signed-off-by: Julien Thierry <jthierry@redhat.com>
---
 tools/objtool/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 09ddc8f1def3..c4857fa3f1d1 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -105,7 +105,7 @@ static int symbol_by_offset(const void *key, const struct rb_node *node)
 
 	if (*o < s->offset)
 		return -1;
-	if (*o > s->offset + s->len)
+	if (*o >= s->offset + s->len)
 		return 1;
 
 	return 0;
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] objtool: Fix off-by-one in symbol_by_offset()
  2020-04-03 13:17 [PATCH] objtool: Fix off-by-one in symbol_by_offset() Julien Thierry
@ 2020-04-03 14:50 ` Josh Poimboeuf
  2020-04-06  9:11 ` Miroslav Benes
  1 sibling, 0 replies; 4+ messages in thread
From: Josh Poimboeuf @ 2020-04-03 14:50 UTC (permalink / raw)
  To: Julien Thierry; +Cc: linux-kernel, peterz, mbenes

On Fri, Apr 03, 2020 at 02:17:30PM +0100, Julien Thierry wrote:
> Sometimes, WARN_FUNC() and other users of symbol_by_offset() will
> associate the first instruction of a symbol with the symbol preceding
> it.
> This is because symbol->offset + symbol->len is already outside of the
> symbol's range.
> 
> Signed-off-by: Julien Thierry <jthierry@redhat.com>
> ---
>  tools/objtool/elf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index 09ddc8f1def3..c4857fa3f1d1 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -105,7 +105,7 @@ static int symbol_by_offset(const void *key, const struct rb_node *node)
>  
>  	if (*o < s->offset)
>  		return -1;
> -	if (*o > s->offset + s->len)
> +	if (*o >= s->offset + s->len)
>  		return 1;
>  
>  	return 0;

Thanks - looks like this fixes 2a362ecc3ec9 ("objtool: Optimize
find_symbol_*() and read_symbols()").

-- 
Josh


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] objtool: Fix off-by-one in symbol_by_offset()
  2020-04-03 13:17 [PATCH] objtool: Fix off-by-one in symbol_by_offset() Julien Thierry
  2020-04-03 14:50 ` Josh Poimboeuf
@ 2020-04-06  9:11 ` Miroslav Benes
  1 sibling, 0 replies; 4+ messages in thread
From: Miroslav Benes @ 2020-04-06  9:11 UTC (permalink / raw)
  To: Julien Thierry; +Cc: linux-kernel, jpoimboe, peterz

On Fri, 3 Apr 2020, Julien Thierry wrote:

> Sometimes, WARN_FUNC() and other users of symbol_by_offset() will
> associate the first instruction of a symbol with the symbol preceding
> it.
> This is because symbol->offset + symbol->len is already outside of the
> symbol's range.
> 
> Signed-off-by: Julien Thierry <jthierry@redhat.com>

Reviewed-by: Miroslav Benes <mbenes@suse.cz>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] objtool: Fix off-by-one in symbol_by_offset()
@ 2020-04-14 12:53 Josh Poimboeuf
  0 siblings, 0 replies; 4+ messages in thread
From: Josh Poimboeuf @ 2020-04-14 12:53 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, Peter Zijlstra, Julien Thierry, Miroslav Benes

From: Julien Thierry <jthierry@redhat.com>

Sometimes, WARN_FUNC() and other users of symbol_by_offset() will
associate the first instruction of a symbol with the symbol preceding
it.  This is because symbol->offset + symbol->len is already outside of
the symbol's range.

Fixes: 2a362ecc3ec9 ("objtool: Optimize find_symbol_*() and read_symbols()")
Signed-off-by: Julien Thierry <jthierry@redhat.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 tools/objtool/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 09ddc8f1def3..c4857fa3f1d1 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -105,7 +105,7 @@ static int symbol_by_offset(const void *key, const struct rb_node *node)
 
 	if (*o < s->offset)
 		return -1;
-	if (*o > s->offset + s->len)
+	if (*o >= s->offset + s->len)
 		return 1;
 
 	return 0;
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-14 12:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 13:17 [PATCH] objtool: Fix off-by-one in symbol_by_offset() Julien Thierry
2020-04-03 14:50 ` Josh Poimboeuf
2020-04-06  9:11 ` Miroslav Benes
2020-04-14 12:53 Josh Poimboeuf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).