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


Groups > linux.kernel > #1292543

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

From Pavel Machek <pavel@ucw.cz>
Newsgroups linux.kernel
Subject Re: 4.4-rc5: ugly warn on: 5 W+X pages found
Date 2015-12-15 22:00 +0100
Message-ID <qG4Rs-MI-21@gated-at.bofh.it> (permalink)
References (5 earlier) <qFIxA-34I-25@gated-at.bofh.it> <qFIQW-3c1-15@gated-at.bofh.it> <qFJN0-3NK-5@gated-at.bofh.it> <qFUp3-2e3-11@gated-at.bofh.it> <qG1TA-7mv-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi!

> > 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);
>   +}
...
>   +       if (protval & _PAGE_PRESENT) {
>                   protval &= __supported_pte_mask;
>   +               WARN_ON_ONCE(kernel_write_execute_prot(protval));
>   +       }
> 
>           return protval;
>    }
> 
> or similar?
> 
> The above is entirely untested. Maybe it doesn't compile. Or
> boot. Or work.

Well, with two extra spaces at each line, it does not apply :-).

I applied it by hand, and the output is:

[    0.000000] MTRR variable ranges enabled:
[    0.000000]   0 base 000000000 mask F80000000 write-back
[    0.000000]   1 base 080000000 mask FC0000000 write-back
[    0.000000]   2 base 0BF700000 mask FFFF00000 uncachable
[    0.000000]   3 base 0BF800000 mask FFF800000 uncachable
[    0.000000]   4 disabled
[    0.000000]   5 disabled
[    0.000000]   6 disabled
[    0.000000]   7 disabled
[    0.000000] x86/PAT: PAT not supported by CPU.
[    0.000000] initial memory mapped: [mem 0x00000000-0x05bfffff]
[    0.000000] Base memory trampoline at [c009b000] 9b000 size 16384
[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at
./arch/x86/include/asm/pgtable.h:357 kernel_physical_mapping_init+0x
256/0x395()
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.4.0-rc5+ #137
[    0.000000] Hardware name: LENOVO 17097HU/17097HU, BIOS 7BETD8WW
(2.19 ) 03/31/2011
[    0.000000]  00000000 00000000 c4e63e90 c42baaf8 00000000 c4e63eac
c404066b 00000165
[    0.000000]  c4f134da 00000000 00000000 00000000 c4e63ebc c404070f
00000009 00000000
[    0.000000]  c4e63f18 c4f134da c4e63f00 00000000 00000000 00000000
00000000 00000000
[    0.000000] Call Trace:
[    0.000000]  [<c42baaf8>] dump_stack+0x41/0x59
[    0.000000]  [<c404066b>] warn_slowpath_common+0x6b/0xa0
[    0.000000]  [<c4f134da>] ?
kernel_physical_mapping_init+0x256/0x395
[    0.000000]  [<c404070f>] warn_slowpath_null+0xf/0x20
[    0.000000]  [<c4f134da>] kernel_physical_mapping_init+0x256/0x395
[    0.000000]  [<c4a4de21>] init_memory_mapping+0x191/0x300
[    0.000000]  [<c4f12d96>] init_mem_mapping+0xe7/0x1f3
[    0.000000]  [<c4f12d96>] ? init_mem_mapping+0xe7/0x1f3
[    0.000000]  [<c4f065ef>] setup_arch+0x659/0x8ca
[    0.000000]  [<c4f0480e>] start_kernel+0xbb/0x360
[    0.000000]  [<c4f042d4>] i386_start_kernel+0x82/0x86
[    0.000000] ---[ end trace e117245cd61feaf1 ]---
[    0.000000] BRK [0x0566a000, 0x0566afff] PGTABLE
[    0.000000] BRK [0x0566b000, 0x0566bfff] PGTABLE
[    0.000000] BRK [0x0566c000, 0x0566cfff] PGTABLE

I'll take a look if I can figure out what it means...
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-14 09:10 +0100
  Re: 4.4-rc5: ugly warn on: 5 W+X pages found Borislav Petkov <bp@alien8.de> - 2015-12-14 10:00 +0100
    Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-14 10:10 +0100
      Re: 4.4-rc5: ugly warn on: 5 W+X pages found Borislav Petkov <bp@alien8.de> - 2015-12-14 10:20 +0100
      Re: 4.4-rc5: ugly warn on: 5 W+X pages found Linus Torvalds <torvalds@linux-foundation.org> - 2015-12-14 20:20 +0100
        Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-14 21:30 +0100
          Re: 4.4-rc5: ugly warn on: 5 W+X pages found Andy Lutomirski <luto@amacapital.net> - 2015-12-14 22:10 +0100
            Re: 4.4-rc5: ugly warn on: 5 W+X pages found Arjan van de Ven <arjan@linux.intel.com> - 2015-12-14 22:30 +0100
              Re: 4.4-rc5: ugly warn on: 5 W+X pages found Andy Lutomirski <luto@amacapital.net> - 2015-12-14 23:30 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-15 10:50 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Linus Torvalds <torvalds@linux-foundation.org> - 2015-12-15 18:50 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Borislav Petkov <bp@alien8.de> - 2015-12-15 19:40 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Linus Torvalds <torvalds@linux-foundation.org> - 2015-12-15 20:10 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Borislav Petkov <bp@alien8.de> - 2015-12-15 20:20 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Andy Lutomirski <luto@amacapital.net> - 2015-12-15 19:50 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Linus Torvalds <torvalds@linux-foundation.org> - 2015-12-15 20:10 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-15 22:00 +0100
                4.4.-rc5: lguest causes ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-15 22:20 +0100
                Re: 4.4.-rc5: lguest causes ugly warn on: 5 W+X pages found Rusty Russell <rusty@rustcorp.com.au> - 2015-12-16 03:30 +0100
                Re: 4.4.-rc5: lguest causes ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-16 09:20 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Borislav Petkov <bp@alien8.de> - 2015-12-15 22:40 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-15 23:10 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Borislav Petkov <bp@alien8.de> - 2015-12-15 23:20 +0100
              Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-15 09:00 +0100
                [PATCH 1/2] x86_32/mm: Set NX in __supported_pte_mask before enabling paging Andy Lutomirski <luto@kernel.org> - 2015-12-15 09:10 +0100
                [PATCH 2/2] x86/mm: Make kmap_prot into a #define Andy Lutomirski <luto@kernel.org> - 2015-12-15 09:10 +0100
                [PATCH 0/2] x86/mm: A _PAGE_NX fixlet and a kmap cleanup Andy Lutomirski <luto@kernel.org> - 2015-12-15 09:10 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Arjan van de Ven <arjan@linux.intel.com> - 2015-12-15 14:40 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-15 15:10 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found "H. Peter Anvin" <hpa@zytor.com> - 2015-12-15 17:30 +0100
                Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-15 18:50 +0100
  Re: 4.4-rc5: ugly warn on: 5 W+X pages found Pavel Machek <pavel@ucw.cz> - 2015-12-14 13:40 +0100

csiph-web