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: <CALCETrV5kRXLAomsPUGKsZiL9Um4NioTqaLqoCzxGCJDRQUX+g@mail.gmail.com>
Date:	Tue, 15 Dec 2015 10:40:53 -0800
From:	Andy Lutomirski <luto@...capital.net>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Pavel Machek <pavel@....cz>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	Borislav Petkov <bp@...en8.de>,
	kernel list <linux-kernel@...r.kernel.org>,
	Stephen Smalley <sds@...ho.nsa.gov>,
	Brian Gerst <brgerst@...il.com>,
	Denys Vlasenko <dvlasenk@...hat.com>,
	Peter Anvin <hpa@...or.com>, Mike Galbraith <efault@....de>,
	Peter Zijlstra <peterz@...radead.org>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: 4.4-rc5: ugly warn on: 5 W+X pages found

On Tue, Dec 15, 2015 at 9:45 AM, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
> On Tue, Dec 15, 2015 at 1:40 AM, Pavel Machek <pavel@....cz> 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) &&
>   +               (protval & _PAGE_RW);
>   +}
>   +
>    /*
>     * Mask out unsupported bits in a present pgprot.  Non-present pgprots
>     * can use those bits for other purposes, so leave them be.
>   @@ -345,8 +352,10 @@ static inline pgprotval_t massage_pgprot(pgprot_t pgprot)
>    {
>           pgprotval_t protval = pgprot_val(pgprot);
>
>   -       if (protval & _PAGE_PRESENT)
>   +       if (protval & _PAGE_PRESENT) {
>                   protval &= __supported_pte_mask;
>   +               WARN_ON_ONCE(kernel_write_execute_prot(protval));

Shouldn't we switch those two lines?  Arguably trying to set rwx
permissions on !PAE is a bug even if it makes no difference, whereas
setting rw- and getting rwx because we don't have NX support on the
platform or kernel build doesn't indicate a bug.

Anyway, I still think that we should apply my patches for 4.5 because
I think they're cleanups, but apparently I guessed wrong as to what
was causing Pavel's issue.  But your patch would help diagnose it.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ