public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
* linux-next 20190611: objtool warning
@ 2019-06-12  1:59 Randy Dunlap
  2019-06-12  2:52 ` Josh Poimboeuf
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2019-06-12  1:59 UTC (permalink / raw)
  To: linux-next@vger•kernel.org, LKML, Josh Poimboeuf, Peter Zijlstra

Hi,

New warning AFAIK:

drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0x11f: sibling call from callable instruction with modified stack frame


> gcc --version
gcc (SUSE Linux) 7.4.1 20190424 [gcc-7-branch revision 270538]


-- 
~Randy

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

* Re: linux-next 20190611: objtool warning
  2019-06-12  1:59 linux-next 20190611: objtool warning Randy Dunlap
@ 2019-06-12  2:52 ` Josh Poimboeuf
  2019-06-12  3:17   ` Randy Dunlap
  2019-06-12  5:09   ` Guenter Roeck
  0 siblings, 2 replies; 4+ messages in thread
From: Josh Poimboeuf @ 2019-06-12  2:52 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: linux-next@vger•kernel.org, LKML, Peter Zijlstra, Masahiro Yamada,
	Guenter Roeck, Jean Delvare

On Tue, Jun 11, 2019 at 06:59:22PM -0700, Randy Dunlap wrote:
> Hi,
> 
> New warning AFAIK:
> 
> drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0x11f: sibling call from callable instruction with modified stack frame

I'm getting a different warning:

  drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0xb6: can't find jump dest instruction at .text+0x93a

But I bet the root cause is the same.

This fixes it for me:

From: Josh Poimboeuf <jpoimboe@redhat•com>
Subject: [PATCH] hwmon/smsc47m1: Fix objtool warning caused by undefined behavior

Objtool is reporting the following warning:

  drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0xb6: can't find jump dest instruction at .text+0x93a

It's apparently caused by

  2cf6745e69d1 ("hwmon: (smsc47m1) fix (suspicious) outside array bounds warnings")

which is somehow convincing GCC to add a jump past the end of the
function:

  793:   45 85 ed                test   %r13d,%r13d
  796:   0f 88 9e 01 00 00       js     93a <fan_div_store+0x25a>
  ...
  930:   e9 5e fe ff ff          jmpq   793 <fan_div_store+0xb3>
  935:   e8 00 00 00 00          callq  93a <fan_div_store+0x25a>
			936: R_X86_64_PLT32     __stack_chk_fail-0x4
  <function end>

I suppose this falls under the category of undefined behavior, so we
probably can't call it a GCC bug.  But if the value of "nr" were out of
range somehow then it would start executing random code.  Use a runtime
BUG() assertion to avoid undefined behavior.

Fixes: 2cf6745e69d1 ("hwmon: (smsc47m1) fix (suspicious) outside array bounds warnings")
Reported-by: Randy Dunlap <rdunlap@infradead•org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat•com>
---
 drivers/hwmon/smsc47m1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 6d366c9cb906..b637836b58a1 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -352,7 +352,7 @@ static ssize_t fan_div_store(struct device *dev,
 		smsc47m1_write_value(data, SMSC47M2_REG_FANDIV3, tmp);
 		break;
 	default:
-		unreachable();
+		BUG();
 	}
 
 	/* Preserve fan min */
-- 
2.20.1


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

* Re: linux-next 20190611: objtool warning
  2019-06-12  2:52 ` Josh Poimboeuf
@ 2019-06-12  3:17   ` Randy Dunlap
  2019-06-12  5:09   ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2019-06-12  3:17 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: linux-next@vger•kernel.org, LKML, Peter Zijlstra, Masahiro Yamada,
	Guenter Roeck, Jean Delvare

On 6/11/19 7:52 PM, Josh Poimboeuf wrote:
> On Tue, Jun 11, 2019 at 06:59:22PM -0700, Randy Dunlap wrote:
>> Hi,
>>
>> New warning AFAIK:
>>
>> drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0x11f: sibling call from callable instruction with modified stack frame
> 
> I'm getting a different warning:
> 
>   drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0xb6: can't find jump dest instruction at .text+0x93a
> 
> But I bet the root cause is the same.
> 
> This fixes it for me:
> 
> From: Josh Poimboeuf <jpoimboe@redhat•com>
> Subject: [PATCH] hwmon/smsc47m1: Fix objtool warning caused by undefined behavior
> 
> Objtool is reporting the following warning:
> 
>   drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0xb6: can't find jump dest instruction at .text+0x93a
> 
> It's apparently caused by
> 
>   2cf6745e69d1 ("hwmon: (smsc47m1) fix (suspicious) outside array bounds warnings")
> 
> which is somehow convincing GCC to add a jump past the end of the
> function:
> 
>   793:   45 85 ed                test   %r13d,%r13d
>   796:   0f 88 9e 01 00 00       js     93a <fan_div_store+0x25a>
>   ...
>   930:   e9 5e fe ff ff          jmpq   793 <fan_div_store+0xb3>
>   935:   e8 00 00 00 00          callq  93a <fan_div_store+0x25a>
> 			936: R_X86_64_PLT32     __stack_chk_fail-0x4
>   <function end>
> 
> I suppose this falls under the category of undefined behavior, so we
> probably can't call it a GCC bug.  But if the value of "nr" were out of
> range somehow then it would start executing random code.  Use a runtime
> BUG() assertion to avoid undefined behavior.
> 
> Fixes: 2cf6745e69d1 ("hwmon: (smsc47m1) fix (suspicious) outside array bounds warnings")
> Reported-by: Randy Dunlap <rdunlap@infradead•org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat•com>

Yes, that works for me.  Thanks.

Acked-by: Randy Dunlap <rdunlap@infradead•org>

> ---
>  drivers/hwmon/smsc47m1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
> index 6d366c9cb906..b637836b58a1 100644
> --- a/drivers/hwmon/smsc47m1.c
> +++ b/drivers/hwmon/smsc47m1.c
> @@ -352,7 +352,7 @@ static ssize_t fan_div_store(struct device *dev,
>  		smsc47m1_write_value(data, SMSC47M2_REG_FANDIV3, tmp);
>  		break;
>  	default:
> -		unreachable();
> +		BUG();
>  	}
>  
>  	/* Preserve fan min */
> 


-- 
~Randy

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

* Re: linux-next 20190611: objtool warning
  2019-06-12  2:52 ` Josh Poimboeuf
  2019-06-12  3:17   ` Randy Dunlap
@ 2019-06-12  5:09   ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2019-06-12  5:09 UTC (permalink / raw)
  To: Josh Poimboeuf, Randy Dunlap
  Cc: linux-next@vger•kernel.org, LKML, Peter Zijlstra, Masahiro Yamada,
	Jean Delvare

On 6/11/19 7:52 PM, Josh Poimboeuf wrote:
> On Tue, Jun 11, 2019 at 06:59:22PM -0700, Randy Dunlap wrote:
>> Hi,
>>
>> New warning AFAIK:
>>
>> drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0x11f: sibling call from callable instruction with modified stack frame
> 
> I'm getting a different warning:
> 
>    drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0xb6: can't find jump dest instruction at .text+0x93a
> 
> But I bet the root cause is the same.
> 
> This fixes it for me:
> 
> From: Josh Poimboeuf <jpoimboe@redhat•com>
> Subject: [PATCH] hwmon/smsc47m1: Fix objtool warning caused by undefined behavior
> 
> Objtool is reporting the following warning:
> 
>    drivers/hwmon/smsc47m1.o: warning: objtool: fan_div_store()+0xb6: can't find jump dest instruction at .text+0x93a
> 
> It's apparently caused by
> 
>    2cf6745e69d1 ("hwmon: (smsc47m1) fix (suspicious) outside array bounds warnings")
> 
> which is somehow convincing GCC to add a jump past the end of the
> function:
> 
>    793:   45 85 ed                test   %r13d,%r13d
>    796:   0f 88 9e 01 00 00       js     93a <fan_div_store+0x25a>
>    ...
>    930:   e9 5e fe ff ff          jmpq   793 <fan_div_store+0xb3>
>    935:   e8 00 00 00 00          callq  93a <fan_div_store+0x25a>
> 			936: R_X86_64_PLT32     __stack_chk_fail-0x4
>    <function end>
> 
> I suppose this falls under the category of undefined behavior, so we
> probably can't call it a GCC bug.  But if the value of "nr" were out of
> range somehow then it would start executing random code.  Use a runtime
> BUG() assertion to avoid undefined behavior.
> 
> Fixes: 2cf6745e69d1 ("hwmon: (smsc47m1) fix (suspicious) outside array bounds warnings")
> Reported-by: Randy Dunlap <rdunlap@infradead•org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat•com>
> ---
>   drivers/hwmon/smsc47m1.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
> index 6d366c9cb906..b637836b58a1 100644
> --- a/drivers/hwmon/smsc47m1.c
> +++ b/drivers/hwmon/smsc47m1.c
> @@ -352,7 +352,7 @@ static ssize_t fan_div_store(struct device *dev,
>   		smsc47m1_write_value(data, SMSC47M2_REG_FANDIV3, tmp);
>   		break;
>   	default:
> -		unreachable();
> +		BUG();

Sigh. And I wanted to avoid BUG() because this is all just to make
the compiler happy to start with. Oh well. I updated the offending
patch to use BUG().

Guenter

>   	}
>   
>   	/* Preserve fan min */
> 


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

end of thread, other threads:[~2019-06-12  5:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-12  1:59 linux-next 20190611: objtool warning Randy Dunlap
2019-06-12  2:52 ` Josh Poimboeuf
2019-06-12  3:17   ` Randy Dunlap
2019-06-12  5:09   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox