From: Christophe LEROY <christophe.leroy@c-s.fr>
To: Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>, Scott Wood <oss@buserror.net>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/32: Fix protection of kernel RAM after freeing unused memory
Date: Tue, 18 Apr 2017 10:15:16 +0200 [thread overview]
Message-ID: <4a39282c-2c69-1a09-ef50-b5c8c25d0a02@c-s.fr> (raw)
In-Reply-To: <87mvbe6wxa.fsf@concordia.ellerman.id.au>
Le 18/04/2017 à 08:40, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>
>> 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() ?
We only want to remove the X bit.
I think unmap_kernel_range() will unmap the area, wheareas we want to
keep it as part of the linear data area.
Christophe
>
> Is this sufficient on all 32-bit PPC? (I have no idea)
>
> cheers
>
prev parent reply other threads:[~2017-04-18 8:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-14 13:11 [PATCH] powerpc/32: Fix protection of kernel RAM after freeing unused memory Christophe Leroy
2017-04-18 6:40 ` Michael Ellerman
2017-04-18 8:15 ` Christophe LEROY [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4a39282c-2c69-1a09-ef50-b5c8c25d0a02@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=oss@buserror.net \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox