1. 06 Feb, 2022 6 commits
    • Leo Yan's avatar
      perf synthetic-events: Return error if procfs isn't mounted for PID namespaces · bc9c806e
      Leo Yan authored
      For perf recording, it retrieves process info by iterating nodes in proc
      fs.  If we run perf in a non-root PID namespace with command:
      
        # unshare --fork --pid perf record -e cycles -a -- test_program
      
      ... in this case, unshare command creates a child PID namespace and
      launches perf tool in it, but the issue is the proc fs is not mounted
      for the non-root PID namespace, this leads to the perf tool gathering
      process info from its parent PID namespace.
      
      We can use below command to observe the process nodes under proc fs:
      
        # unshare --pid --fork ls /proc
      1    137   1968  2128  3    342  48  62   78	     crypto	  kcore        net	      uptime
      10   138   2	 2142  30   35	 49  63   8	     devices	  keys	       pagetypeinfo   version
      11   139   20	 2143  304  36	 50  64   82	     device-tree  key-users    partitions     vmallocinfo
      12   14    2011  22    305  37	 51  65   83	     diskstats	  kmsg	       self	      vmstat
      128  140   2038  23    307  39	 52  656  84	     driver	  kpagecgroup  slabinfo       zoneinfo
      129  15    2074  24    309  4	 53  67   9	     execdomains  kpagecount   softirqs
      13   16    2094  241   31   40	 54  68   asound     fb		  kpageflags   stat
      130  164   2096  242   310  41	 55  69   buddyinfo  filesystems  loadavg      swaps
      131  17    2098  25    317  42	 56  70   bus	     fs		  locks        sys
      132  175   21	 26    32   43	 57  71   cgroups    interrupts   meminfo      sysrq-trigger
      133  179   2102  263   329  44	 58  75   cmdline    iomem	  misc	       sysvipc
      134  1875  2103  27    330  45	 59  76   config.gz  ioports	  modules      thread-self
      135  19    2117  29    333  46	 6   77   consoles   irq	  mounts       timer_list
      136  1941  2121  298   34   47	 60  773  cpuinfo    kallsyms	  mtd	       tty
      
      So it shows many existed tasks, since unshared command has not mounted
      the proc fs for the new created PID namespace, it still accesses the
      proc fs of the root PID namespace.  This leads to two prominent issues:
      
      - Firstly, PID values are mismatched between thread info and samples.
        The gathered thread info are coming from the proc fs of the root PID
        namespace, but samples record its PID from the child PID namespace.
      
      - The second issue is profiled program 'test_program' returns its forked
        PID number from the child PID namespace, perf tool wrongly uses this
        PID number to retrieve the process info via the proc fs of the root
        PID namespace.
      
      To avoid issues, we need to mount proc fs for the child PID namespace
      with the option '--mount-proc' when use unshare command:
      
        # unshare --fork --pid --mount-proc perf record -e cycles -a -- test_program
      
      Conversely, when the proc fs of the root PID namespace is used by child
      namespace, perf tool can detect the multiple PID levels and
      nsinfo__is_in_root_namespace() returns false, this patch reports error
      for this case:
      
        # unshare --fork --pid perf record -e cycles -a -- test_program
        Couldn't synthesize bpf events.
        Perf runs in non-root PID namespace but it tries to gather process info from its parent PID namespace.
        Please mount the proc file system properly, e.g. add the option '--mount-proc' for unshare command.
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/r/20211224124014.2492751-1-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc9c806e
    • Ameer Hamza's avatar
      perf session: Check for NULL pointer before dereference · d792a7a9
      Ameer Hamza authored
      Move NULL pointer check before dereferencing the variable.
      
      Addresses-Coverity: 1497622 ("Derereference before null check")
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarAmeer Hamza <amhamza.mgc@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Link: https://lore.kernel.org/r/20220125121141.18347-1-amhamza.mgc@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d792a7a9
    • Namhyung Kim's avatar
      perf annotate: Set error stream of objdump process for TUI · a663520f
      Namhyung Kim authored
      The stderr should be set to a pipe when using TUI.  Otherwise it'd
      print to stdout and break TUI windows with an error message.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20220202070828.143303-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a663520f
    • Anshuman Khandual's avatar
      perf tools: Add missing branch_sample_type to perf_event_attr__fprintf() · ae65b443
      Anshuman Khandual authored
      This updates branch sample type with missing PERF_SAMPLE_BRANCH_TYPE_SAVE.
      Suggested-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lore.kernel.org/lkml/1643799443-15109-1-git-send-email-anshuman.khandual@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae65b443
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/kvm.h with the kernel sources · b7b9825f
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        f6c6804c ("kvm: Move KVM_GET_XSAVE2 IOCTL definition at the end of kvm.h")
      
      That just rebuilds perf, as these patches don't add any new KVM ioctl to
      be harvested for the the 'perf trace' ioctl syscall argument
      beautifiers.
      
      This is also by now used by tools/testing/selftests/kvm/, a simple test
      build succeeded.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
        diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
      
      Cc: Janosch Frank <frankja@linux.ibm.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Link: http://lore.kernel.org/lkml/Yf+4k5Fs5Q3HdSG9@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b7b9825f
    • Arnaldo Carvalho de Melo's avatar
      Merge remote-tracking branch 'torvalds/master' into perf/urgent · 9334030c
      Arnaldo Carvalho de Melo authored
      To check if more kernel API sync is needed and also to see if the perf
      build tests continue to pass.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9334030c
  2. 05 Feb, 2022 7 commits
    • Linus Torvalds's avatar
      Merge tag 'for-linus-5.17a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 90c9e950
      Linus Torvalds authored
      Pull xen fixes from Juergen Gross:
      
       - documentation fixes related to Xen
      
       - enable x2apic mode when available when running as hardware
         virtualized guest under Xen
      
       - cleanup and fix a corner case of vcpu enumeration when running a
         paravirtualized Xen guest
      
      * tag 'for-linus-5.17a-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        x86/Xen: streamline (and fix) PV CPU enumeration
        xen: update missing ioctl magic numers documentation
        Improve docs for IOCTL_GNTDEV_MAP_GRANT_REF
        xen: xenbus_dev.h: delete incorrect file name
        xen/x2apic: enable x2apic mode when supported for HVM
      90c9e950
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 5fdb2621
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "ARM:
      
         - A couple of fixes when handling an exception while a SError has
           been delivered
      
         - Workaround for Cortex-A510's single-step erratum
      
        RISC-V:
      
         - Make CY, TM, and IR counters accessible in VU mode
      
         - Fix SBI implementation version
      
        x86:
      
         - Report deprecation of x87 features in supported CPUID
      
         - Preparation for fixing an interrupt delivery race on AMD hardware
      
         - Sparse fix
      
        All except POWER and s390:
      
         - Rework guest entry code to correctly mark noinstr areas and fix
           vtime' accounting (for x86, this was already mostly correct but not
           entirely; for ARM, MIPS and RISC-V it wasn't)"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: x86: Use ERR_PTR_USR() to return -EFAULT as a __user pointer
        KVM: x86: Report deprecated x87 features in supported CPUID
        KVM: arm64: Workaround Cortex-A510's single-step and PAC trap errata
        KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs
        KVM: arm64: Avoid consuming a stale esr value when SError occur
        RISC-V: KVM: Fix SBI implementation version
        RISC-V: KVM: make CY, TM, and IR counters accessible in VU mode
        kvm/riscv: rework guest entry logic
        kvm/arm64: rework guest entry logic
        kvm/x86: rework guest entry logic
        kvm/mips: rework guest entry logic
        kvm: add guest_state_{enter,exit}_irqoff()
        KVM: x86: Move delivery of non-APICv interrupt into vendor code
        kvm: Move KVM_GET_XSAVE2 IOCTL definition at the end of kvm.h
      5fdb2621
    • Linus Torvalds's avatar
      Merge tag 'xfs-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · fbc04bf0
      Linus Torvalds authored
      Pull xfs fixes from Darrick Wong:
       "I was auditing operations in XFS that clear file privileges, and
        realized that XFS' fallocate implementation drops suid/sgid but
        doesn't clear file capabilities the same way that file writes and
        reflink do.
      
        There are VFS helpers that do it correctly, so refactor XFS to use
        them. I also noticed that we weren't flushing the log at the correct
        point in the fallocate operation, so that's fixed too.
      
        Summary:
      
         - Fix fallocate so that it drops all file privileges when files are
           modified instead of open-coding that incompletely.
      
         - Fix fallocate to flush the log if the caller wanted synchronous
           file updates"
      
      * tag 'xfs-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: ensure log flush at the end of a synchronous fallocate call
        xfs: move xfs_update_prealloc_flags() to xfs_pnfs.c
        xfs: set prealloc flag in xfs_alloc_file_space()
        xfs: fallocate() should call file_modified()
        xfs: remove XFS_PREALLOC_SYNC
        xfs: reject crazy array sizes being fed to XFS_IOC_GETBMAP*
      fbc04bf0
    • Linus Torvalds's avatar
      Merge tag 'vfs-5.17-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · ea7b3e6d
      Linus Torvalds authored
      Pull vfs fixes from Darrick Wong:
       "I was auditing the sync_fs code paths recently and noticed that most
        callers of ->sync_fs ignore its return value (and many implementations
        never return nonzero even if the fs is broken!), which means that
        internal fs errors and corruption are not passed up to userspace
        callers of syncfs(2) or FIFREEZE. Hence fixing the common code and
        XFS, and I'll start working on the ext4/btrfs folks if this is merged.
      
        Summary:
      
         - Fix a bug where callers of ->sync_fs (e.g. sync_filesystem and
           syncfs(2)) ignore the return value.
      
         - Fix a bug where callers of sync_filesystem (e.g. fs freeze) ignore
           the return value.
      
         - Fix a bug in XFS where xfs_fs_sync_fs never passed back error
           returns"
      
      * tag 'vfs-5.17-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: return errors in xfs_fs_sync_fs
        quota: make dquot_quota_sync return errors from ->sync_fs
        vfs: make sync_filesystem return errors from ->sync_fs
        vfs: make freeze_super abort when sync_filesystem returns error
      ea7b3e6d
    • Linus Torvalds's avatar
      Merge tag 'iomap-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · 524446e2
      Linus Torvalds authored
      Pull iomap fix from Darrick Wong:
       "A single bugfix for iomap.
      
        The fix should eliminate occasional complaints about stall warnings
        when a lot of writeback IO completes all at once and we have to then
        go clearing status on a large number of folios.
      
        Summary:
      
         - Limit the length of ioend chains in writeback so that we don't trip
           the softlockup watchdog and to limit long tail latency on clearing
           PageWriteback"
      
      * tag 'iomap-5.17-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs, iomap: limit individual ioend chain lengths in writeback
      524446e2
    • Paolo Bonzini's avatar
      Merge tag 'kvmarm-fixes-5.17-2' of... · 7e6a6b40
      Paolo Bonzini authored
      Merge tag 'kvmarm-fixes-5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
      
      KVM/arm64 fixes for 5.17, take #2
      
      - A couple of fixes when handling an exception while a SError has been
        delivered
      
      - Workaround for Cortex-A510's single-step[ erratum
      7e6a6b40
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · 0457e515
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "Some medium sized bugs in the various drivers. A couple are more
        recent regressions:
      
         - Fix two panics in hfi1 and two allocation problems
      
         - Send the IGMP to the correct address in cma
      
         - Squash a syzkaller bug related to races reading the multicast list
      
         - Memory leak in siw and cm
      
         - Fix a corner case spec compliance for HFI/QIB
      
         - Correct the implementation of fences in siw
      
         - Error unwind bug in mlx4"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/mlx4: Don't continue event handler after memory allocation failure
        RDMA/siw: Fix broken RDMA Read Fence/Resume logic.
        IB/rdmavt: Validate remote_addr during loopback atomic tests
        IB/cm: Release previously acquired reference counter in the cm_id_priv
        RDMA/siw: Fix refcounting leak in siw_create_qp()
        RDMA/ucma: Protect mc during concurrent multicast leaves
        RDMA/cma: Use correct address when leaving multicast group
        IB/hfi1: Fix tstats alloc and dealloc
        IB/hfi1: Fix AIP early init panic
        IB/hfi1: Fix alloc failure with larger txqueuelen
        IB/hfi1: Fix panic with larger ipoib send_queue_size
      0457e515
  3. 04 Feb, 2022 27 commits
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · fc93310c
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "Seven fixes, six of which are fairly obvious driver fixes.
      
        The one core change to the device budget depth is to try to ensure
        that if the default depth is large (which can produce quite a sizeable
        bitmap allocation per device), we give back the memory we don't need
        if there's a queue size reduction in slave_configure (which happens to
        a lot of devices)"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: hisi_sas: Fix setting of hisi_sas_slot.is_internal
        scsi: pm8001: Fix use-after-free for aborted SSP/STP sas_task
        scsi: pm8001: Fix use-after-free for aborted TMF sas_task
        scsi: pm8001: Fix warning for undescribed param in process_one_iomb()
        scsi: core: Reallocate device's budget map on queue depth change
        scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe
        scsi: pm80xx: Fix double completion for SATA devices
      fc93310c
    • Linus Torvalds's avatar
      Merge tag 'pci-v5.17-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · e09e1a40
      Linus Torvalds authored
      Pull pci fixes from Bjorn Helgaas:
      
       - Restructure j721e_pcie_probe() so we don't dereference a NULL pointer
         (Bjorn Helgaas)
      
       - Add a kirin_pcie_data struct to identify different Kirin variants to
         fix probe failure for controllers with an internal PHY (Bjorn
         Helgaas)
      
      * tag 'pci-v5.17-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
        PCI: kirin: Add dev struct for of_device_get_match_data()
        PCI: j721e: Initialize pcie->cdns_pcie before using it
      e09e1a40
    • Bjorn Helgaas's avatar
      PCI: kirin: Add dev struct for of_device_get_match_data() · 7dd38762
      Bjorn Helgaas authored
      Bean reported that a622435f ("PCI: kirin: Prefer
      of_device_get_match_data()") broke kirin_pcie_probe() because it assumed
      match data of 0 was a failure when in fact, it meant the match data was
      "(void *)PCIE_KIRIN_INTERNAL_PHY".
      
      Therefore, probing of "hisilicon,kirin960-pcie" devices failed with -EINVAL
      and an "OF data missing" message.
      
      Add a struct kirin_pcie_data to encode the PHY type.  Then the result of
      of_device_get_match_data() should always be a non-NULL pointer to a struct
      kirin_pcie_data that contains the PHY type.
      
      Fixes: a622435f ("PCI: kirin: Prefer of_device_get_match_data()")
      Link: https://lore.kernel.org/r/20220202162659.GA12603@bhelgaas
      Link: https://lore.kernel.org/r/20220201215941.1203155-1-huobean@gmail.comReported-by: default avatarBean Huo <beanhuo@micron.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      7dd38762
    • Linus Torvalds's avatar
      Merge tag 'for-5.17-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 86286e48
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "A few fixes and error handling improvements:
      
         - fix deadlock between quota disable and qgroup rescan worker
      
         - fix use-after-free after failure to create a snapshot
      
         - skip warning on unmount after log cleanup failure
      
         - don't start transaction for scrub if the fs is mounted read-only
      
         - tree checker verifies item sizes"
      
      * tag 'for-5.17-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: skip reserved bytes warning on unmount after log cleanup failure
        btrfs: fix use of uninitialized variable at rm device ioctl
        btrfs: fix use-after-free after failure to create a snapshot
        btrfs: tree-checker: check item_size for dev_item
        btrfs: tree-checker: check item_size for inode_item
        btrfs: fix deadlock between quota disable and qgroup rescan worker
        btrfs: don't start transaction for scrub if the fs is mounted read-only
      86286e48
    • Linus Torvalds's avatar
      Merge tag 'erofs-for-5.17-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs · b0bc0cb8
      Linus Torvalds authored
      Pull erofs fixes from Gao Xiang:
       "Two fixes related to fsdax cleanup in this cycle and ztailpacking to
        fix small compressed data inlining. There is also a trivial cleanup to
        rearrange code for better reading.
      
        Summary:
      
         - fix fsdax partition offset misbehavior
      
         - clean up z_erofs_decompressqueue_work() declaration
      
         - fix up EOF lcluster inlining, especially for small compressed data"
      
      * tag 'erofs-for-5.17-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
        erofs: fix small compressed files inlining
        erofs: avoid unnecessary z_erofs_decompressqueue_work() declaration
        erofs: fix fsdax partition offset handling
      b0bc0cb8
    • Linus Torvalds's avatar
      Merge tag 'block-5.17-2022-02-04' of git://git.kernel.dk/linux-block · 7c4a9459
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
      
       - NVMe pull request
          - fix use-after-free in rdma and tcp controller reset (Sagi Grimberg)
          - fix the state check in nvmf_ctlr_matches_baseopts (Uday Shankar)
      
       - MD nowait null pointer fix (Song)
      
       - blk-integrity seed advance fix (Martin)
      
       - Fix a dio regression in this merge window (Ilya)
      
      * tag 'block-5.17-2022-02-04' of git://git.kernel.dk/linux-block:
        block: bio-integrity: Advance seed correctly for larger interval sizes
        nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts()
        md: fix NULL pointer deref with nowait but no mddev->queue
        block: fix DIO handling regressions in blkdev_read_iter()
        nvme-rdma: fix possible use-after-free in transport error_recovery work
        nvme-tcp: fix possible use-after-free in transport error_recovery work
        nvme: fix a possible use-after-free in controller reset during load
      7c4a9459
    • Linus Torvalds's avatar
      Merge tag 'ata-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata · 494a2c2b
      Linus Torvalds authored
      Pull ATA fixes from Damien Le Moal:
      
       - Sergey volunteered to be a reviewer for the Renesas R-Car SATA driver
         and PATA drivers. Update the MAINTAINERS file accordingly.
      
       - Regression fix: add a horkage flag to prevent accessing the log
         directory log page with SATADOM-ML 3ME SATA devices as they react
         badly to reading that log page (from Anton).
      
      * tag 'ata-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata:
        ata: libata-core: Introduce ATA_HORKAGE_NO_LOG_DIR horkage
        MAINTAINERS: add myself as Renesas R-Car SATA driver reviewer
        MAINTAINERS: add myself as PATA drivers reviewer
      494a2c2b
    • Linus Torvalds's avatar
      Merge tag 'iommu-fixes-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu · 07cd9ac4
      Linus Torvalds authored
      Pull iommu fixes from Joerg Roedel:
      
       - Warning fixes and a fix for a potential use-after-free in IOMMU core
         code
      
       - Another potential memory leak fix for the Intel VT-d driver
      
       - Fix for an IO polling loop timeout issue in the AMD IOMMU driver
      
      * tag 'iommu-fixes-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
        iommu/amd: Fix loop timeout issue in iommu_ga_log_enable()
        iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping()
        iommu: Fix some W=1 warnings
        iommu: Fix potential use-after-free during probe
      07cd9ac4
    • Linus Torvalds's avatar
      Merge tag 'random-5.17-rc3-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random · ba6ef8af
      Linus Torvalds authored
      Pull random number generator fixes from Jason Donenfeld:
       "For this week, we have:
      
         - A fix to make more frequent use of hwgenerator randomness, from
           Dominik.
      
         - More cleanups to the boot initialization sequence, from Dominik.
      
         - A fix for an old shortcoming with the ZAP ioctl, from me.
      
         - A workaround for a still unfixed Clang CFI/FullLTO compiler bug,
           from me. On one hand, it's a bummer to commit workarounds for
           experimental compiler features that have bugs. But on the other, I
           think this actually improves the code somewhat, independent of the
           bug. So a win-win"
      
      * tag 'random-5.17-rc3-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/crng/random:
        random: only call crng_finalize_init() for primary_crng
        random: access primary_pool directly rather than through pointer
        random: wake up /dev/random writers after zap
        random: continually use hwgenerator randomness
        lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI
      ba6ef8af
    • Linus Torvalds's avatar
      Merge tag 'acpi-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · ddb16b08
      Linus Torvalds authored
      Pull ACPI fix from Rafael Wysocki:
       "Fix compilation in the case when ACPI is selected and CRC32, depended
        on by ACPI after recent changes, is not (Randy Dunlap)"
      
      * tag 'acpi-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        ACPI: require CRC32 to build
      ddb16b08
    • Linus Torvalds's avatar
      Merge tag 'sound-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 0a566d43
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "A collection of small fixes.
      
        The major changes are ASoC core fixes, addressing the DPCM locking
        issue after the recent code changes and the potentially invalid
        register accesses via control API. Also, HD-audio got a core fix for
        Oops at dynamic unbinding.
      
        The rest are device-specific small fixes, including the usual stuff
        like HD-audio and USB-audio quirks"
      
      * tag 'sound-5.17-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (31 commits)
        ALSA: hda: Skip codec shutdown in case the codec is not registered
        ALSA: usb-audio: Correct quirk for VF0770
        ALSA: Replace acpi_bus_get_device()
        Input: wm97xx: Simplify resource management
        ALSA: hda/realtek: Add quirk for ASUS GU603
        ALSA: hda/realtek: Fix silent output on Gigabyte X570 Aorus Xtreme after reboot from Windows
        ALSA: hda/realtek: Fix silent output on Gigabyte X570S Aorus Master (newer chipset)
        ALSA: hda/realtek: Add missing fixup-model entry for Gigabyte X570 ALC1220 quirks
        ALSA: hda: realtek: Fix race at concurrent COEF updates
        ASoC: ops: Check for negative values before reading them
        ASoC: rt5682: Fix deadlock on resume
        ASoC: hdmi-codec: Fix OOB memory accesses
        ASoC: soc-pcm: Move debugfs removal out of spinlock
        ASoC: soc-pcm: Fix DPCM lockdep warning due to nested stream locks
        ASoC: fsl: Add missing error handling in pcm030_fabric_probe
        ALSA: hda: Fix signedness of sscanf() arguments
        ALSA: usb-audio: initialize variables that could ignore errors
        ALSA: hda: Fix UAF of leds class devs at unbinding
        ASoC: qdsp6: q6apm-dai: only stop graphs that are started
        ASoC: codecs: wcd938x: fix return value of mixer put function
        ...
      0a566d43
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2022-02-04' of git://anongit.freedesktop.org/drm/drm · 31462d9e
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Regular fixes for the week. Daniel has agreed to bring back the fbcon
        hw acceleration under a CONFIG option for the non-drm fbdev users, we
        don't advise turning this on unless you are in the niche that is old
        fbdev drivers, Since it's essentially a revert and shouldn't be high
        impact seemed like a good time to do it now.
      
        Otherwise, i915 and amdgpu fixes are most of it, along with some minor
        fixes elsewhere.
      
        fbdev:
         - readd fbcon acceleration
      
        i915:
         - fix DP monitor via type-c dock
         - fix for engine busyness and read timeout with GuC
         - use ALLOW_FAIL for error capture buffer allocs
         - don't use interruptible lock on error paths
         - smatch fix to reject zero sized overlays.
      
        amdgpu:
         - mGPU fan boost fix for beige goby
         - S0ix fixes
         - Cyan skillfish hang fix
         - DCN fixes for DCN 3.1
         - DCN fixes for DCN 3.01
         - Apple retina panel fix
         - ttm logic inversion fix
      
        dma-buf:
         - heaps: fix potential spectre v1 gadget
      
        kmb:
         - fix potential oob access
      
        mxsfb:
         - fix NULL ptr deref
      
        nouveau:
         - fix potential oob access during BIOS decode"
      
      * tag 'drm-fixes-2022-02-04' of git://anongit.freedesktop.org/drm/drm: (24 commits)
        drm: mxsfb: Fix NULL pointer dereference
        drm/amdgpu: fix logic inversion in check
        drm/amd: avoid suspend on dGPUs w/ s2idle support when runtime PM enabled
        drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panels
        drm/amd/display: revert "Reset fifo after enable otg"
        drm/amd/display: watermark latencies is not enough on DCN31
        drm/amd/display: Update watermark values for DCN301
        drm/amdgpu: fix a potential GPU hang on cyan skillfish
        drm/amd: Only run s3 or s0ix if system is configured properly
        drm/amd: add support to check whether the system is set to s3
        fbcon: Add option to enable legacy hardware acceleration
        Revert "fbcon: Disable accelerated scrolling"
        Revert "fbdev: Garbage collect fbdev scrolling acceleration, part 1 (from TODO list)"
        drm/i915/pmu: Fix KMD and GuC race on accessing busyness
        dma-buf: heaps: Fix potential spectre v1 gadget
        drm/amd: Warn users about potential s0ix problems
        drm/amd/pm: correct the MGpuFanBoost support for Beige Goby
        drm/nouveau: fix off by one in BIOS boundary checking
        drm/i915/adlp: Fix TypeC PHY-ready status readout
        drm/i915/pmu: Use PM timestamp instead of RING TIMESTAMP for reference
        ...
      31462d9e
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · f9aaa5b0
      Linus Torvalds authored
      Merge misc fixes from Andrew Morton:
       "10 patches.
      
        Subsystems affected by this patch series: ipc, MAINTAINERS, and mm
        (vmscan, debug, pagemap, kmemleak, and selftests)"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        kselftest/vm: revert "tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner"
        MAINTAINERS: update rppt's email
        mm/kmemleak: avoid scanning potential huge holes
        ipc/sem: do not sleep with a spin lock held
        mm/pgtable: define pte_index so that preprocessor could recognize it
        mm/page_table_check: check entries at pmd levels
        mm/khugepaged: unify collapse pmd clear, flush and free
        mm/page_table_check: use unsigned long for page counters and cleanup
        mm/debug_vm_pgtable: remove pte entry from the page table
        Revert "mm/page_isolation: unset migratetype directly for non Buddy page"
      f9aaa5b0
    • Dominik Brodowski's avatar
      random: only call crng_finalize_init() for primary_crng · 9d5505f1
      Dominik Brodowski authored
      crng_finalize_init() returns instantly if it is called for another pool
      than primary_crng. The test whether crng_finalize_init() is still required
      can be moved to the relevant caller in crng_reseed(), and
      crng_need_final_init can be reset to false if crng_finalize_init() is
      called with workqueues ready. Then, no previous callsite will call
      crng_finalize_init() unless it is needed, and we can get rid of the
      superfluous function parameter.
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      9d5505f1
    • Dominik Brodowski's avatar
      random: access primary_pool directly rather than through pointer · ebf76063
      Dominik Brodowski authored
      Both crng_initialize_primary() and crng_init_try_arch_early() are
      only called for the primary_pool. Accessing it directly instead of
      through a function parameter simplifies the code.
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      ebf76063
    • Jason A. Donenfeld's avatar
      random: wake up /dev/random writers after zap · 042e293e
      Jason A. Donenfeld authored
      When account() is called, and the amount of entropy dips below
      random_write_wakeup_bits, we wake up the random writers, so that they
      can write some more in. However, the RNDZAPENTCNT/RNDCLEARPOOL ioctl
      sets the entropy count to zero -- a potential reduction just like
      account() -- but does not unblock writers. This commit adds the missing
      logic to that ioctl to unblock waiting writers.
      Reviewed-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      042e293e
    • Dominik Brodowski's avatar
      random: continually use hwgenerator randomness · c321e907
      Dominik Brodowski authored
      The rngd kernel thread may sleep indefinitely if the entropy count is
      kept above random_write_wakeup_bits by other entropy sources. To make
      best use of multiple sources of randomness, mix entropy from hardware
      RNGs into the pool at least once within CRNG_RESEED_INTERVAL.
      
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Jason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      c321e907
    • Jason A. Donenfeld's avatar
      lib/crypto: blake2s: avoid indirect calls to compression function for Clang CFI · d2a02e3c
      Jason A. Donenfeld authored
      blake2s_compress_generic is weakly aliased by blake2s_compress. The
      current harness for function selection uses a function pointer, which is
      ordinarily inlined and resolved at compile time. But when Clang's CFI is
      enabled, CFI still triggers when making an indirect call via a weak
      symbol. This seems like a bug in Clang's CFI, as though it's bucketing
      weak symbols and strong symbols differently. It also only seems to
      trigger when "full LTO" mode is used, rather than "thin LTO".
      
      [    0.000000][    T0] Kernel panic - not syncing: CFI failure (target: blake2s_compress_generic+0x0/0x1444)
      [    0.000000][    T0] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.16.0-mainline-06981-g076c855b846e #1
      [    0.000000][    T0] Hardware name: MT6873 (DT)
      [    0.000000][    T0] Call trace:
      [    0.000000][    T0]  dump_backtrace+0xfc/0x1dc
      [    0.000000][    T0]  dump_stack_lvl+0xa8/0x11c
      [    0.000000][    T0]  panic+0x194/0x464
      [    0.000000][    T0]  __cfi_check_fail+0x54/0x58
      [    0.000000][    T0]  __cfi_slowpath_diag+0x354/0x4b0
      [    0.000000][    T0]  blake2s_update+0x14c/0x178
      [    0.000000][    T0]  _extract_entropy+0xf4/0x29c
      [    0.000000][    T0]  crng_initialize_primary+0x24/0x94
      [    0.000000][    T0]  rand_initialize+0x2c/0x6c
      [    0.000000][    T0]  start_kernel+0x2f8/0x65c
      [    0.000000][    T0]  __primary_switched+0xc4/0x7be4
      [    0.000000][    T0] Rebooting in 5 seconds..
      
      Nonetheless, the function pointer method isn't so terrific anyway, so
      this patch replaces it with a simple boolean, which also gets inlined
      away. This successfully works around the Clang bug.
      
      In general, I'm not too keen on all of the indirection involved here; it
      clearly does more harm than good. Hopefully the whole thing can get
      cleaned up down the road when lib/crypto is overhauled more
      comprehensively. But for now, we go with a simple bandaid.
      
      Fixes: 6048fdcc ("lib/crypto: blake2s: include as built-in")
      Link: https://github.com/ClangBuiltLinux/linux/issues/1567Reported-by: default avatarMiles Chen <miles.chen@mediatek.com>
      Tested-by: default avatarMiles Chen <miles.chen@mediatek.com>
      Tested-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Acked-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      d2a02e3c
    • Linus Torvalds's avatar
      Merge tag 'ceph-for-5.17-rc3' of git://github.com/ceph/ceph-client · cff7f223
      Linus Torvalds authored
      Pull ceph fixes from Ilya Dryomov:
       "A patch to make it possible to disable zero copy path in the messenger
        to avoid checksum or authentication tag mismatches and ensuing session
        resets in case the destination buffer isn't guaranteed to be stable"
      
      * tag 'ceph-for-5.17-rc3' of git://github.com/ceph/ceph-client:
        libceph: optionally use bounce buffer on recv path in crc mode
        libceph: make recv path in secure mode work the same as send path
      cff7f223
    • Linus Torvalds's avatar
      Merge tag '9p-for-5.17-rc3' of git://github.com/martinetd/linux · 1eb7de17
      Linus Torvalds authored
      Pull 9p fix from Dominique Martinet:
       "Fix 'cannot walk open fid' rule
      
        The 9p 'walk' operation requires fid arguments to not originate from
        an open or create call and we've missed that for a while as the
        servers regularly running tests with don't enforce the check and no
        active reviewer knew about the rule.
      
        Both reporters confirmed reverting this patch fixes things for them
        and looking at it further wasn't actually required... Will take more
        time for follow up and enforcing the rule more thoroughly later"
      
      * tag '9p-for-5.17-rc3' of git://github.com/martinetd/linux:
        Revert "fs/9p: search open fids first"
      1eb7de17
    • Linus Torvalds's avatar
      Merge tag '5.17-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6 · 633a8e89
      Linus Torvalds authored
      Pull cifs fixes from Steve French:
       "SMB3 client fixes including:
      
         - multiple fscache related fixes, reenabling ability to read/write to
           cached files for cifs.ko (that was temporarily disabled for cifs.ko
           a few weeks ago due to the recent fscache changes)
      
         - also includes a new fscache helper function ("query_occupancy")
           used by above
      
         - fix for multiuser mounts and NTLMSSP auth (workstation name) for
           stable
      
         - fix locking ordering problem in multichannel code
      
         - trivial malformed comment fix"
      
      * tag '5.17-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
        cifs: fix workstation_name for multiuser mounts
        Invalidate fscache cookie only when inode attributes are changed.
        cifs: Fix the readahead conversion to manage the batch when reading from cache
        cifs: Implement cache I/O by accessing the cache directly
        netfs, cachefiles: Add a method to query presence of data in the cache
        cifs: Transition from ->readpages() to ->readahead()
        cifs: unlock chan_lock before calling cifs_put_tcp_session
        Fix a warning about a malformed kernel doc comment in cifs
      633a8e89
    • Shuah Khan's avatar
      kselftest/vm: revert "tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner" · 07d2505b
      Shuah Khan authored
      With this change, userfaultfd fails to build with undefined reference
      swap() error:
      
        userfaultfd.c: In function `userfaultfd_stress':
        userfaultfd.c:1530:17: warning: implicit declaration of function `swap'; did you mean `swab'? [-Wimplicit-function-declaration]
         1530 |                 swap(area_src, area_dst);
              |                 ^~~~
              |                 swab
        /usr/bin/ld: /tmp/ccDGOAdV.o: in function `userfaultfd_stress':
        userfaultfd.c:(.text+0x549e): undefined reference to `swap'
        /usr/bin/ld: userfaultfd.c:(.text+0x54bc): undefined reference to `swap'
        collect2: error: ld returned 1 exit status
      
      Revert the commit to fix the problem.
      
      Link: https://lkml.kernel.org/r/20220202003340.87195-1-skhan@linuxfoundation.org
      Fixes: 2c769ed7 ("tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner")
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Minghao Chi <chi.minghao@zte.com.cn>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      07d2505b
    • Mike Rapoport's avatar
    • Lang Yu's avatar
      mm/kmemleak: avoid scanning potential huge holes · c10a0f87
      Lang Yu authored
      When using devm_request_free_mem_region() and devm_memremap_pages() to
      add ZONE_DEVICE memory, if requested free mem region's end pfn were
      huge(e.g., 0x400000000), the node_end_pfn() will be also huge (see
      move_pfn_range_to_zone()).  Thus it creates a huge hole between
      node_start_pfn() and node_end_pfn().
      
      We found on some AMD APUs, amdkfd requested such a free mem region and
      created a huge hole.  In such a case, following code snippet was just
      doing busy test_bit() looping on the huge hole.
      
        for (pfn = start_pfn; pfn < end_pfn; pfn++) {
      	struct page *page = pfn_to_online_page(pfn);
      		if (!page)
      			continue;
      	...
        }
      
      So we got a soft lockup:
      
        watchdog: BUG: soft lockup - CPU#6 stuck for 26s! [bash:1221]
        CPU: 6 PID: 1221 Comm: bash Not tainted 5.15.0-custom #1
        RIP: 0010:pfn_to_online_page+0x5/0xd0
        Call Trace:
          ? kmemleak_scan+0x16a/0x440
          kmemleak_write+0x306/0x3a0
          ? common_file_perm+0x72/0x170
          full_proxy_write+0x5c/0x90
          vfs_write+0xb9/0x260
          ksys_write+0x67/0xe0
          __x64_sys_write+0x1a/0x20
          do_syscall_64+0x3b/0xc0
          entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      I did some tests with the patch.
      
      (1) amdgpu module unloaded
      
      before the patch:
      
        real    0m0.976s
        user    0m0.000s
        sys     0m0.968s
      
      after the patch:
      
        real    0m0.981s
        user    0m0.000s
        sys     0m0.973s
      
      (2) amdgpu module loaded
      
      before the patch:
      
        real    0m35.365s
        user    0m0.000s
        sys     0m35.354s
      
      after the patch:
      
        real    0m1.049s
        user    0m0.000s
        sys     0m1.042s
      
      Link: https://lkml.kernel.org/r/20211108140029.721144-1-lang.yu@amd.comSigned-off-by: default avatarLang Yu <lang.yu@amd.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c10a0f87
    • Minghao Chi's avatar
      ipc/sem: do not sleep with a spin lock held · 520ba724
      Minghao Chi authored
      We can't call kvfree() with a spin lock held, so defer it.
      
      Link: https://lkml.kernel.org/r/20211223031207.556189-1-chi.minghao@zte.com.cn
      Fixes: fc37a3b8 ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation")
      Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
      Signed-off-by: default avatarMinghao Chi <chi.minghao@zte.com.cn>
      Reviewed-by: default avatarShakeel Butt <shakeelb@google.com>
      Reviewed-by: default avatarManfred Spraul <manfred@colorfullife.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Yang Guang <cgel.zte@gmail.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Bhaskar Chowdhury <unixbhaskar@gmail.com>
      Cc: Vasily Averin <vvs@virtuozzo.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      520ba724
    • Mike Rapoport's avatar
      mm/pgtable: define pte_index so that preprocessor could recognize it · 314c459a
      Mike Rapoport authored
      Since commit 974b9b2c ("mm: consolidate pte_index() and
      pte_offset_*() definitions") pte_index is a static inline and there is
      no define for it that can be recognized by the preprocessor.  As a
      result, vm_insert_pages() uses slower loop over vm_insert_page() instead
      of insert_pages() that amortizes the cost of spinlock operations when
      inserting multiple pages.
      
      Link: https://lkml.kernel.org/r/20220111145457.20748-1-rppt@kernel.org
      Fixes: 974b9b2c ("mm: consolidate pte_index() and pte_offset_*() definitions")
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Reported-by: default avatarChristian Dietrich <stettberger@dokucode.de>
      Reviewed-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      314c459a
    • Pasha Tatashin's avatar
      mm/page_table_check: check entries at pmd levels · 80110bbf
      Pasha Tatashin authored
      syzbot detected a case where the page table counters were not properly
      updated.
      
        syzkaller login:  ------------[ cut here ]------------
        kernel BUG at mm/page_table_check.c:162!
        invalid opcode: 0000 [#1] PREEMPT SMP KASAN
        CPU: 0 PID: 3099 Comm: pasha Not tainted 5.16.0+ #48
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIO4
        RIP: 0010:__page_table_check_zero+0x159/0x1a0
        Call Trace:
         free_pcp_prepare+0x3be/0xaa0
         free_unref_page+0x1c/0x650
         free_compound_page+0xec/0x130
         free_transhuge_page+0x1be/0x260
         __put_compound_page+0x90/0xd0
         release_pages+0x54c/0x1060
         __pagevec_release+0x7c/0x110
         shmem_undo_range+0x85e/0x1250
        ...
      
      The repro involved having a huge page that is split due to uprobe event
      temporarily replacing one of the pages in the huge page.  Later the huge
      page was combined again, but the counters were off, as the PTE level was
      not properly updated.
      
      Make sure that when PMD is cleared and prior to freeing the level the
      PTEs are updated.
      
      Link: https://lkml.kernel.org/r/20220131203249.2832273-5-pasha.tatashin@soleen.com
      Fixes: df4e817b ("mm: page table check")
      Signed-off-by: default avatarPasha Tatashin <pasha.tatashin@soleen.com>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Greg Thelen <gthelen@google.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: Mike Rapoport <rppt@kernel.org>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Wei Xu <weixugc@google.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Zi Yan <ziy@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      80110bbf