Revision d12d9ad816299052385bac351fad338a073121b3 authored by Andrey Konovalov on 26 February 2021, 01:20:23 UTC, committed by Linus Torvalds on 26 February 2021, 17:41:03 UTC
Currently, krealloc() always calls ksize(), which unpoisons the whole object including the redzone. This is inefficient, as kasan_krealloc() repoisons the redzone for objects that fit into the same buffer. This patch changes krealloc() instrumentation to use uninstrumented __ksize() that doesn't unpoison the memory. Instead, kasan_kreallos() is changed to unpoison the memory excluding the redzone. For objects that don't fit into the old allocation, this patch disables KASAN accessibility checks when copying memory into a new object instead of unpoisoning it. Link: https://lkml.kernel.org/r/9bef90327c9cb109d736c40115684fd32f49e6b0.1612546384.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reviewed-by: Marco Elver <elver@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Branislav Rankov <Branislav.Rankov@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Evgenii Stepanov <eugenis@google.com> Cc: Kevin Brodsky <kevin.brodsky@arm.com> Cc: Peter Collingbourne <pcc@google.com> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 26a5ca7
File | Mode | Size |
---|---|---|
kasan | ||
kfence | ||
Kconfig | -rw-r--r-- | 28.1 KB |
Kconfig.debug | -rw-r--r-- | 5.6 KB |
Makefile | -rw-r--r-- | 4.3 KB |
backing-dev.c | -rw-r--r-- | 25.1 KB |
balloon_compaction.c | -rw-r--r-- | 8.2 KB |
cleancache.c | -rw-r--r-- | 9.8 KB |
cma.c | -rw-r--r-- | 14.9 KB |
cma.h | -rw-r--r-- | 646 bytes |
cma_debug.c | -rw-r--r-- | 4.5 KB |
compaction.c | -rw-r--r-- | 81.5 KB |
debug.c | -rw-r--r-- | 8.4 KB |
debug_page_ref.c | -rw-r--r-- | 1.4 KB |
debug_vm_pgtable.c | -rw-r--r-- | 31.3 KB |
dmapool.c | -rw-r--r-- | 13.7 KB |
early_ioremap.c | -rw-r--r-- | 6.8 KB |
fadvise.c | -rw-r--r-- | 5.3 KB |
failslab.c | -rw-r--r-- | 1.4 KB |
filemap.c | -rw-r--r-- | 105.3 KB |
frontswap.c | -rw-r--r-- | 14.2 KB |
gup.c | -rw-r--r-- | 81.1 KB |
gup_test.c | -rw-r--r-- | 5.4 KB |
gup_test.h | -rw-r--r-- | 915 bytes |
highmem.c | -rw-r--r-- | 19.3 KB |
hmm.c | -rw-r--r-- | 16.6 KB |
huge_memory.c | -rw-r--r-- | 83.2 KB |
hugetlb.c | -rw-r--r-- | 155.0 KB |
hugetlb_cgroup.c | -rw-r--r-- | 21.4 KB |
hwpoison-inject.c | -rw-r--r-- | 2.6 KB |
init-mm.c | -rw-r--r-- | 1.3 KB |
internal.h | -rw-r--r-- | 19.2 KB |
interval_tree.c | -rw-r--r-- | 3.1 KB |
ioremap.c | -rw-r--r-- | 6.5 KB |
khugepaged.c | -rw-r--r-- | 59.0 KB |
kmemleak.c | -rw-r--r-- | 56.2 KB |
ksm.c | -rw-r--r-- | 88.8 KB |
list_lru.c | -rw-r--r-- | 14.2 KB |
maccess.c | -rw-r--r-- | 8.7 KB |
madvise.c | -rw-r--r-- | 30.3 KB |
mapping_dirty_helpers.c | -rw-r--r-- | 10.5 KB |
memblock.c | -rw-r--r-- | 58.8 KB |
memcontrol.c | -rw-r--r-- | 190.4 KB |
memfd.c | -rw-r--r-- | 7.9 KB |
memory-failure.c | -rw-r--r-- | 52.8 KB |
memory.c | -rw-r--r-- | 141.7 KB |
memory_hotplug.c | -rw-r--r-- | 53.8 KB |
mempolicy.c | -rw-r--r-- | 76.4 KB |
mempool.c | -rw-r--r-- | 15.8 KB |
memremap.c | -rw-r--r-- | 14.4 KB |
memtest.c | -rw-r--r-- | 2.8 KB |
migrate.c | -rw-r--r-- | 82.3 KB |
mincore.c | -rw-r--r-- | 7.0 KB |
mlock.c | -rw-r--r-- | 22.2 KB |
mm_init.c | -rw-r--r-- | 5.3 KB |
mmap.c | -rw-r--r-- | 102.9 KB |
mmap_lock.c | -rw-r--r-- | 5.8 KB |
mmu_gather.c | -rw-r--r-- | 8.2 KB |
mmu_notifier.c | -rw-r--r-- | 34.3 KB |
mmzone.c | -rw-r--r-- | 2.2 KB |
mprotect.c | -rw-r--r-- | 17.3 KB |
mremap.c | -rw-r--r-- | 25.8 KB |
msync.c | -rw-r--r-- | 2.6 KB |
nommu.c | -rw-r--r-- | 44.9 KB |
oom_kill.c | -rw-r--r-- | 30.3 KB |
page-writeback.c | -rw-r--r-- | 84.6 KB |
page_alloc.c | -rw-r--r-- | 248.7 KB |
page_counter.c | -rw-r--r-- | 6.6 KB |
page_ext.c | -rw-r--r-- | 10.9 KB |
page_idle.c | -rw-r--r-- | 5.3 KB |
page_io.c | -rw-r--r-- | 11.3 KB |
page_isolation.c | -rw-r--r-- | 9.2 KB |
page_owner.c | -rw-r--r-- | 16.3 KB |
page_poison.c | -rw-r--r-- | 2.3 KB |
page_reporting.c | -rw-r--r-- | 9.9 KB |
page_reporting.h | -rw-r--r-- | 1.6 KB |
page_vma_mapped.c | -rw-r--r-- | 7.8 KB |
pagewalk.c | -rw-r--r-- | 14.2 KB |
percpu-internal.h | -rw-r--r-- | 7.7 KB |
percpu-km.c | -rw-r--r-- | 3.0 KB |
percpu-stats.c | -rw-r--r-- | 6.0 KB |
percpu-vm.c | -rw-r--r-- | 10.3 KB |
percpu.c | -rw-r--r-- | 95.6 KB |
pgalloc-track.h | -rw-r--r-- | 1.3 KB |
pgtable-generic.c | -rw-r--r-- | 5.6 KB |
process_vm_access.c | -rw-r--r-- | 8.2 KB |
ptdump.c | -rw-r--r-- | 4.0 KB |
readahead.c | -rw-r--r-- | 17.3 KB |
rmap.c | -rw-r--r-- | 55.7 KB |
rodata_test.c | -rw-r--r-- | 1.3 KB |
shmem.c | -rw-r--r-- | 110.0 KB |
shuffle.c | -rw-r--r-- | 4.7 KB |
shuffle.h | -rw-r--r-- | 1.1 KB |
slab.c | -rw-r--r-- | 106.3 KB |
slab.h | -rw-r--r-- | 16.7 KB |
slab_common.c | -rw-r--r-- | 32.0 KB |
slob.c | -rw-r--r-- | 18.2 KB |
slub.c | -rw-r--r-- | 143.3 KB |
sparse-vmemmap.c | -rw-r--r-- | 6.8 KB |
sparse.c | -rw-r--r-- | 26.4 KB |
swap.c | -rw-r--r-- | 30.6 KB |
swap_cgroup.c | -rw-r--r-- | 5.1 KB |
swap_slots.c | -rw-r--r-- | 9.3 KB |
swap_state.c | -rw-r--r-- | 24.4 KB |
swapfile.c | -rw-r--r-- | 96.0 KB |
truncate.c | -rw-r--r-- | 25.6 KB |
usercopy.c | -rw-r--r-- | 9.5 KB |
userfaultfd.c | -rw-r--r-- | 17.6 KB |
util.c | -rw-r--r-- | 25.1 KB |
vmacache.c | -rw-r--r-- | 2.7 KB |
vmalloc.c | -rw-r--r-- | 91.7 KB |
vmpressure.c | -rw-r--r-- | 13.9 KB |
vmscan.c | -rw-r--r-- | 123.9 KB |
vmstat.c | -rw-r--r-- | 53.8 KB |
workingset.c | -rw-r--r-- | 21.3 KB |
z3fold.c | -rw-r--r-- | 46.6 KB |
zbud.c | -rw-r--r-- | 18.2 KB |
zpool.c | -rw-r--r-- | 11.5 KB |
zsmalloc.c | -rw-r--r-- | 61.1 KB |
zswap.c | -rw-r--r-- | 39.0 KB |
Computing file changes ...