The patch titled Subject: x86: add missing include to sparsemem.h has been added to the -mm mm-unstable branch. Its filename is x86-add-missing-include-to-sparsememh.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/x86-add-missing-include-to-sparsememh.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Subject: x86: add missing include to sparsemem.h Date: Fri, 26 Aug 2022 17:07:24 +0200 Patch series ""Ad KernelMemorySanitizer infrastructure", v5. KernelMemorySanitizer (KMSAN) is a detector of errors related to uses of uninitialized memory. It relies on compile-time Clang instrumentation (similar to MSan in the userspace [1]) and tracks the state of every bit of kernel memory, being able to report an error if uninitialized value is used in a condition, dereferenced, or escapes to userspace, USB or DMA. KMSAN has reported more than 300 bugs in the past few years (recently fixed bugs: [2]), most of them with the help of syzkaller. Such bugs keep getting introduced into the kernel despite new compiler warnings and other analyses (the 6.0 cycle already resulted in several KMSAN-reported bugs, e.g. [3]). Mitigations like total stack and heap initialization are unfortunately very far from being deployable. The proposed patchset contains KMSAN runtime implementation together with small changes to other subsystems needed to make KMSAN work. The latter changes fall into several categories: 1. Changes and refactorings of existing code required to add KMSAN: - [01/44] x86: add missing include to sparsemem.h - [02/44] stackdepot: reserve 5 extra bits in depot_stack_handle_t - [03/44] instrumented.h: allow instrumenting both sides of copy_from_user() - [04/44] x86: asm: instrument usercopy in get_user() and __put_user_size() - [05/44] asm-generic: instrument usercopy in cacheflush.h - [10/44] libnvdimm/pfn_dev: increase MAX_STRUCT_PAGE_SIZE 2. KMSAN-related declarations in generic code, KMSAN runtime library, docs and configs: - [06/44] kmsan: add ReST documentation - [07/44] kmsan: introduce __no_sanitize_memory and __no_kmsan_checks - [09/44] x86: kmsan: pgtable: reduce vmalloc space - [11/44] kmsan: add KMSAN runtime core - [13/44] MAINTAINERS: add entry for KMSAN - [25/44] kmsan: add tests for KMSAN - [32/44] objtool: kmsan: list KMSAN API functions as uaccess-safe - [36/44] x86: kmsan: use __msan_ string functions where possible - [44/44] x86: kmsan: enable KMSAN builds for x86 3. Adding hooks from different subsystems to notify KMSAN about memory state changes: - [14/44] mm: kmsan: maintain KMSAN metadata for page - [15/44] mm: kmsan: call KMSAN hooks from SLUB code - [16/44] kmsan: handle task creation and exiting - [17/44] init: kmsan: call KMSAN initialization routines - [18/44] instrumented.h: add KMSAN support - [20/44] kmsan: add iomap support - [21/44] Input: libps2: mark data received in __ps2_command() as initialized - [22/44] dma: kmsan: unpoison DMA mappings - [35/44] x86: kmsan: handle open-coded assembly in lib/iomem.c - [37/43] x86: kmsan: sync metadata pages on page fault 4. Changes that prevent false reports by explicitly initializing memory, disabling optimized code that may trick KMSAN, selectively skipping instrumentation: - [08/44] kmsan: mark noinstr as __no_sanitize_memory - [12/44] kmsan: disable instrumentation of unsupported common kernel code - [19/44] kmsan: unpoison @tlb in arch_tlb_gather_mmu() - [23/44] virtio: kmsan: check/unpoison scatterlist in vring_map_one_sg() - [24/44] kmsan: handle memory sent to/from USB - [26/44] kmsan: disable strscpy() optimization under KMSAN - [27/44] crypto: kmsan: disable accelerated configs under KMSAN - [28/44] kmsan: disable physical page merging in biovec - [29/44] block: kmsan: skip bio block merging logic for KMSAN - [30/44] kcov: kmsan: unpoison area->list in kcov_remote_area_put() - [31/44] security: kmsan: fix interoperability with auto-initialization - [33/44] x86: kmsan: disable instrumentation of unsupported code - [34/44] x86: kmsan: skip shadow checks in __switch_to() - [38/44] x86: kasan: kmsan: support CONFIG_GENERIC_CSUM on x86, enable it for KASAN/KMSAN - [39/44] x86: fs: kmsan: disable CONFIG_DCACHE_WORD_ACCESS - [40/44] x86: kmsan: don't instrument stack walking functions - [41/44] entry: kmsan: introduce kmsan_unpoison_entry_regs() 5. Fixes for bugs detected with CONFIG_KMSAN_CHECK_PARAM_RETVAL: - [42/44] bpf: kmsan: initialize BPF registers with zeroes - [43/44] mm: fs: initialize fsdata passed to write_begin/write_end interface This patchset allows one to boot and run a defconfig+KMSAN kernel on a QEMU without known false positives. It however doesn't guarantee there are no false positives in drivers of certain devices or less tested subsystems, although KMSAN is actively tested on syzbot with a large config. By default, KMSAN enforces conservative checks of most kernel function parameters passed by value (via CONFIG_KMSAN_CHECK_PARAM_RETVAL, which maps to the -fsanitize-memory-param-retval compiler flag). As discussed in [4] and [5], passing uninitialized values as function parameters is considered undefined behavior, therefore KMSAN now reports such cases as errors. Several newly added patches fix known manifestations of these errors. The most up-to-date KMSAN tree currently resides at https://github.com/google/kmsan/. One may find it handy to review these patches in Gerrit [6]. A huge thanks goes to the reviewers of the RFC patch series sent to LKML in 2020 ([7]). [1] https://clang.llvm.org/docs/MemorySanitizer.html [2] https://syzkaller.appspot.com/upstream/fixed?manager=ci-upstream-kmsan-gce [3] https://lore.kernel.org/all/0000000000002c7abf05e721698d@xxxxxxxxxx/ [4] https://lore.kernel.org/all/20220614144853.3693273-1-glider@xxxxxxxxxx/ [5] https://lore.kernel.org/linux-mm/20220701142310.2188015-45-glider@xxxxxxxxxx/ [6] https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/12604/ [7] https://lore.kernel.org/all/20200325161249.55095-1-glider@xxxxxxxxxx/ This patch (of 44): Including sparsemem.h from other files (e.g. transitively via asm/pgtable_64_types.h) results in compilation errors due to unknown types: sparsemem.h:34:32: error: unknown type name 'phys_addr_t' extern int phys_to_target_node(phys_addr_t start); ^ sparsemem.h:36:39: error: unknown type name 'u64' extern int memory_add_physaddr_to_nid(u64 start); ^ Fix these errors by including linux/types.h from sparsemem.h This is required for the upcoming KMSAN patches. Link: https://lkml.kernel.org/r/20220826150807.723137-2-glider@xxxxxxxxxx Link: https://lkml.kernel.org/r/20220826150807.723137-1-glider@xxxxxxxxxx Signed-off-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Signed-off-by: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Alexei Starovoitov <ast@xxxxxxxxxx> Cc: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Cc: Andy Lutomirski <luto@xxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Borislav Petkov <bp@xxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Eric Dumazet <edumazet@xxxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Cc: Ilya Leoshkevich <iii@xxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: kasan-dev@xxxxxxxxxxxxxxxx Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Marco Elver <elver@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Michael S. Tsirkin <mst@xxxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Petr Mladek <pmladek@xxxxxxxx> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx> Cc: Vegard Nossum <vegard.nossum@xxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Andrey Konovalov <andreyknvl@xxxxxxxxx> Cc: Eric Biggers <ebiggers@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/x86/include/asm/sparsemem.h | 2 ++ 1 file changed, 2 insertions(+) --- a/arch/x86/include/asm/sparsemem.h~x86-add-missing-include-to-sparsememh +++ a/arch/x86/include/asm/sparsemem.h @@ -2,6 +2,8 @@ #ifndef _ASM_X86_SPARSEMEM_H #define _ASM_X86_SPARSEMEM_H +#include <linux/types.h> + #ifdef CONFIG_SPARSEMEM /* * generic non-linear memory support: _ Patches currently in -mm which might be from dvyukov@xxxxxxxxxx are x86-add-missing-include-to-sparsememh.patch