lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87mvbe6wxa.fsf@concordia.ellerman.id.au>
Date:   Tue, 18 Apr 2017 16:40:17 +1000
From:   Michael Ellerman <mpe@...erman.id.au>
To:     Christophe Leroy <christophe.leroy@....fr>,
        Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Scott Wood <oss@...error.net>
Cc:     linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH] powerpc/32: Fix protection of kernel RAM after freeing unused memory

Christophe Leroy <christophe.leroy@....fr> writes:

> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index 9ee536ec0739..e95931c4e6cf 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -401,6 +401,9 @@ void free_initmem(void)
>  {
>  	ppc_md.progress = ppc_printk_progress;
>  	free_initmem_default(POISON_FREE_INITMEM);
> +#ifdef CONFIG_PPC32
> +	remap_init_ram();
> +#endif
>  }

Please don't put ifdefs straight in C code like that unless you have to.
In this case it's easy to put an empty version in a header, eg:

> diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h
> index f988db655e5b..d39d92600839 100644
> --- a/arch/powerpc/mm/mmu_decl.h
> +++ b/arch/powerpc/mm/mmu_decl.h
> @@ -95,6 +95,7 @@ extern void _tlbia(void);
>  
>  extern void mapin_ram(void);
>  extern int map_page(unsigned long va, phys_addr_t pa, int flags);

  +#ifdef CONFIG_PPC32
> +void remap_init_ram(void);
  +#else
  +static inline void remap_init_ram(void) { }
  +#endif

> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
> index a65c0b4c0669..d506bd61b629 100644
> --- a/arch/powerpc/mm/pgtable_32.c
> +++ b/arch/powerpc/mm/pgtable_32.c
> @@ -323,6 +323,26 @@ get_pteptr(struct mm_struct *mm, unsigned long addr, pte_t **ptep, pmd_t **pmdp)
>          return(retval);
>  }
>  
> +void remap_init_ram(void)
> +{
> +	unsigned long start = (unsigned long)_sinittext & PAGE_MASK;
> +	unsigned long end = (unsigned long)_einittext;
> +	unsigned long va;
> +
> +	for (va = start; va < end; va += PAGE_SIZE) {
> +		pte_t *kpte;
> +		pmd_t *kpmd;
> +		pte_t pte = pfn_pte(__pa(va) >> PAGE_SHIFT, PAGE_KERNEL);
> +
> +		if (!get_pteptr(&init_mm, va, &kpte, &kpmd))
> +			continue;
> +		__set_pte_at(&init_mm, va, kpte, pte, 0);
> +		wmb();
> +		pte_unmap(kpte);
> +	}
> +	flush_tlb_kernel_range(start, end);
> +}

Can we just use unmap_kernel_range() ?

Is this sufficient on all 32-bit PPC? (I have no idea)

cheers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ