Re: 4.4-rc5: ugly warn on: 5 W+X pages found

From: Borislav Petkov
Date: Tue Dec 15 2015 - 13:30:20 EST


On Tue, Dec 15, 2015 at 09:45:40AM -0800, Linus Torvalds wrote:
> On Tue, Dec 15, 2015 at 1:40 AM, Pavel Machek <pavel@xxxxxx> wrote:
> >
> > I tried applying:
> >
> > [PATCH 1/2] x86_32/mm: Set NX in __supported_pte_mask before enabling
> > paging
> >
> > but I still get
> >
> > [ 2.691897] x86/mm: Found insecure W+X mapping at address ffe69000/0xffe69000
>
> This may be an insane suggestion, but how about we try to detect when
> that entry gets set, rather than after the fact.
>
> Something really brute-force like
>
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index 6ec0c8b2e9df..538c9bb239b9 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -337,6 +337,13 @@ static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
>
> #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */
>
> +static inline int kernel_write_execute_prot(pgprotval_t protval)
> +{
> + return !(protval & _PAGE_USER) &&
> + !(protval & _PAGE_NX) &&

Shouldn't this be without a "!"? AFAIU, we want _PAGE_NX | _PAGE_RW?

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/