linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled
@ 2021-07-06 16:26 Guenter Roeck
  2021-07-24  0:58 ` Palmer Dabbelt
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2021-07-06 16:26 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: Palmer Dabbelt, Albert Ou, linux-riscv, linux-kernel,
	Guenter Roeck, Guo Ren

riscv uses the value of TSK_STACK_CANARY to set
stack-protector-guard-offset. With GCC_PLUGIN_RANDSTRUCT enabled, that
value is non-deterministic, and with riscv:allmodconfig often results
in build errors such as

cc1: error: '8120' is not a valid offset in '-mstack-protector-guard-offset='

Enable STACKPROTECTOR_PER_TASK only if GCC_PLUGIN_RANDSTRUCT is disabled
to fix the problem.

Fixes: fea2fed201ee5 ("riscv: Enable per-task stack canaries")
Cc: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 arch/riscv/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 469a70bd8da6..3afb84fa2190 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -486,6 +486,7 @@ config CC_HAVE_STACKPROTECTOR_TLS
 
 config STACKPROTECTOR_PER_TASK
 	def_bool y
+	depends on !GCC_PLUGIN_RANDSTRUCT
 	depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
 
 config PHYS_RAM_BASE_FIXED
-- 
2.25.1


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

* Re: [PATCH] riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled
  2021-07-06 16:26 [PATCH] riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled Guenter Roeck
@ 2021-07-24  0:58 ` Palmer Dabbelt
  2021-07-24  2:13   ` Guenter Roeck
  2021-08-04  5:14   ` Palmer Dabbelt
  0 siblings, 2 replies; 5+ messages in thread
From: Palmer Dabbelt @ 2021-07-24  0:58 UTC (permalink / raw)
  To: linux; +Cc: Paul Walmsley, aou, linux-riscv, linux-kernel, linux, guoren

On Tue, 06 Jul 2021 09:26:21 PDT (-0700), linux@roeck-us.net wrote:
> riscv uses the value of TSK_STACK_CANARY to set
> stack-protector-guard-offset. With GCC_PLUGIN_RANDSTRUCT enabled, that
> value is non-deterministic, and with riscv:allmodconfig often results
> in build errors such as
>
> cc1: error: '8120' is not a valid offset in '-mstack-protector-guard-offset='
>
> Enable STACKPROTECTOR_PER_TASK only if GCC_PLUGIN_RANDSTRUCT is disabled
> to fix the problem.
>
> Fixes: fea2fed201ee5 ("riscv: Enable per-task stack canaries")
> Cc: Guo Ren <guoren@linux.alibaba.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  arch/riscv/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 469a70bd8da6..3afb84fa2190 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -486,6 +486,7 @@ config CC_HAVE_STACKPROTECTOR_TLS
>
>  config STACKPROTECTOR_PER_TASK
>  	def_bool y
> +	depends on !GCC_PLUGIN_RANDSTRUCT
>  	depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
>
>  config PHYS_RAM_BASE_FIXED

Thanks, this is on fixes.  I do an allmodconfig build and haven't seen 
these failures, is there something special I need to do to get this 
working?  I know nothing about GCC plugins...

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

* Re: [PATCH] riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled
  2021-07-24  0:58 ` Palmer Dabbelt
@ 2021-07-24  2:13   ` Guenter Roeck
  2021-08-04  5:14   ` Palmer Dabbelt
  1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-07-24  2:13 UTC (permalink / raw)
  To: Palmer Dabbelt; +Cc: Paul Walmsley, aou, linux-riscv, linux-kernel, guoren

On 7/23/21 5:58 PM, Palmer Dabbelt wrote:
> On Tue, 06 Jul 2021 09:26:21 PDT (-0700), linux@roeck-us.net wrote:
>> riscv uses the value of TSK_STACK_CANARY to set
>> stack-protector-guard-offset. With GCC_PLUGIN_RANDSTRUCT enabled, that
>> value is non-deterministic, and with riscv:allmodconfig often results
>> in build errors such as
>>
>> cc1: error: '8120' is not a valid offset in '-mstack-protector-guard-offset='
>>
>> Enable STACKPROTECTOR_PER_TASK only if GCC_PLUGIN_RANDSTRUCT is disabled
>> to fix the problem.
>>
>> Fixes: fea2fed201ee5 ("riscv: Enable per-task stack canaries")
>> Cc: Guo Ren <guoren@linux.alibaba.com>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>  arch/riscv/Kconfig | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 469a70bd8da6..3afb84fa2190 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -486,6 +486,7 @@ config CC_HAVE_STACKPROTECTOR_TLS
>>
>>  config STACKPROTECTOR_PER_TASK
>>      def_bool y
>> +    depends on !GCC_PLUGIN_RANDSTRUCT
>>      depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
>>
>>  config PHYS_RAM_BASE_FIXED
> 
> Thanks, this is on fixes.  I do an allmodconfig build and haven't seen these failures, is there something special I need to do to get this working?  I know nothing about GCC plugins...

The problem is seen only randomly. It depends on the value
of TSK_STACK_CANARY in include/generated/asm-offsets.h.
That in turn depends on the location of stack_canary
in struct task_struct. You may have to try several times
from a clean tree to see the problem.

Guenter

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

* Re: [PATCH] riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled
  2021-07-24  0:58 ` Palmer Dabbelt
  2021-07-24  2:13   ` Guenter Roeck
@ 2021-08-04  5:14   ` Palmer Dabbelt
  2021-08-04  5:25     ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2021-08-04  5:14 UTC (permalink / raw)
  To: linux; +Cc: Paul Walmsley, aou, linux-riscv, linux-kernel, linux, guoren

On Fri, 23 Jul 2021 17:58:13 PDT (-0700), Palmer Dabbelt wrote:
> On Tue, 06 Jul 2021 09:26:21 PDT (-0700), linux@roeck-us.net wrote:
>> riscv uses the value of TSK_STACK_CANARY to set
>> stack-protector-guard-offset. With GCC_PLUGIN_RANDSTRUCT enabled, that
>> value is non-deterministic, and with riscv:allmodconfig often results
>> in build errors such as
>>
>> cc1: error: '8120' is not a valid offset in '-mstack-protector-guard-offset='
>>
>> Enable STACKPROTECTOR_PER_TASK only if GCC_PLUGIN_RANDSTRUCT is disabled
>> to fix the problem.
>>
>> Fixes: fea2fed201ee5 ("riscv: Enable per-task stack canaries")
>> Cc: Guo Ren <guoren@linux.alibaba.com>
>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> ---
>>  arch/riscv/Kconfig | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>> index 469a70bd8da6..3afb84fa2190 100644
>> --- a/arch/riscv/Kconfig
>> +++ b/arch/riscv/Kconfig
>> @@ -486,6 +486,7 @@ config CC_HAVE_STACKPROTECTOR_TLS
>>
>>  config STACKPROTECTOR_PER_TASK
>>  	def_bool y
>> +	depends on !GCC_PLUGIN_RANDSTRUCT
>>  	depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
>>
>>  config PHYS_RAM_BASE_FIXED
>
> Thanks, this is on fixes.  I do an allmodconfig build and haven't seen
> these failures, is there something special I need to do to get this
> working?  I know nothing about GCC plugins...

Sorry, looks like I screwed something up and I didn't actually merge 
this onto fixes.  Not sure what happened, but this time it should 
actually be on fixes.

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

* Re: [PATCH] riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled
  2021-08-04  5:14   ` Palmer Dabbelt
@ 2021-08-04  5:25     ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-08-04  5:25 UTC (permalink / raw)
  To: Palmer Dabbelt; +Cc: Paul Walmsley, aou, linux-riscv, linux-kernel, guoren

On 8/3/21 10:14 PM, Palmer Dabbelt wrote:
> On Fri, 23 Jul 2021 17:58:13 PDT (-0700), Palmer Dabbelt wrote:
>> On Tue, 06 Jul 2021 09:26:21 PDT (-0700), linux@roeck-us.net wrote:
>>> riscv uses the value of TSK_STACK_CANARY to set
>>> stack-protector-guard-offset. With GCC_PLUGIN_RANDSTRUCT enabled, that
>>> value is non-deterministic, and with riscv:allmodconfig often results
>>> in build errors such as
>>>
>>> cc1: error: '8120' is not a valid offset in '-mstack-protector-guard-offset='
>>>
>>> Enable STACKPROTECTOR_PER_TASK only if GCC_PLUGIN_RANDSTRUCT is disabled
>>> to fix the problem.
>>>
>>> Fixes: fea2fed201ee5 ("riscv: Enable per-task stack canaries")
>>> Cc: Guo Ren <guoren@linux.alibaba.com>
>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>> ---
>>>  arch/riscv/Kconfig | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
>>> index 469a70bd8da6..3afb84fa2190 100644
>>> --- a/arch/riscv/Kconfig
>>> +++ b/arch/riscv/Kconfig
>>> @@ -486,6 +486,7 @@ config CC_HAVE_STACKPROTECTOR_TLS
>>>
>>>  config STACKPROTECTOR_PER_TASK
>>>      def_bool y
>>> +    depends on !GCC_PLUGIN_RANDSTRUCT
>>>      depends on STACKPROTECTOR && CC_HAVE_STACKPROTECTOR_TLS
>>>
>>>  config PHYS_RAM_BASE_FIXED
>>
>> Thanks, this is on fixes.  I do an allmodconfig build and haven't seen
>> these failures, is there something special I need to do to get this
>> working?  I know nothing about GCC plugins...
> 
> Sorry, looks like I screwed something up and I didn't actually merge this onto fixes.  Not sure what happened, but this time it should actually be on fixes.

Ah, I thought you decided not to apply it for some reason. I changed
my test scripts to always disable GCC_PLUGIN_RANDSTRUCT for riscv
build tests and stopped reporting the problem. I mentioned this
a couple of weeks ago in my test reports. Just in case you wondered.

Guenter

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

end of thread, other threads:[~2021-08-04  5:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 16:26 [PATCH] riscv: Disable STACKPROTECTOR_PER_TASK if GCC_PLUGIN_RANDSTRUCT is enabled Guenter Roeck
2021-07-24  0:58 ` Palmer Dabbelt
2021-07-24  2:13   ` Guenter Roeck
2021-08-04  5:14   ` Palmer Dabbelt
2021-08-04  5:25     ` Guenter Roeck

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).