linux-sg2042/arch/x86
Ma Wupeng d155df53f3 x86/mm/pat: clear VM_PAT if copy_p4d_range failed
Syzbot reports a warning in untrack_pfn().  Digging into the root we found
that this is due to memory allocation failure in pmd_alloc_one.  And this
failure is produced due to failslab.

In copy_page_range(), memory alloaction for pmd failed.  During the error
handling process in copy_page_range(), mmput() is called to remove all
vmas.  While untrack_pfn this empty pfn, warning happens.

Here's a simplified flow:

dup_mm
  dup_mmap
    copy_page_range
      copy_p4d_range
        copy_pud_range
          copy_pmd_range
            pmd_alloc
              __pmd_alloc
                pmd_alloc_one
                  page = alloc_pages(gfp, 0);
                    if (!page)
                      return NULL;
    mmput
        exit_mmap
          unmap_vmas
            unmap_single_vma
              untrack_pfn
                follow_phys
                  WARN_ON_ONCE(1);

Since this vma is not generate successfully, we can clear flag VM_PAT.  In
this case, untrack_pfn() will not be called while cleaning this vma.

Function untrack_pfn_moved() has also been renamed to fit the new logic.

Link: https://lkml.kernel.org/r/20230217025615.1595558-1-mawupeng1@huawei.com
Signed-off-by: Ma Wupeng <mawupeng1@huawei.com>
Reported-by: <syzbot+5f488e922d047d8f00cc@syzkaller.appspotmail.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-03-28 16:20:07 -07:00
..
boot Kbuild updates for v6.3 2023-02-26 11:53:25 -08:00
coco - Fixup comment typo 2023-02-25 09:11:30 -08:00
configs x86/defconfig: Enable CONFIG_DEBUG_WX=y 2022-09-02 10:41:42 +02:00
crypto crypto: x86/aria-avx - Do not use avx2 instructions 2023-02-14 13:39:33 +08:00
entry Changes in this cycle were: 2023-03-02 09:45:34 -08:00
events perf/x86/amd/core: Always clear status for idx 2023-03-21 14:43:05 +01:00
hyperv x86/hyperv: Remove unregister syscore call from Hyper-V cleanup 2022-11-29 17:55:29 +00:00
ia32 x86/signal/32: Merge native and compat 32-bit signal code 2022-10-19 09:58:49 +02:00
include - Check cmdline_find_option()'s return value before further processing 2023-03-19 09:43:41 -07:00
kernel - Add a AMX ptrace self test 2023-03-26 09:01:24 -07:00
kvm KVM: SVM: WARN if GATag generation drops VM or vCPU ID information 2023-03-14 10:20:07 -04:00
lib - Cache the AMD debug registers in per-CPU variables to avoid MSR writes 2023-02-21 14:51:40 -08:00
math-emu
mm x86/mm/pat: clear VM_PAT if copy_p4d_range failed 2023-03-28 16:20:07 -07:00
net bpf, x86: Simplify the parsing logic of structure parameters 2023-01-10 15:53:22 -08:00
pci x86/pci/xen: Fixup fallout from the PCI/MSI overhaul 2023-01-16 20:40:44 +01:00
platform A healthy mix of EFI contributions this time: 2023-02-23 14:41:48 -08:00
power - Add the call depth tracking mitigation for Retbleed which has 2022-12-14 15:03:00 -08:00
purgatory x86/purgatory: disable KMSAN instrumentation 2022-10-28 13:37:23 -07:00
ras
realmode x86/boot: Skip realmode init code when running as Xen PV guest 2022-11-25 12:05:22 +01:00
tools kbuild: allow to combine multiple V= levels 2023-01-22 23:43:32 +09:00
um This pull request contains the following changes for UML: 2023-03-01 09:13:00 -08:00
video
virt/vmx/tdx
xen xen: branch for v6.3-rc4 2023-03-24 09:44:43 -07:00
.gitignore
Kbuild
Kconfig x86/Kconfig: Fix spellos & punctuation 2023-01-25 12:21:04 +01:00
Kconfig.assembler crypto: x86/aria-avx - fix build failure with old binutils 2023-01-20 18:29:31 +08:00
Kconfig.cpu
Kconfig.debug
Makefile x86/build: Make 64-bit defconfig the default 2023-02-15 14:20:17 +01:00
Makefile.um This pull request contains the following changes for UML: 2023-03-01 09:13:00 -08:00
Makefile_32.cpu