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


Groups > linux.kernel > #1266923 > unrolled thread

[PATCH 1/2] arm64: Fix STRICT_MM_TYPECHECKS errors from pgprot

Started byLaura Abbott <labbott@fedoraproject.org>
First post2015-11-11 03:10 +0100
Last post2015-11-15 08:40 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] arm64: Fix STRICT_MM_TYPECHECKS errors from pgprot Laura Abbott <labbott@fedoraproject.org> - 2015-11-11 03:10 +0100
    Re: [PATCH 1/2] arm64: Fix STRICT_MM_TYPECHECKS errors from pgprot Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-11-11 07:00 +0100
      Re: [PATCH 1/2] arm64: Fix STRICT_MM_TYPECHECKS errors from pgprot Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-11-11 07:10 +0100
        [PATCHv2] arm64: Fix R/O permissions in mark_rodata_ro Laura Abbott <labbott@fedoraproject.org> - 2015-11-12 21:30 +0100
          Re: [PATCHv2] arm64: Fix R/O permissions in mark_rodata_ro Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-11-15 08:40 +0100

#1266923 — [PATCH 1/2] arm64: Fix STRICT_MM_TYPECHECKS errors from pgprot

FromLaura Abbott <labbott@fedoraproject.org>
Date2015-11-11 03:10 +0100
Subject[PATCH 1/2] arm64: Fix STRICT_MM_TYPECHECKS errors from pgprot
Message-ID<qtt1f-4Vo-7@gated-at.bofh.it>
Several accesses of pgprot values are incorrect when compiled with
STRICT_MM_TYPECHECKS. Use the appropriate pgprot_val/__pgprot wrappers
to access the structures appropriately.

Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
---
Found while working on the set_memory_* work
---
 arch/arm64/mm/mmu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index c2fa6b5..83a1162 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -146,7 +146,7 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
 		if (((addr | next | phys) & ~CONT_MASK) == 0) {
 			/* a block of CONT_PTES  */
 			__populate_init_pte(pte, addr, next, phys,
-					    prot | __pgprot(PTE_CONT));
+					 __pgprot(pgprot_val(prot) | PTE_CONT));
 		} else {
 			/*
 			 * If the range being split is already inside of a
@@ -475,7 +475,7 @@ void mark_rodata_ro(void)
 {
 	create_mapping_late(__pa(_stext), (unsigned long)_stext,
 				(unsigned long)_etext - (unsigned long)_stext,
-				PAGE_KERNEL_EXEC | PTE_RDONLY);
+				__pgprot(pgprot_val(PAGE_KERNEL_EXEC) | PTE_RDONLY));
 
 }
 #endif
@@ -691,7 +691,7 @@ void __set_fixmap(enum fixed_addresses idx,
 void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
 {
 	const u64 dt_virt_base = __fix_to_virt(FIX_FDT);
-	pgprot_t prot = PAGE_KERNEL | PTE_RDONLY;
+	pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | PTE_RDONLY);
 	int size, offset;
 	void *dt_virt;
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1266976

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2015-11-11 07:00 +0100
Message-ID<qtwBR-77u-9@gated-at.bofh.it>
In reply to#1266923
Hi Laura,

On 11 November 2015 at 03:03, Laura Abbott <labbott@fedoraproject.org> wrote:
>
> Several accesses of pgprot values are incorrect when compiled with
> STRICT_MM_TYPECHECKS. Use the appropriate pgprot_val/__pgprot wrappers
> to access the structures appropriately.
>

I spotted 2 out of these, and Catalin has already queued fixes for
them (see below)

> Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
> ---
> Found while working on the set_memory_* work
> ---
>  arch/arm64/mm/mmu.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index c2fa6b5..83a1162 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -146,7 +146,7 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
>                 if (((addr | next | phys) & ~CONT_MASK) == 0) {
>                         /* a block of CONT_PTES  */
>                         __populate_init_pte(pte, addr, next, phys,
> -                                           prot | __pgprot(PTE_CONT));
> +                                        __pgprot(pgprot_val(prot) | PTE_CONT));

Got this one

>                 } else {
>                         /*
>                          * If the range being split is already inside of a
> @@ -475,7 +475,7 @@ void mark_rodata_ro(void)
>  {
>         create_mapping_late(__pa(_stext), (unsigned long)_stext,
>                                 (unsigned long)_etext - (unsigned long)_stext,
> -                               PAGE_KERNEL_EXEC | PTE_RDONLY);
> +                               __pgprot(pgprot_val(PAGE_KERNEL_EXEC) | PTE_RDONLY));
>

This needs PAGE_KERNEL_RO (which was just introduced). The reason is
that PAGE_KERNEL_EXEC has PTE_WRITE set as well, making the range
writeable under the ARMv8.1 DBM feature, that manages the dirty bit in
hardware (writing to a page with the PTE_RDONLY and PTE_WRITE bits
both set will clear the PTE_RDONLY bit in that case)

>  }
>  #endif
> @@ -691,7 +691,7 @@ void __set_fixmap(enum fixed_addresses idx,
>  void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
>  {
>         const u64 dt_virt_base = __fix_to_virt(FIX_FDT);
> -       pgprot_t prot = PAGE_KERNEL | PTE_RDONLY;
> +       pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | PTE_RDONLY);

Got this one as well (using PAGE_KERNEL_RO)

>         int size, offset;
>         void *dt_virt;
>
> --
> 2.5.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


#1266977

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2015-11-11 07:10 +0100
Message-ID<qtwLw-7rg-3@gated-at.bofh.it>
In reply to#1266976
On 11 November 2015 at 06:51, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> Hi Laura,
>
> On 11 November 2015 at 03:03, Laura Abbott <labbott@fedoraproject.org> wrote:
>>
>> Several accesses of pgprot values are incorrect when compiled with
>> STRICT_MM_TYPECHECKS. Use the appropriate pgprot_val/__pgprot wrappers
>> to access the structures appropriately.
>>
>
> I spotted 2 out of these, and Catalin has already queued fixes for
> them (see below)
>
>> Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
>> ---
>> Found while working on the set_memory_* work
>> ---
>>  arch/arm64/mm/mmu.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
>> index c2fa6b5..83a1162 100644
>> --- a/arch/arm64/mm/mmu.c
>> +++ b/arch/arm64/mm/mmu.c
>> @@ -146,7 +146,7 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
>>                 if (((addr | next | phys) & ~CONT_MASK) == 0) {
>>                         /* a block of CONT_PTES  */
>>                         __populate_init_pte(pte, addr, next, phys,
>> -                                           prot | __pgprot(PTE_CONT));
>> +                                        __pgprot(pgprot_val(prot) | PTE_CONT));
>
> Got this one
>
>>                 } else {
>>                         /*
>>                          * If the range being split is already inside of a
>> @@ -475,7 +475,7 @@ void mark_rodata_ro(void)
>>  {
>>         create_mapping_late(__pa(_stext), (unsigned long)_stext,
>>                                 (unsigned long)_etext - (unsigned long)_stext,
>> -                               PAGE_KERNEL_EXEC | PTE_RDONLY);
>> +                               __pgprot(pgprot_val(PAGE_KERNEL_EXEC) | PTE_RDONLY));
>>
>
> This needs PAGE_KERNEL_RO (which was just introduced). The reason is
> that PAGE_KERNEL_EXEC has PTE_WRITE set as well, making the range
> writeable under the ARMv8.1 DBM feature, that manages the dirty bit in
> hardware (writing to a page with the PTE_RDONLY and PTE_WRITE bits
> both set will clear the PTE_RDONLY bit in that case)
>

...only you'd obviously need to clear the PTE_PXN bit (or introduce a
new PAGE_KERNEL_xx define?)

>>  }
>>  #endif
>> @@ -691,7 +691,7 @@ void __set_fixmap(enum fixed_addresses idx,
>>  void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
>>  {
>>         const u64 dt_virt_base = __fix_to_virt(FIX_FDT);
>> -       pgprot_t prot = PAGE_KERNEL | PTE_RDONLY;
>> +       pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | PTE_RDONLY);
>
> Got this one as well (using PAGE_KERNEL_RO)
>
>>         int size, offset;
>>         void *dt_virt;
>>
>> --
>> 2.5.0
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


#1268248 — [PATCHv2] arm64: Fix R/O permissions in mark_rodata_ro

FromLaura Abbott <labbott@fedoraproject.org>
Date2015-11-12 21:30 +0100
Subject[PATCHv2] arm64: Fix R/O permissions in mark_rodata_ro
Message-ID<qu6Fk-5dX-19@gated-at.bofh.it>
In reply to#1266977
The permissions in mark_rodata_ro trigger a build error
with STRICT_MM_TYPECHECKS. Fix this by introducing
PAGE_KERNEL_ROX for the same reasons as PAGE_KERNEL_RO.
From Ard:

"PAGE_KERNEL_EXEC has PTE_WRITE set as well, making the range
writeable under the ARMv8.1 DBM feature, that manages the
dirty bit in hardware (writing to a page with the PTE_RDONLY
and PTE_WRITE bits both set will clear the PTE_RDONLY bit in that case)"

Signed-off-by: Laura Abbott <labbott@fedoraproject.org>
---
 arch/arm64/include/asm/pgtable.h | 1 +
 arch/arm64/mm/mmu.c              | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 9819a94..7e074f9 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -81,6 +81,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
 
 #define PAGE_KERNEL		__pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE)
 #define PAGE_KERNEL_RO		__pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_RDONLY)
+#define PAGE_KERNEL_ROX	__pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY)
 #define PAGE_KERNEL_EXEC	__pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE)
 #define PAGE_KERNEL_EXEC_CONT	__pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT)
 
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 9ca5996..6598c48 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -475,7 +475,7 @@ void mark_rodata_ro(void)
 {
 	create_mapping_late(__pa(_stext), (unsigned long)_stext,
 				(unsigned long)_etext - (unsigned long)_stext,
-				PAGE_KERNEL_EXEC | PTE_RDONLY);
+				PAGE_KERNEL_ROX);
 
 }
 #endif
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


#1269639 — Re: [PATCHv2] arm64: Fix R/O permissions in mark_rodata_ro

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2015-11-15 08:40 +0100
SubjectRe: [PATCHv2] arm64: Fix R/O permissions in mark_rodata_ro
Message-ID<qv04N-6Qp-1@gated-at.bofh.it>
In reply to#1268248
On 12 November 2015 at 21:21, Laura Abbott <labbott@fedoraproject.org> wrote:
> The permissions in mark_rodata_ro trigger a build error
> with STRICT_MM_TYPECHECKS. Fix this by introducing
> PAGE_KERNEL_ROX for the same reasons as PAGE_KERNEL_RO.

Forgive the bikeshedding but perhaps PAGE_KERNEL_EXEC_RO is more consistent?

> From Ard:
>
> "PAGE_KERNEL_EXEC has PTE_WRITE set as well, making the range
> writeable under the ARMv8.1 DBM feature, that manages the
> dirty bit in hardware (writing to a page with the PTE_RDONLY
> and PTE_WRITE bits both set will clear the PTE_RDONLY bit in that case)"
>
> Signed-off-by: Laura Abbott <labbott@fedoraproject.org>

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  arch/arm64/include/asm/pgtable.h | 1 +
>  arch/arm64/mm/mmu.c              | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index 9819a94..7e074f9 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -81,6 +81,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
>
>  #define PAGE_KERNEL            __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE)
>  #define PAGE_KERNEL_RO         __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_RDONLY)
> +#define PAGE_KERNEL_ROX        __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY)
>  #define PAGE_KERNEL_EXEC       __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE)
>  #define PAGE_KERNEL_EXEC_CONT  __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT)
>
> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> index 9ca5996..6598c48 100644
> --- a/arch/arm64/mm/mmu.c
> +++ b/arch/arm64/mm/mmu.c
> @@ -475,7 +475,7 @@ void mark_rodata_ro(void)
>  {
>         create_mapping_late(__pa(_stext), (unsigned long)_stext,
>                                 (unsigned long)_etext - (unsigned long)_stext,
> -                               PAGE_KERNEL_EXEC | PTE_RDONLY);
> +                               PAGE_KERNEL_ROX);
>
>  }
>  #endif
> --
> 2.5.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web