lineage_android_kernel_xiao.../include
Pavel Tatashin 87395eeb28 mm: discard memblock data later
commit 3010f876500f9ba921afaeccec30c45ca6584dc8 upstream.

There is existing use after free bug when deferred struct pages are
enabled:

The memblock_add() allocates memory for the memory array if more than
128 entries are needed.  See comment in e820__memblock_setup():

  * The bootstrap memblock region count maximum is 128 entries
  * (INIT_MEMBLOCK_REGIONS), but EFI might pass us more E820 entries
  * than that - so allow memblock resizing.

This memblock memory is freed here:
        free_low_memory_core_early()

We access the freed memblock.memory later in boot when deferred pages
are initialized in this path:

        deferred_init_memmap()
                for_each_mem_pfn_range()
                  __next_mem_pfn_range()
                    type = &memblock.memory;

One possible explanation for why this use-after-free hasn't been hit
before is that the limit of INIT_MEMBLOCK_REGIONS has never been
exceeded at least on systems where deferred struct pages were enabled.

Tested by reducing INIT_MEMBLOCK_REGIONS down to 4 from the current 128,
and verifying in qemu that this code is getting excuted and that the
freed pages are sane.

Link: http://lkml.kernel.org/r/1502485554-318703-2-git-send-email-pasha.tatashin@oracle.com
Fixes: 7e18adb4f8 ("mm: meminit: initialise remaining struct pages in parallel with kswapd")
Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Reviewed-by: Bob Picco <bob.picco@oracle.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-08-24 17:12:19 -07:00
..
acpi ACPICA: Linuxize: Restore and fix Intel compiler build 2017-02-26 11:10:52 +01:00
asm-generic
clocksource
crypto crypto: ahash - Fix EINPROGRESS notification callback 2017-04-21 09:31:23 +02:00
drm drm: Don't race connector registration 2017-06-17 06:41:53 +02:00
dt-bindings dt: bindings: net: use boolean dt properties for eee broken modes 2017-07-05 14:40:20 +02:00
keys
kvm
linux mm: discard memblock data later 2017-08-24 17:12:19 -07:00
math-emu
media
memory
misc
net wext: handle NULL extra data in iwe_stream_add_point better 2017-08-11 08:49:34 -07:00
pcmcia
ras
rdma RDMA/core: Fix incorrect structure packing for booleans 2017-03-12 06:41:50 +01:00
rxrpc
scsi scsi: Add STARGET_CREATED_REMOVE state to scsi_target_state 2017-07-27 15:07:59 -07:00
soc ARM: at91: define LPDDR types 2017-03-12 06:41:41 +01:00
sound
target iscsi-target: Fix iscsi_np reset hung task during parallel delete 2017-08-16 13:43:16 -07:00
trace tracing: Add #undef to fix compile error 2017-03-18 19:14:29 +08:00
uapi net: ethtool: add support for 2500BaseT and 5000BaseT link modes 2017-07-05 14:40:19 +02:00
video
xen xen: Revert commits da72ff5bfcb0 and 72a9b18629 2017-05-14 14:00:22 +02:00
Kbuild