Add KernelMemorySanitizer infrastructure

Started by Alexander Potapenko on Dec 14, 2021 · 77 messages from 8 authors · Last reply Mar 25, 2022

Series

43 patches, 95 files

+4,062 −68

Subsystems (62)

Show 59 more

Maintainers (84)

Show 80 more
STALE1703d SUPERSEDED

Status: Superseded by v7 (posted 2022-09-15). [go to v7]

Revision v1 (7 revisions archived).

Revisions (7)
  1. v1 current re-posted go to this post
  2. v2 [diff against previous] re-posted go to this post
  3. v3 [diff against previous] re-posted go to this post
  4. v4 [diff against previous] re-posted go to this post
  5. v5 [diff against previous] re-posted go to this post
  6. v6 [diff against previous]
  7. v7 [diff against previous]

page 2 of 2 · open the first message on its own page

  1. [PATCH 01/43] arch/x86: add missing include to sparsemem.h
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  2. [PATCH 02/43] stackdepot: reserve 5 extra bits in depot_stack_handle_t
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  3. [PATCH 03/43] kasan: common: adapt to the new prototype of __stack_depot_save()
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  4. [PATCH 04/43] instrumented.h: allow instrumenting both sides of copy_from_user()
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  5. [PATCH 05/43] asm: x86: instrument usercopy in get_user() and __put_user_size()
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  6. [PATCH 06/43] asm-generic: instrument usercopy in cacheflush.h
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  7. [PATCH 07/43] compiler_attributes.h: add __disable_sanitizer_instrumentation
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  8. [PATCH 09/43] kmsan: introduce __no_sanitize_memory and __no_kmsan_checks
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  9. [PATCH 08/43] kmsan: add ReST documentation
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  10. [PATCH 10/43] kmsan: pgtable: reduce vmalloc space
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  11. [PATCH 11/43] libnvdimm/pfn_dev: increase MAX_STRUCT_PAGE_SIZE
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  12. [PATCH 12/43] kcsan: clang: retire CONFIG_KCSAN_KCOV_BROKEN
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  13. [PATCH 16/43] kmsan: mm: call KMSAN hooks from SLUB code
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  14. [PATCH 15/43] kmsan: mm: maintain KMSAN metadata for page operations
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  15. [PATCH 14/43] MAINTAINERS: add entry for KMSAN
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  16. [PATCH 13/43] kmsan: add KMSAN runtime core
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  17. [PATCH 17/43] kmsan: handle task creation and exiting
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  18. [PATCH 18/43] kmsan: unpoison @tlb in arch_tlb_gather_mmu()
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  19. [PATCH 20/43] instrumented.h: add KMSAN support
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  20. [PATCH 21/43] kmsan: mark noinstr as __no_sanitize_memory
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  21. [PATCH 22/43] kmsan: initialize the output of READ_ONCE_NOCHECK()
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  22. [PATCH 19/43] kmsan: init: call KMSAN initialization routines
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v4 [diff against previous] re-posted go to this post
    4. v5 [diff against previous] re-posted go to this post
    5. v3 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  23. [PATCH 23/43] kmsan: make READ_ONCE_TASK_STACK() return initialized values
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  24. [PATCH 24/43] kmsan: disable KMSAN instrumentation for certain kernel parts
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  25. [PATCH 25/43] kmsan: skip shadow checks in files doing context switches
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v2 [diff against previous] re-posted go to this post
    3. v3 [diff against previous] re-posted go to this post
    4. v4 [diff against previous] re-posted go to this post
    5. v5 [diff against previous] re-posted go to this post
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  26. [PATCH 26/43] kmsan: virtio: check/unpoison scatterlist in vring_map_one_sg()
    Revisions and related patches
    Revisions (7)
    1. v1 current re-posted go to this post
    2. v3 [diff against previous] re-posted go to this post
    3. v4 [diff against previous] re-posted go to this post
    4. v5 [diff against previous] re-posted go to this post
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  27. [PATCH 27/43] x86: kmsan: add iomem support
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  28. [PATCH 28/43] kmsan: dma: unpoison DMA mappings
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  29. [PATCH 29/43] kmsan: handle memory sent to/from USB
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  30. [PATCH 31/43] kmsan: disable strscpy() optimization under KMSAN
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  31. [PATCH 32/43] crypto: kmsan: disable accelerated configs under KMSAN
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  32. [PATCH 33/43] kmsan: disable physical page merging in biovec
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  33. [PATCH 34/43] kmsan: block: skip bio block merging logic for KMSAN
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  34. [PATCH 30/43] kmsan: add tests for KMSAN
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  35. [PATCH 35/43] x86: kmsan: use __msan_ string functions where possible.
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  36. [PATCH 37/43] x86: kasan: kmsan: support CONFIG_GENERIC_CSUM on x86, enable it for KASAN/KMSAN
    Revisions and related patches
    Revisions (7)
    1. v4 re-posted go to this post
    2. v5 [diff against previous] re-posted go to this post
    3. v1 current [diff against previous]
    4. v2 [diff against previous]
    5. v3 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  37. [PATCH 36/43] x86: kmsan: sync metadata pages on page fault
    Revisions and related patches
    Revisions (7)
    1. v3 re-posted go to this post
    2. v4 [diff against previous] re-posted go to this post
    3. v5 [diff against previous] re-posted go to this post
    4. v1 current [diff against previous]
    5. v2 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  38. [PATCH 38/43] x86: fs: kmsan: disable CONFIG_DCACHE_WORD_ACCESS
    Revisions and related patches
    Revisions (7)
    1. v4 re-posted go to this post
    2. v5 [diff against previous] re-posted go to this post
    3. v1 current [diff against previous]
    4. v2 [diff against previous]
    5. v3 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  39. [PATCH 39/43] x86: kmsan: handle register passing from uninstrumented code
    Revisions and related patches
    Revisions (7)
    1. v4 re-posted go to this post
    2. v1 current [diff against previous]
    3. v2 [diff against previous]
    4. v3 [diff against previous]
    5. v5 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  40. [PATCH 40/43] kmsan: kcov: unpoison area->list in kcov_remote_area_put()
    Revisions and related patches
    Revisions (7)
    1. v4 re-posted go to this post
    2. v1 current [diff against previous]
    3. v2 [diff against previous]
    4. v3 [diff against previous]
    5. v5 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  41. [PATCH 41/43] security: kmsan: fix interoperability with auto-initialization
    Revisions and related patches
    Revisions (7)
    1. v4 re-posted go to this post
    2. v1 current [diff against previous]
    3. v2 [diff against previous]
    4. v3 [diff against previous]
    5. v5 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  42. [PATCH 42/43] objtool: kmsan: list KMSAN API functions as uaccess-safe
    Revisions and related patches
    Revisions (7)
    1. v4 re-posted go to this post
    2. v1 current [diff against previous]
    3. v2 [diff against previous]
    4. v3 [diff against previous]
    5. v5 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]
  43. [PATCH 43/43] x86: kmsan: enable KMSAN builds for x86
    Revisions and related patches
    Revisions (7)
    1. v1 current
    2. v2 [diff against previous]
    3. v3 [diff against previous]
    4. v4 [diff against previous]
    5. v5 [diff against previous]
    6. v6 [diff against previous]
    7. v7 [diff against previous]

Re: [PATCH 13/43] kmsan: add KMSAN runtime core

Message details and related content
quoted
Just to make sure I don't misunderstand - for example for "kmsan: mm:
call KMSAN hooks from SLUB code", would it be better to pull the code
in mm/kmsan/core.c implementing kmsan_slab_alloc() and
kmsan_slab_free() into that patch?
Yes.
quoted
I thought maintainers would prefer to have patches to their code
separated from KMSAN code, but if it's not true, I can surely fix
that.
As a maintainer, I want to know what the function call that you just
added to my subsystem to call does.  Wouldn't you?  Put it all in the
same patch.
Ok, will be done in v2, thanks!
Think about submitting a patch series as telling a story.  You need to
show the progression forward of the feature so that everyone can
understand what is going on.  To just throw tiny snippets at us is
impossible to follow along with what your goal is.

You want reviewers to be able to easily see if the things you describe
being done in the changelog actually are implemented in the diff.
Dividing stuff up by files does not show that at all.

thanks,

greg k-h


-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Liana Sebastian
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Falls Sie diese fälschlicherweise
erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes
weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich
bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.


This e-mail is confidential. If you received this communication by
mistake, please don't forward it to anyone else, please erase all
copies and attachments, and please let me know that it has gone to the
wrong person.

Re: [PATCH 16/43] kmsan: mm: call KMSAN hooks from SLUB code

Message details and related content
quoted
 static inline void *get_freepointer(struct kmem_cache *s, void *object)
 {
      object = kasan_reset_tag(object);
-     return freelist_dereference(s, object + s->offset);
+     return kmsan_init(freelist_dereference(s, object + s->offset));
... but I don't see why it applies to get_freepointer() too? What am I missing?
Agreed, kmsan_init() is not needed here.
quoted
 }

 static void prefetch_freepointer(const struct kmem_cache *s, void *object)
@@ -357,18 +361,28 @@ static void prefetch_freepointer(const struct kmem_cache *s, void *object)
      prefetchw(object + s->offset);
 }

+/*
+ * When running under KMSAN, get_freepointer_safe() may return an uninitialized
+ * pointer value in the case the current thread loses the race for the next
+ * memory chunk in the freelist. In that case this_cpu_cmpxchg_double() in
+ * slab_alloc_node() will fail, so the uninitialized value won't be used, but
+ * KMSAN will still check all arguments of cmpxchg because of imperfect
+ * handling of inline assembly.
+ * To work around this problem, use kmsan_init() to force initialize the
+ * return value of get_freepointer_safe().
+ */
 static inline void *get_freepointer_safe(struct kmem_cache *s, void *object)
 {
      unsigned long freepointer_addr;
      void *p;

      if (!debug_pagealloc_enabled_static())
-             return get_freepointer(s, object);
+             return kmsan_init(get_freepointer(s, object));
So here kmsan_init() is done twice?
Yeah, removing it from get_freepointer() does not introduce new
errors. I'll fix this in v2.

Previous page

Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help