Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1413393 > unrolled thread
| Started by | Kees Cook <keescook@chromium.org> |
|---|---|
| First post | 2016-06-03 20:50 +0200 |
| Last post | 2016-06-04 00:10 +0200 |
| Articles | 5 — 2 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.
[PATCH 2/2] arm: apply more __ro_after_init Kees Cook <keescook@chromium.org> - 2016-06-03 20:50 +0200
Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init Greg KH <gregkh@linuxfoundation.org> - 2016-06-03 21:00 +0200
Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init Kees Cook <keescook@chromium.org> - 2016-06-03 23:30 +0200
Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init Greg KH <gregkh@linuxfoundation.org> - 2016-06-04 00:00 +0200
Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init Kees Cook <keescook@chromium.org> - 2016-06-04 00:10 +0200
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2016-06-03 20:50 +0200 |
| Subject | [PATCH 2/2] arm: apply more __ro_after_init |
| Message-ID | <rG2kq-6QU-7@gated-at.bofh.it> |
Guided by grsecurity's analogous __read_only markings in arch/arm,
this applies several uses of __ro_after_init to structures that are
only updated during __init.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
arch/arm/kernel/cpuidle.c | 2 +-
arch/arm/kernel/setup.c | 10 +++++-----
arch/arm/kernel/smp.c | 2 +-
arch/arm/lib/delay.c | 2 +-
arch/arm/mm/mmu.c | 9 ++-------
arch/x86/mm/ioremap.c | 3 +--
6 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
index a44b268e12e1..d574708ea20c 100644
--- a/arch/arm/kernel/cpuidle.c
+++ b/arch/arm/kernel/cpuidle.c
@@ -19,7 +19,7 @@ extern struct of_cpuidle_method __cpuidle_method_of_table[];
static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel
__used __section(__cpuidle_method_of_table_end);
-static struct cpuidle_ops cpuidle_ops[NR_CPUS];
+static struct cpuidle_ops cpuidle_ops[NR_CPUS] __ro_after_init;
/**
* arm_cpuidle_simple_enter() - a wrapper to cpu_do_idle()
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 7b5350060612..38196e581d0a 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -115,19 +115,19 @@ EXPORT_SYMBOL(elf_hwcap2);
#ifdef MULTI_CPU
-struct processor processor __read_mostly;
+struct processor processor __ro_after_init;
#endif
#ifdef MULTI_TLB
-struct cpu_tlb_fns cpu_tlb __read_mostly;
+struct cpu_tlb_fns cpu_tlb __ro_after_init;
#endif
#ifdef MULTI_USER
-struct cpu_user_fns cpu_user __read_mostly;
+struct cpu_user_fns cpu_user __ro_after_init;
#endif
#ifdef MULTI_CACHE
-struct cpu_cache_fns cpu_cache __read_mostly;
+struct cpu_cache_fns cpu_cache __ro_after_init;
#endif
#ifdef CONFIG_OUTER_CACHE
-struct outer_cache_fns outer_cache __read_mostly;
+struct outer_cache_fns outer_cache __ro_after_init;
EXPORT_SYMBOL(outer_cache);
#endif
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index df90bc59bfce..9902e76fce0d 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -82,7 +82,7 @@ enum ipi_msg_type {
static DECLARE_COMPLETION(cpu_running);
-static struct smp_operations smp_ops;
+static struct smp_operations smp_ops __ro_after_init;
void __init smp_set_ops(const struct smp_operations *ops)
{
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
index 8044591dca72..2cef11884857 100644
--- a/arch/arm/lib/delay.c
+++ b/arch/arm/lib/delay.c
@@ -29,7 +29,7 @@
/*
* Default to the loop-based delay implementation.
*/
-struct arm_delay_ops arm_delay_ops = {
+struct arm_delay_ops arm_delay_ops __ro_after_init = {
.delay = __loop_delay,
.const_udelay = __loop_const_udelay,
.udelay = __loop_udelay,
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 62f4d01941f7..5e2acc78175e 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -243,7 +243,7 @@ __setup("noalign", noalign_setup);
#define PROT_PTE_S2_DEVICE PROT_PTE_DEVICE
#define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
-static struct mem_type mem_types[] = {
+static struct mem_type mem_types[] __ro_after_init = {
[MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
.prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
L_PTE_SHARED,
@@ -1309,16 +1309,11 @@ void __init arm_mm_memblock_reserve(void)
* Any other function or debugging method which may touch any device _will_
* crash the kernel.
*/
+static char vectors[PAGE_SIZE * 2] __ro_after_init __aligned(PAGE_SIZE);
static void __init devicemaps_init(const struct machine_desc *mdesc)
{
struct map_desc map;
unsigned long addr;
- void *vectors;
-
- /*
- * Allocate the vector page early.
- */
- vectors = early_alloc(PAGE_SIZE * 2);
early_trap_init(vectors);
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 4e5821896eec..f0894910bdd7 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -419,8 +419,7 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
}
-static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __ro_after_init
- __aligned(PAGE_SIZE);
+static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
{
--
2.7.4
[toc] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-06-03 21:00 +0200 |
| Subject | Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init |
| Message-ID | <rG2u5-6TX-5@gated-at.bofh.it> |
| In reply to | #1413393 |
On Fri, Jun 03, 2016 at 11:40:24AM -0700, Kees Cook wrote: > Guided by grsecurity's analogous __read_only markings in arch/arm, > this applies several uses of __ro_after_init to structures that are > only updated during __init. > > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > arch/arm/kernel/cpuidle.c | 2 +- > arch/arm/kernel/setup.c | 10 +++++----- > arch/arm/kernel/smp.c | 2 +- > arch/arm/lib/delay.c | 2 +- > arch/arm/mm/mmu.c | 9 ++------- > arch/x86/mm/ioremap.c | 3 +-- I don't think this x86 file is an arm-specific one :) That minor nit aside, these patches are a great step forward, are you going to take them and work to push them upstream, or do you want/need others to do this? thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2016-06-03 23:30 +0200 |
| Subject | Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init |
| Message-ID | <rG4Pf-8ss-3@gated-at.bofh.it> |
| In reply to | #1413410 |
On Fri, Jun 3, 2016 at 11:51 AM, Greg KH <gregkh@linuxfoundation.org> wrote: > On Fri, Jun 03, 2016 at 11:40:24AM -0700, Kees Cook wrote: >> Guided by grsecurity's analogous __read_only markings in arch/arm, >> this applies several uses of __ro_after_init to structures that are >> only updated during __init. >> >> Signed-off-by: Kees Cook <keescook@chromium.org> >> --- >> arch/arm/kernel/cpuidle.c | 2 +- >> arch/arm/kernel/setup.c | 10 +++++----- >> arch/arm/kernel/smp.c | 2 +- >> arch/arm/lib/delay.c | 2 +- >> arch/arm/mm/mmu.c | 9 ++------- >> arch/x86/mm/ioremap.c | 3 +-- > > I don't think this x86 file is an arm-specific one :) Hah, whooops. :) > That minor nit aside, these patches are a great step forward, are you > going to take them and work to push them upstream, or do you want/need > others to do this? I'll collect more like these and carry a tree for -next and push them for v4.8. -Kees -- Kees Cook Chrome OS & Brillo Security
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-06-04 00:00 +0200 |
| Subject | Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init |
| Message-ID | <rG5ih-c6-1@gated-at.bofh.it> |
| In reply to | #1413494 |
On Fri, Jun 03, 2016 at 02:26:54PM -0700, Kees Cook wrote: > On Fri, Jun 3, 2016 at 11:51 AM, Greg KH <gregkh@linuxfoundation.org> wrote: > > On Fri, Jun 03, 2016 at 11:40:24AM -0700, Kees Cook wrote: > >> Guided by grsecurity's analogous __read_only markings in arch/arm, > >> this applies several uses of __ro_after_init to structures that are > >> only updated during __init. > >> > >> Signed-off-by: Kees Cook <keescook@chromium.org> > >> --- > >> arch/arm/kernel/cpuidle.c | 2 +- > >> arch/arm/kernel/setup.c | 10 +++++----- > >> arch/arm/kernel/smp.c | 2 +- > >> arch/arm/lib/delay.c | 2 +- > >> arch/arm/mm/mmu.c | 9 ++------- > >> arch/x86/mm/ioremap.c | 3 +-- > > > > I don't think this x86 file is an arm-specific one :) > > Hah, whooops. :) > > > That minor nit aside, these patches are a great step forward, are you > > going to take them and work to push them upstream, or do you want/need > > others to do this? > > I'll collect more like these and carry a tree for -next and push them for v4.8. Sounds good! Is there any "problem" with applying these markings to code that could be built as a module? I'm thinking of lots of buses and drivers that have structures like this, but can be a module or not, depending on the configuration selected. It would be nice to get the "benefit" of protection if the code is built into the kernel image. thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2016-06-04 00:10 +0200 |
| Subject | Re: [kernel-hardening] [PATCH 2/2] arm: apply more __ro_after_init |
| Message-ID | <rG5rX-uq-7@gated-at.bofh.it> |
| In reply to | #1413520 |
On Fri, Jun 3, 2016 at 2:54 PM, Greg KH <gregkh@linuxfoundation.org> wrote: > On Fri, Jun 03, 2016 at 02:26:54PM -0700, Kees Cook wrote: >> On Fri, Jun 3, 2016 at 11:51 AM, Greg KH <gregkh@linuxfoundation.org> wrote: >> > On Fri, Jun 03, 2016 at 11:40:24AM -0700, Kees Cook wrote: >> >> Guided by grsecurity's analogous __read_only markings in arch/arm, >> >> this applies several uses of __ro_after_init to structures that are >> >> only updated during __init. >> >> >> >> Signed-off-by: Kees Cook <keescook@chromium.org> >> >> --- >> >> arch/arm/kernel/cpuidle.c | 2 +- >> >> arch/arm/kernel/setup.c | 10 +++++----- >> >> arch/arm/kernel/smp.c | 2 +- >> >> arch/arm/lib/delay.c | 2 +- >> >> arch/arm/mm/mmu.c | 9 ++------- >> >> arch/x86/mm/ioremap.c | 3 +-- >> > >> > I don't think this x86 file is an arm-specific one :) >> >> Hah, whooops. :) >> >> > That minor nit aside, these patches are a great step forward, are you >> > going to take them and work to push them upstream, or do you want/need >> > others to do this? >> >> I'll collect more like these and carry a tree for -next and push them for v4.8. > > Sounds good! > > Is there any "problem" with applying these markings to code that could > be built as a module? I'm thinking of lots of buses and drivers that > have structures like this, but can be a module or not, depending on the > configuration selected. It would be nice to get the "benefit" of > protection if the code is built into the kernel image. There's no operational problem, it will just currently offer no protections, and once the module side of things HAS been fixed, if any got marked incorrectly, it'll be discovered then instead of when they were added. -Kees -- Kees Cook Chrome OS & Brillo Security
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web