[SRU Groovy] riscv: Fixup bootup failure with HARDENED_USERCOPY

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[SRU Groovy] riscv: Fixup bootup failure with HARDENED_USERCOPY

Thadeu Lima de Souza Cascardo-3
From: Guo Ren <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1904912

6184358da000 ("riscv: Fixup static_obj() fail") attempted to elide a lockdep
failure by rearranging our kernel image to place all initdata within [_stext,
_end], thus triggering lockdep to treat these as static objects.  These objects
are released and eventually reallocated, causing check_kernel_text_object() to
trigger a BUG().

This backs out the change to make [_stext, _end] all-encompassing, instead just
moving initdata.  This results in initdata being outside of [__init_begin,
__init_end], which means initdata can't be freed.

Link: https://lore.kernel.org/linux-riscv/1593266228-61125-1-git-send-email-guoren@.../T/#t
Signed-off-by: Guo Ren <[hidden email]>
Reported-by: Aurelien Jarno <[hidden email]>
Tested-by: Aurelien Jarno <[hidden email]>
[Palmer: Clean up commit text]
Signed-off-by: Palmer Dabbelt <[hidden email]>
(cherry picked from commit 84814460eef9af0fb56a4698341c9cb7996a6312)
Signed-off-by: Thadeu Lima de Souza Cascardo <[hidden email]>
---
 arch/riscv/kernel/vmlinux.lds.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index f3586e31ed1e..34d00d9e6eac 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -22,13 +22,11 @@ SECTIONS
  /* Beginning of code and text segment */
  . = LOAD_OFFSET;
  _start = .;
- _stext = .;
  HEAD_TEXT_SECTION
  . = ALIGN(PAGE_SIZE);
 
  __init_begin = .;
  INIT_TEXT_SECTION(PAGE_SIZE)
- INIT_DATA_SECTION(16)
  . = ALIGN(8);
  __soc_early_init_table : {
  __soc_early_init_table_start = .;
@@ -55,6 +53,7 @@ SECTIONS
  . = ALIGN(SECTION_ALIGN);
  .text : {
  _text = .;
+ _stext = .;
  TEXT_TEXT
  SCHED_TEXT
  CPUIDLE_TEXT
@@ -67,6 +66,8 @@ SECTIONS
  _etext = .;
  }
 
+ INIT_DATA_SECTION(16)
+
  /* Start of data section */
  _sdata = .;
  RO_DATA(SECTION_ALIGN)
--
2.27.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU Groovy] riscv: Fixup bootup failure with HARDENED_USERCOPY

Ian May
LGTM

Acked-by: Ian May <[hidden email]>

On 2020-11-19 18:10:28 , Thadeu Lima de Souza Cascardo wrote:

> From: Guo Ren <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1904912
>
> 6184358da000 ("riscv: Fixup static_obj() fail") attempted to elide a lockdep
> failure by rearranging our kernel image to place all initdata within [_stext,
> _end], thus triggering lockdep to treat these as static objects.  These objects
> are released and eventually reallocated, causing check_kernel_text_object() to
> trigger a BUG().
>
> This backs out the change to make [_stext, _end] all-encompassing, instead just
> moving initdata.  This results in initdata being outside of [__init_begin,
> __init_end], which means initdata can't be freed.
>
> Link: https://lore.kernel.org/linux-riscv/1593266228-61125-1-git-send-email-guoren@.../T/#t
> Signed-off-by: Guo Ren <[hidden email]>
> Reported-by: Aurelien Jarno <[hidden email]>
> Tested-by: Aurelien Jarno <[hidden email]>
> [Palmer: Clean up commit text]
> Signed-off-by: Palmer Dabbelt <[hidden email]>
> (cherry picked from commit 84814460eef9af0fb56a4698341c9cb7996a6312)
> Signed-off-by: Thadeu Lima de Souza Cascardo <[hidden email]>
> ---
>  arch/riscv/kernel/vmlinux.lds.S | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
> index f3586e31ed1e..34d00d9e6eac 100644
> --- a/arch/riscv/kernel/vmlinux.lds.S
> +++ b/arch/riscv/kernel/vmlinux.lds.S
> @@ -22,13 +22,11 @@ SECTIONS
>   /* Beginning of code and text segment */
>   . = LOAD_OFFSET;
>   _start = .;
> - _stext = .;
>   HEAD_TEXT_SECTION
>   . = ALIGN(PAGE_SIZE);
>  
>   __init_begin = .;
>   INIT_TEXT_SECTION(PAGE_SIZE)
> - INIT_DATA_SECTION(16)
>   . = ALIGN(8);
>   __soc_early_init_table : {
>   __soc_early_init_table_start = .;
> @@ -55,6 +53,7 @@ SECTIONS
>   . = ALIGN(SECTION_ALIGN);
>   .text : {
>   _text = .;
> + _stext = .;
>   TEXT_TEXT
>   SCHED_TEXT
>   CPUIDLE_TEXT
> @@ -67,6 +66,8 @@ SECTIONS
>   _etext = .;
>   }
>  
> + INIT_DATA_SECTION(16)
> +
>   /* Start of data section */
>   _sdata = .;
>   RO_DATA(SECTION_ALIGN)
> --
> 2.27.0
>
>
> --
> kernel-team mailing list
> [hidden email]
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU Groovy] riscv: Fixup bootup failure with HARDENED_USERCOPY

Colin Ian King-2
In reply to this post by Thadeu Lima de Souza Cascardo-3
On 19/11/2020 21:10, Thadeu Lima de Souza Cascardo wrote:

> From: Guo Ren <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1904912
>
> 6184358da000 ("riscv: Fixup static_obj() fail") attempted to elide a lockdep
> failure by rearranging our kernel image to place all initdata within [_stext,
> _end], thus triggering lockdep to treat these as static objects.  These objects
> are released and eventually reallocated, causing check_kernel_text_object() to
> trigger a BUG().
>
> This backs out the change to make [_stext, _end] all-encompassing, instead just
> moving initdata.  This results in initdata being outside of [__init_begin,
> __init_end], which means initdata can't be freed.
>
> Link: https://lore.kernel.org/linux-riscv/1593266228-61125-1-git-send-email-guoren@.../T/#t
> Signed-off-by: Guo Ren <[hidden email]>
> Reported-by: Aurelien Jarno <[hidden email]>
> Tested-by: Aurelien Jarno <[hidden email]>
> [Palmer: Clean up commit text]
> Signed-off-by: Palmer Dabbelt <[hidden email]>
> (cherry picked from commit 84814460eef9af0fb56a4698341c9cb7996a6312)
> Signed-off-by: Thadeu Lima de Souza Cascardo <[hidden email]>
> ---
>  arch/riscv/kernel/vmlinux.lds.S | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
> index f3586e31ed1e..34d00d9e6eac 100644
> --- a/arch/riscv/kernel/vmlinux.lds.S
> +++ b/arch/riscv/kernel/vmlinux.lds.S
> @@ -22,13 +22,11 @@ SECTIONS
>   /* Beginning of code and text segment */
>   . = LOAD_OFFSET;
>   _start = .;
> - _stext = .;
>   HEAD_TEXT_SECTION
>   . = ALIGN(PAGE_SIZE);
>  
>   __init_begin = .;
>   INIT_TEXT_SECTION(PAGE_SIZE)
> - INIT_DATA_SECTION(16)
>   . = ALIGN(8);
>   __soc_early_init_table : {
>   __soc_early_init_table_start = .;
> @@ -55,6 +53,7 @@ SECTIONS
>   . = ALIGN(SECTION_ALIGN);
>   .text : {
>   _text = .;
> + _stext = .;
>   TEXT_TEXT
>   SCHED_TEXT
>   CPUIDLE_TEXT
> @@ -67,6 +66,8 @@ SECTIONS
>   _etext = .;
>   }
>  
> + INIT_DATA_SECTION(16)
> +
>   /* Start of data section */
>   _sdata = .;
>   RO_DATA(SECTION_ALIGN)
>
Looks sane to me. Thanks Thadeu

Acked-by: Colin Ian King <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [SRU Groovy] riscv: Fixup bootup failure with HARDENED_USERCOPY

Kamal Mostafa-2
In reply to this post by Thadeu Lima de Souza Cascardo-3
LGTM

Acked-by: Kamal Mostafa <[hidden email]>

 -Kamal

On Thu, Nov 19, 2020 at 06:10:28PM -0300, Thadeu Lima de Souza Cascardo wrote:

> From: Guo Ren <[hidden email]>
>
> BugLink: https://bugs.launchpad.net/bugs/1904912
>
> 6184358da000 ("riscv: Fixup static_obj() fail") attempted to elide a lockdep
> failure by rearranging our kernel image to place all initdata within [_stext,
> _end], thus triggering lockdep to treat these as static objects.  These objects
> are released and eventually reallocated, causing check_kernel_text_object() to
> trigger a BUG().
>
> This backs out the change to make [_stext, _end] all-encompassing, instead just
> moving initdata.  This results in initdata being outside of [__init_begin,
> __init_end], which means initdata can't be freed.
>
> Link: https://lore.kernel.org/linux-riscv/1593266228-61125-1-git-send-email-guoren@.../T/#t
> Signed-off-by: Guo Ren <[hidden email]>
> Reported-by: Aurelien Jarno <[hidden email]>
> Tested-by: Aurelien Jarno <[hidden email]>
> [Palmer: Clean up commit text]
> Signed-off-by: Palmer Dabbelt <[hidden email]>
> (cherry picked from commit 84814460eef9af0fb56a4698341c9cb7996a6312)
> Signed-off-by: Thadeu Lima de Souza Cascardo <[hidden email]>
> ---
>  arch/riscv/kernel/vmlinux.lds.S | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
> index f3586e31ed1e..34d00d9e6eac 100644
> --- a/arch/riscv/kernel/vmlinux.lds.S
> +++ b/arch/riscv/kernel/vmlinux.lds.S
> @@ -22,13 +22,11 @@ SECTIONS
>   /* Beginning of code and text segment */
>   . = LOAD_OFFSET;
>   _start = .;
> - _stext = .;
>   HEAD_TEXT_SECTION
>   . = ALIGN(PAGE_SIZE);
>  
>   __init_begin = .;
>   INIT_TEXT_SECTION(PAGE_SIZE)
> - INIT_DATA_SECTION(16)
>   . = ALIGN(8);
>   __soc_early_init_table : {
>   __soc_early_init_table_start = .;
> @@ -55,6 +53,7 @@ SECTIONS
>   . = ALIGN(SECTION_ALIGN);
>   .text : {
>   _text = .;
> + _stext = .;
>   TEXT_TEXT
>   SCHED_TEXT
>   CPUIDLE_TEXT
> @@ -67,6 +66,8 @@ SECTIONS
>   _etext = .;
>   }
>  
> + INIT_DATA_SECTION(16)
> +
>   /* Start of data section */
>   _sdata = .;
>   RO_DATA(SECTION_ALIGN)
> --
> 2.27.0
>
>
> --
> kernel-team mailing list
> [hidden email]
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED: [SRU Groovy] riscv: Fixup bootup failure with HARDENED_USERCOPY

Thadeu Lima de Souza Cascardo-3
In reply to this post by Thadeu Lima de Souza Cascardo-3
Applied to groovy master-next branch. Also applied locally to
groovy:linux-riscv master branch.

Thanks.
Cascardo.

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team