Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1522067 > unrolled thread

[PATCH v2] tile: handle __ro_after_init like parisc does

Started byChris Metcalf <cmetcalf@mellanox.com>
First post2016-11-14 21:30 +0100
Last post2016-11-15 08:50 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2] tile: handle __ro_after_init like parisc does Chris Metcalf <cmetcalf@mellanox.com> - 2016-11-14 21:30 +0100
    Re: [PATCH v2] tile: handle __ro_after_init like parisc does Kees Cook <keescook@chromium.org> - 2016-11-14 22:20 +0100
      Re: [PATCH v2] tile: handle __ro_after_init like parisc does Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-11-15 08:50 +0100

#1522067 — [PATCH v2] tile: handle __ro_after_init like parisc does

FromChris Metcalf <cmetcalf@mellanox.com>
Date2016-11-14 21:30 +0100
Subject[PATCH v2] tile: handle __ro_after_init like parisc does
Message-ID<sDw37-3m0-17@gated-at.bofh.it>
The tile architecture already marks RO_DATA as read-only in
the kernel, so grouping RO_AFTER_INIT_DATA with RO_DATA, as is
done by default, means the kernel faults in init when it tries
to write to RO_AFTER_INIT_DATA.  For now, just arrange that
__ro_after_init is handled like __write_once, i.e. __read_mostly.

Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
---
 arch/tile/include/asm/cache.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
index 6160761d5f61..4810e48dbbbf 100644
--- a/arch/tile/include/asm/cache.h
+++ b/arch/tile/include/asm/cache.h
@@ -61,4 +61,7 @@
  */
 #define __write_once __read_mostly
 
+/* __ro_after_init is the generic name for the tile arch __write_once. */
+#define __ro_after_init __read_mostly
+
 #endif /* _ASM_TILE_CACHE_H */
-- 
2.7.2

[toc] | [next] | [standalone]


#1522091

FromKees Cook <keescook@chromium.org>
Date2016-11-14 22:20 +0100
Message-ID<sDwPw-3SH-23@gated-at.bofh.it>
In reply to#1522067
On Mon, Nov 14, 2016 at 12:29 PM, Chris Metcalf <cmetcalf@mellanox.com> wrote:
> The tile architecture already marks RO_DATA as read-only in
> the kernel, so grouping RO_AFTER_INIT_DATA with RO_DATA, as is
> done by default, means the kernel faults in init when it tries
> to write to RO_AFTER_INIT_DATA.  For now, just arrange that
> __ro_after_init is handled like __write_once, i.e. __read_mostly.
>
> Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

At some point here, I want to collect all the arch maintainers and
discuss the options for correctly reflecting the three data
memory-protection needs we have:

- always read-only
- read-only after init
- read-only except during rare updates

(The latter one doesn't exist all yet...)

x86, arm, and arm64 use mark_rodata_ro() after init finishes, so they
don't technically implement "always read-only". parisc, tile, powerpc,
others have "always read-only", but disable read-only-after-init since
they don't use mark_rodata_ro(). I think s390 has recently implemented
both, but I have to double-check...

-Kees

> ---
>  arch/tile/include/asm/cache.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
> index 6160761d5f61..4810e48dbbbf 100644
> --- a/arch/tile/include/asm/cache.h
> +++ b/arch/tile/include/asm/cache.h
> @@ -61,4 +61,7 @@
>   */
>  #define __write_once __read_mostly
>
> +/* __ro_after_init is the generic name for the tile arch __write_once. */
> +#define __ro_after_init __read_mostly
> +
>  #endif /* _ASM_TILE_CACHE_H */
> --
> 2.7.2
>



-- 
Kees Cook
Nexus Security

[toc] | [prev] | [next] | [standalone]


#1522412

FromHeiko Carstens <heiko.carstens@de.ibm.com>
Date2016-11-15 08:50 +0100
Message-ID<sDGFb-1YS-7@gated-at.bofh.it>
In reply to#1522091
On Mon, Nov 14, 2016 at 01:12:05PM -0800, Kees Cook wrote:
> At some point here, I want to collect all the arch maintainers and
> discuss the options for correctly reflecting the three data
> memory-protection needs we have:
> 
> - always read-only
> - read-only after init
> - read-only except during rare updates
> 
> (The latter one doesn't exist all yet...)
> 
> x86, arm, and arm64 use mark_rodata_ro() after init finishes, so they
> don't technically implement "always read-only". parisc, tile, powerpc,
> others have "always read-only", but disable read-only-after-init since
> they don't use mark_rodata_ro(). I think s390 has recently implemented
> both, but I have to double-check...

Yes, s390 has both: an early always read-only support, which is effective
as soon as paging_init() has set up and enabled page tables.
Our mark_rodata_ro() implementation only makes the ro_after_init section
read-only.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web