Kees Cook
918a3058f0
usercopy: Avoid HIGHMEM pfn warning
...
commit 314eed30ede02fa925990f535652254b5bad6b65 upstream.
When running on a system with >512MB RAM with a 32-bit kernel built with:
CONFIG_DEBUG_VIRTUAL=y
CONFIG_HIGHMEM=y
CONFIG_HARDENED_USERCOPY=y
all execve()s will fail due to argv copying into kmap()ed pages, and on
usercopy checking the calls ultimately of virt_to_page() will be looking
for "bad" kmap (highmem) pointers due to CONFIG_DEBUG_VIRTUAL=y:
------------[ cut here ]------------
kernel BUG at ../arch/x86/mm/physaddr.c:83!
invalid opcode: 0000 [#1 ] PREEMPT SMP DEBUG_PAGEALLOC
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc8 #6
Hardware name: Dell Inc. Inspiron 1318/0C236D, BIOS A04 01/15/2009
EIP: __phys_addr+0xaf/0x100
...
Call Trace:
__check_object_size+0xaf/0x3c0
? __might_sleep+0x80/0xa0
copy_strings+0x1c2/0x370
copy_strings_kernel+0x2b/0x40
__do_execve_file+0x4ca/0x810
? kmem_cache_alloc+0x1c7/0x370
do_execve+0x1b/0x20
...
The check is from arch/x86/mm/physaddr.c:
VIRTUAL_BUG_ON((phys_addr >> PAGE_SHIFT) > max_low_pfn);
Due to the kmap() in fs/exec.c:
kaddr = kmap(kmapped_page);
...
if (copy_from_user(kaddr+offset, str, bytes_to_copy)) ...
Now we can fetch the correct page to avoid the pfn check. In both cases,
hardened usercopy will need to walk the page-span checker (if enabled)
to do sanity checking.
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Fixes: f5509cc18d ("mm: Hardened usercopy")
Cc: Matthew Wilcox <willy@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/201909171056.7F2FFD17@keescook
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-17 13:42:06 -07:00
..
kasan
kasan: avoid -Wmaybe-uninitialized warning
2019-05-08 07:19:07 +02:00
backing-dev.c
writeback: synchronize sync(2) against cgroup writeback membership switches
2019-05-21 18:49:01 +02:00
balloon_compaction.c
mm: balloon: use general non-lru movable page feature
2016-07-26 16:19:19 -07:00
bootmem.c
mm: kmemleak: avoid using __va() on addresses that don't have a lowmem mapping
2016-10-11 15:06:33 -07:00
cleancache.c
cleancache: constify cleancache_ops structure
2016-01-27 09:09:57 -05:00
cma.c
mm/cma.c: fail if fixed declaration can't be honored
2019-08-06 18:29:37 +02:00
cma.h
cma_debug.c
mm/cma_debug.c: fix the break condition in cma_maxchunk_get()
2019-06-22 08:17:12 +02:00
compaction.c
mm, compaction: fix NR_ISOLATED_* stats for pfn based migration
2017-01-12 11:39:32 +01:00
debug.c
mm: get rid of vmacache_flush_all() entirely
2018-09-19 22:47:17 +02:00
debug_page_ref.c
mm/page_ref: add tracepoint to track down page reference manipulation
2016-03-17 15:09:34 -07:00
dmapool.c
mm: convert printk(KERN_<LEVEL> to pr_<level>
2016-03-17 15:09:34 -07:00
early_ioremap.c
mm/early_ioremap: Fix boot hang with earlyprintk=efi,keep
2018-02-25 11:05:49 +01:00
fadvise.c
mm/fadvise.c: fix signed overflow UBSAN complaint
2018-09-15 09:42:57 +02:00
failslab.c
mm: fault-inject take over bootstrap kmem_cache check
2016-03-15 16:55:16 -07:00
filemap.c
mm/filemap.c: fix NULL pointer in page_cache_tree_insert()
2018-04-24 09:34:18 +02:00
frame_vector.c
mm/frame_vector.c: release a semaphore in 'get_vaddr_frames()'
2018-11-10 07:42:52 -08:00
frontswap.c
mm, frontswap: convert frontswap_enabled to static key
2016-07-26 16:19:19 -07:00
gup.c
mm: prevent get_user_pages() from overflowing page refcount
2019-06-11 12:22:45 +02:00
highmem.c
mm/highmem: make nr_free_highpages() handles all highmem zones by itself
2016-05-19 19:12:14 -07:00
huge_memory.c
mm, page_owner: handle THP splits correctly
2019-09-06 10:19:39 +02:00
hugetlb.c
hugetlbfs: on restore reserve error path retain subpool reservation
2019-06-22 08:17:12 +02:00
hugetlb_cgroup.c
mm, hugetlb_cgroup: round limit_in_bytes down to hugepage size
2016-05-20 17:58:30 -07:00
hwpoison-inject.c
init-mm.c
mm: Add a user_ns owner to mm_struct and fix ptrace permission checks
2017-01-06 10:40:13 +01:00
internal.h
mm: fix 100% CPU kswapd busyloop on unreclaimable nodes
2018-01-31 12:55:53 +01:00
interval_tree.c
Kconfig
mm: don't allow deferred pages with NEED_PER_CPU_KM
2018-05-22 16:57:57 +02:00
Kconfig.debug
PM / Hibernate: allow hibernation with PAGE_POISONING_ZERO
2016-09-13 02:35:27 +02:00
khugepaged.c
coredump: fix race condition between collapse_huge_page() and core dumping
2019-08-06 18:29:41 +02:00
kmemcheck.c
mm: convert printk(KERN_<LEVEL> to pr_<level>
2016-03-17 15:09:34 -07:00
kmemleak-test.c
mm: convert printk(KERN_<LEVEL> to pr_<level>
2016-03-17 15:09:34 -07:00
kmemleak.c
mm/kmemleak.c: fix check for softirq context
2019-08-04 09:33:41 +02:00
ksm.c
mm/ksm: fix interaction with THP
2018-05-30 07:50:41 +02:00
list_lru.c
mm/list_lru.c: fix memory leak in __memcg_init_list_lru_node
2019-06-22 08:17:18 +02:00
maccess.c
x86: remove more uaccess_32.h complexity
2016-05-22 17:21:27 -07:00
madvise.c
mm: madvise(MADV_DODUMP): allow hugetlbfs pages
2018-10-10 08:53:20 +02:00
Makefile
Disable the __builtin_return_address() warning globally after all
2016-10-12 10:23:41 -07:00
memblock.c
mm/memblock.c: reversed logic in memblock_discard()
2017-08-30 10:21:47 +02:00
memcontrol.c
memcg, kmem: do not fail __GFP_NOFAIL charges
2019-10-05 12:30:34 +02:00
memory-failure.c
mm: hwpoison: fix thp split handing in soft_offline_in_use_page()
2019-03-23 13:19:49 +01:00
memory.c
mm: stop leaking PageTables
2019-02-20 10:18:34 +01:00
memory_hotplug.c
mm, memory_hotplug: test_pages_in_a_zone do not pass the end of zone
2019-03-13 14:04:58 -07:00
mempolicy.c
mm: mempolicy: make mbind() return -EIO when MPOL_MF_STRICT is specified
2019-04-05 22:29:05 +02:00
mempool.c
Revert "mm, mempool: only set __GFP_NOMEMALLOC if there are free elements"
2016-07-28 16:07:41 -07:00
memtest.c
migrate.c
hugetlbfs: fix races and page leaks during migration
2019-03-13 14:04:54 -07:00
mincore.c
mm/mincore.c: make mincore() more conservative
2019-05-21 18:48:58 +02:00
mlock.c
mm/mlock.c: change count_mm_mlocked_page_nr return type
2019-07-10 09:55:43 +02:00
mm_init.c
mm: convert printk(KERN_<LEVEL> to pr_<level>
2016-03-17 15:09:34 -07:00
mmap.c
coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping
2019-08-06 18:29:41 +02:00
mmu_context.c
mm/mmu_context, sched/core: Fix mmu_context.h assumption
2016-04-28 11:44:19 +02:00
mmu_notifier.c
mm/mmu_notifier: use hlist_add_head_rcu()
2019-08-04 09:33:42 +02:00
mmzone.c
mm, page_alloc: inline the fast path of the zonelist iterator
2016-05-19 19:12:14 -07:00
mprotect.c
x86/speculation/l1tf: Disallow non privileged high MMIO PROT_NONE mappings
2018-08-15 18:14:45 +02:00
mremap.c
mremap: properly flush TLB before releasing the page
2018-10-20 09:51:31 +02:00
msync.c
mm/msync: use offset_in_page macro
2015-11-05 19:34:48 -08:00
nobootmem.c
mm: discard memblock data later
2017-08-24 17:12:19 -07:00
nommu.c
ptrace: Don't allow accessing an undumpable mm
2017-01-06 10:40:13 +01:00
oom_kill.c
oom, oom_reaper: do not enqueue same task twice
2019-02-12 19:45:02 +01:00
page-writeback.c
mm/page-writeback.c: don't break integrity writeback on ->writepage() error
2019-01-26 09:38:35 +01:00
page_alloc.c
mem-hotplug: fix node spanned pages when we have a node with only ZONE_MOVABLE
2019-06-22 08:17:12 +02:00
page_counter.c
mm: page_counter: let page_counter_try_charge() return bool
2015-11-05 19:34:48 -08:00
page_ext.c
mm/page_ext.c: fix an imbalance with kmemleak
2019-04-05 22:29:06 +02:00
page_idle.c
mm/page_idle.c: fix oops because end_pfn is larger than max_pfn
2019-07-10 09:55:38 +02:00
page_io.c
mm/page_io.c: replace some BUG_ON()s with VM_BUG_ON_PAGE()
2016-10-07 18:46:29 -07:00
page_isolation.c
mm/page_isolation: fix typo: "paes" -> "pages"
2016-10-07 18:46:29 -07:00
page_owner.c
mm/page_owner: don't define fields on struct page_ext by hard-coding
2016-10-07 18:46:27 -07:00
page_poison.c
mm: check the return value of lookup_page_ext for all call sites
2016-06-03 15:06:22 -07:00
pagewalk.c
mm/pagewalk.c: report holes in hugetlb ranges
2017-11-24 08:33:42 +01:00
percpu-km.c
mm: percpu: use pr_fmt to prefix output
2016-03-17 15:09:34 -07:00
percpu-vm.c
percpu.c
percpu: stop printing kernel addresses
2019-04-27 09:34:47 +02:00
pgtable-generic.c
mm/thp/migration: switch from flush_tlb_range to flush_pmd_tlb_range
2016-03-17 15:09:34 -07:00
process_vm_access.c
mm: remove write/force parameters from __get_user_pages_unlocked()
2016-10-18 14:13:37 -07:00
quicklist.c
fix Christoph's email addresses
2016-03-17 15:09:34 -07:00
readahead.c
mm: silently skip readahead for DAX inodes
2016-08-26 17:39:35 -07:00
rmap.c
mm: migration: fix migration of huge PMD shared pages
2018-11-21 09:26:03 +01:00
shmem.c
tmpfs: fix uninitialized return value in shmem_link
2019-03-23 13:19:44 +01:00
slab.c
mm/slab.c: fix an infinite loop in leaks_show()
2019-06-22 08:17:13 +02:00
slab.h
slub: move synchronize_sched out of slab_mutex on shrink
2017-03-22 12:43:38 +01:00
slab_common.c
mm: don't warn about large allocations for slab
2018-12-01 09:44:19 +01:00
slob.c
slub: move synchronize_sched out of slab_mutex on shrink
2017-03-22 12:43:38 +01:00
slub.c
slub: make ->cpu_partial unsigned int
2018-10-03 17:01:50 -07:00
sparse-vmemmap.c
treewide: replace obsolete _refok by __ref
2016-08-02 17:31:41 -04:00
sparse.c
mm/memory_hotplug: set magic number to page->freelist instead of page->lru.next
2017-10-21 17:21:36 +02:00
swap.c
thp: reduce usage of huge zero page's atomic counter
2016-10-07 18:46:28 -07:00
swap_cgroup.c
mm, swap_cgroup: reschedule when neeed in swap_cgroup_swapoff()
2017-07-05 14:40:17 +02:00
swap_state.c
mm, swap: use offset of swap entry as key of swap cache
2016-10-07 18:46:28 -07:00
swapfile.c
x86/speculation/l1tf: Limit swap file size to MAX_PA/2
2018-08-15 18:14:45 +02:00
truncate.c
mm: cleancache: fix corruption on missed inode invalidation
2018-12-08 13:05:09 +01:00
usercopy.c
usercopy: Avoid HIGHMEM pfn warning
2019-10-17 13:42:06 -07:00
userfaultfd.c
mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros
2016-04-04 10:41:08 -07:00
util.c
mm: page_mapped: don't assume compound page is huge or THP
2019-01-16 22:12:32 +01:00
vmacache.c
mm: get rid of vmacache_flush_all() entirely
2018-09-19 22:47:17 +02:00
vmalloc.c
mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy()
2019-08-25 10:51:20 +02:00
vmpressure.c
mm: vmpressure: fix sending wrong events on underflow
2017-03-12 06:41:43 +01:00
vmscan.c
mm: remove seemingly spurious reclaimability check from laptop_mode gating
2018-09-19 22:47:12 +02:00
vmstat.c
mm/vmstat.c: fix /proc/vmstat format for CONFIG_DEBUG_TLBFLUSH=y CONFIG_SMP=n
2019-04-27 09:34:46 +02:00
workingset.c
mm: workingset: fix premature shadow node shrinking with cgroups
2017-04-08 09:30:36 +02:00
z3fold.c
mm/z3fold.c: avoid modifying HEADLESS page and minor cleanup
2016-06-03 16:02:55 -07:00
zbud.c
mm/zbud.c: use list_last_entry() instead of list_tail_entry()
2016-01-15 11:40:52 -08:00
zpool.c
mm: zsmalloc: constify struct zs_pool name
2015-11-06 17:50:42 -08:00
zsmalloc.c
mm/zsmalloc.c: fix build when CONFIG_COMPACTION=n
2019-09-06 10:19:54 +02:00
zswap.c
zswap: re-check zswap_is_full() after do zswap_shrink()
2018-09-05 09:20:02 +02:00