2014-02-13 19:54:10

by Kees Cook

[permalink] [raw]
Subject: [PATCH v3] ARM: mm: report both sections from PMD

On 2-level page table systems, the PMD has 2 section entries. Report
these, otherwise ARM_PTDUMP will miss reporting permission changes on
odd section boundaries.

Signed-off-by: Kees Cook <[email protected]>
---
v3:
- re-reorganize, drop use of pmd_sect; suggested by Catalin Marinas.
v2:
- reorganize, suggested by Catalin Marinas.
---
arch/arm/mm/dump.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
index 2b342177f5de..61cc78ae9f21 100644
--- a/arch/arm/mm/dump.c
+++ b/arch/arm/mm/dump.c
@@ -264,6 +264,9 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
note_page(st, addr, 3, pmd_val(*pmd));
else
walk_pte(st, pmd, addr);
+
+ if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1]))
+ note_page(st, addr + SECTION_SIZE, 3, pmd_val(pmd[1]));
}
}

--
1.7.9.5


--
Kees Cook
Chrome OS Security


2014-02-14 10:17:34

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH v3] ARM: mm: report both sections from PMD

On Thu, Feb 13, 2014 at 07:52:30PM +0000, Kees Cook wrote:
> On 2-level page table systems, the PMD has 2 section entries. Report
> these, otherwise ARM_PTDUMP will miss reporting permission changes on
> odd section boundaries.
>
> Signed-off-by: Kees Cook <[email protected]>

Acked-by: Catalin Marinas <[email protected]>

2014-02-14 17:06:09

by Steve Capper

[permalink] [raw]
Subject: Re: [PATCH v3] ARM: mm: report both sections from PMD

On Thu, Feb 13, 2014 at 11:52:30AM -0800, Kees Cook wrote:
> On 2-level page table systems, the PMD has 2 section entries. Report
> these, otherwise ARM_PTDUMP will miss reporting permission changes on
> odd section boundaries.
>
> Signed-off-by: Kees Cook <[email protected]>
> ---
> v3:
> - re-reorganize, drop use of pmd_sect; suggested by Catalin Marinas.
> v2:
> - reorganize, suggested by Catalin Marinas.
> ---
> arch/arm/mm/dump.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
> index 2b342177f5de..61cc78ae9f21 100644
> --- a/arch/arm/mm/dump.c
> +++ b/arch/arm/mm/dump.c
> @@ -264,6 +264,9 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
> note_page(st, addr, 3, pmd_val(*pmd));
> else
> walk_pte(st, pmd, addr);
> +
> + if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[1]))
> + note_page(st, addr + SECTION_SIZE, 3, pmd_val(pmd[1]));
> }
> }
>
> --
> 1.7.9.5

This picks up an odd megabyte aligned section on my Arndale board with
short descriptors on 3.14-rc2. Behaves as expected with long descriptors
too (does nothing).

FWIW:
Tested-by: Steve Capper <[email protected]>

Cheers,
--
Steve

>
>
> --
> Kees Cook
> Chrome OS Security
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2014-02-14 19:13:55

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v3] ARM: mm: report both sections from PMD

On Fri, Feb 14, 2014 at 2:17 AM, Catalin Marinas
<[email protected]> wrote:
> On Thu, Feb 13, 2014 at 07:52:30PM +0000, Kees Cook wrote:
>> On 2-level page table systems, the PMD has 2 section entries. Report
>> these, otherwise ARM_PTDUMP will miss reporting permission changes on
>> odd section boundaries.
>>
>> Signed-off-by: Kees Cook <[email protected]>
>
> Acked-by: Catalin Marinas <[email protected]>

On Fri, Feb 14, 2014 at 9:05 AM, Steve Capper <[email protected]> wrote:
> Tested-by: Steve Capper <[email protected]>

Thanks to both of you! If you have a moment can you check this other
patch which has additional fixes for the dump code?

https://lkml.org/lkml/2014/2/12/662

Thanks,

-Kees

--
Kees Cook
Chrome OS Security

2014-02-14 19:23:33

by Russell King - ARM Linux

[permalink] [raw]
Subject: Re: [PATCH v3] ARM: mm: report both sections from PMD

On Fri, Feb 14, 2014 at 11:13:53AM -0800, Kees Cook wrote:
> On Fri, Feb 14, 2014 at 2:17 AM, Catalin Marinas
> <[email protected]> wrote:
> > On Thu, Feb 13, 2014 at 07:52:30PM +0000, Kees Cook wrote:
> >> On 2-level page table systems, the PMD has 2 section entries. Report
> >> these, otherwise ARM_PTDUMP will miss reporting permission changes on
> >> odd section boundaries.
> >>
> >> Signed-off-by: Kees Cook <[email protected]>
> >
> > Acked-by: Catalin Marinas <[email protected]>
>
> On Fri, Feb 14, 2014 at 9:05 AM, Steve Capper <[email protected]> wrote:
> > Tested-by: Steve Capper <[email protected]>
>
> Thanks to both of you! If you have a moment can you check this other
> patch which has additional fixes for the dump code?
>
> https://lkml.org/lkml/2014/2/12/662

It's not that simple, because APX in section descriptors doesn't exist
on pre-v6 ARMs. This needs to be conditional upon the CPU arch.

--
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up. Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".

2014-02-14 19:31:23

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v3] ARM: mm: report both sections from PMD

On Fri, Feb 14, 2014 at 11:23 AM, Russell King - ARM Linux
<[email protected]> wrote:
>> https://lkml.org/lkml/2014/2/12/662
>
> It's not that simple, because APX in section descriptors doesn't exist
> on pre-v6 ARMs. This needs to be conditional upon the CPU arch.

Ah! Okay, do we need a single #define to describe the expected masks
and values? What should it look like for pre-v6 ARMs?

-Kees

--
Kees Cook
Chrome OS Security