lkml.org 
[lkml]   [2019]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: linux-next 20190611: objtool warning
From
Date
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 */
>

\
 
 \ /
  Last update: 2019-06-12 07:10    [W:0.034 / U:108.484 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site