1. 20 Jun, 2024 3 commits
  2. 19 Jun, 2024 2 commits
  3. 18 Jun, 2024 6 commits
  4. 17 Jun, 2024 5 commits
    • Linus Torvalds's avatar
      Revert "mm: mmap: allow for the maximum number of bits for randomizing mmap_base by default" · 14d7c92f
      Linus Torvalds authored
      This reverts commit 3afb76a6.
      
      This was a wrongheaded workaround for an issue that had already been
      fixed much better by commit 4ef9ad19 ("mm: huge_memory: don't force
      huge page alignment on 32 bit").
      
      Asking users questions at kernel compile time that they can't make sense
      of is not a viable strategy.  And the fact that even the kernel VM
      maintainers apparently didn't catch that this "fix" is not a fix any
      more pretty much proves the point that people can't be expected to
      understand the implications of the question.
      
      It may well be the case that we could improve things further, and that
      __thp_get_unmapped_area() should take the mapping randomization into
      account even for 64-bit kernels.  Maybe we should not be so eager to use
      THP mappings.
      
      But in no case should this be a kernel config option.
      
      Cc: Rafael Aquini <aquini@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      14d7c92f
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2024-06-17-11-43' of... · e6b324fb
      Linus Torvalds authored
      Merge tag 'mm-hotfixes-stable-2024-06-17-11-43' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
      
      Pull misc fixes from Andrew Morton:
       "Mainly MM singleton fixes. And a couple of ocfs2 regression fixes"
      
      * tag 'mm-hotfixes-stable-2024-06-17-11-43' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        kcov: don't lose track of remote references during softirqs
        mm: shmem: fix getting incorrect lruvec when replacing a shmem folio
        mm/debug_vm_pgtable: drop RANDOM_ORVALUE trick
        mm: fix possible OOB in numa_rebuild_large_mapping()
        mm/migrate: fix kernel BUG at mm/compaction.c:2761!
        selftests: mm: make map_fixed_noreplace test names stable
        mm/memfd: add documentation for MFD_NOEXEC_SEAL MFD_EXEC
        mm: mmap: allow for the maximum number of bits for randomizing mmap_base by default
        gcov: add support for GCC 14
        zap_pid_ns_processes: clear TIF_NOTIFY_SIGNAL along with TIF_SIGPENDING
        mm: huge_memory: fix misused mapping_large_folio_support() for anon folios
        lib/alloc_tag: fix RCU imbalance in pgalloc_tag_get()
        lib/alloc_tag: do not register sysctl interface when CONFIG_SYSCTL=n
        MAINTAINERS: remove Lorenzo as vmalloc reviewer
        Revert "mm: init_mlocked_on_free_v3"
        mm/page_table_check: fix crash on ZONE_DEVICE
        gcc: disable '-Warray-bounds' for gcc-9
        ocfs2: fix NULL pointer dereference in ocfs2_abort_trigger()
        ocfs2: fix NULL pointer dereference in ocfs2_journal_dirty()
      e6b324fb
    • Linus Torvalds's avatar
      Merge tag 'hardening-v6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · 5cf81d7b
      Linus Torvalds authored
      Pull hardening fixes from Kees Cook:
      
       - yama: document function parameter (Christian Göttsche)
      
       - mm/util: Swap kmemdup_array() arguments (Jean-Philippe Brucker)
      
       - kunit/overflow: Adjust for __counted_by with DEFINE_RAW_FLEX()
      
       - MAINTAINERS: Update entries for Kees Cook
      
      * tag 'hardening-v6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
        MAINTAINERS: Update entries for Kees Cook
        kunit/overflow: Adjust for __counted_by with DEFINE_RAW_FLEX()
        yama: document function parameter
        mm/util: Swap kmemdup_array() arguments
      5cf81d7b
    • Kees Cook's avatar
      MAINTAINERS: Update entries for Kees Cook · 1ab1a422
      Kees Cook authored
      Update current email address for Kees Cook in the MAINTAINER file to
      match the change from commit 4e173c82 ("mailmap: update entry for
      Kees Cook").
      
      Link: https://lore.kernel.org/r/20240617181257.work.206-kees@kernel.orgSigned-off-by: default avatarKees Cook <kees@kernel.org>
      1ab1a422
    • Linus Torvalds's avatar
      Merge tag 'hyperv-fixes-signed-20240616' of... · 6226e749
      Linus Torvalds authored
      Merge tag 'hyperv-fixes-signed-20240616' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux
      
      Pull Hyper-V fixes from Wei Liu:
      
       - Some cosmetic changes for hv.c and balloon.c (Aditya Nagesh)
      
       - Two documentation updates (Michael Kelley)
      
       - Suppress the invalid warning for packed member alignment (Saurabh
         Sengar)
      
       - Two hv_balloon fixes (Michael Kelley)
      
      * tag 'hyperv-fixes-signed-20240616' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
        Drivers: hv: Cosmetic changes for hv.c and balloon.c
        Documentation: hyperv: Improve synic and interrupt handling description
        Documentation: hyperv: Update spelling and fix typo
        tools: hv: suppress the invalid warning for packed member alignment
        hv_balloon: Enable hot-add for memblock sizes > 128 MiB
        hv_balloon: Use kernel macros to simplify open coded sequences
      6226e749
  5. 16 Jun, 2024 16 commits
  6. 15 Jun, 2024 8 commits
    • Linus Torvalds's avatar
      Merge tag 'xfs-6.10-fixes-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · a3e18a54
      Linus Torvalds authored
      Pull xfs fix from Chandan Babu:
       "Ensure xfs incore superblock's allocated inode counter, free inode
        counter, and free data block counter are all zero or positive when
        they are copied over from xfs_mount->m_[icount,ifree,fdblocks]
        respectively"
      
      * tag 'xfs-6.10-fixes-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: make sure sb_fdblocks is non-negative
      a3e18a54
    • Linus Torvalds's avatar
      Merge tag '6.10-rc3-smb3-server-fixes' of git://git.samba.org/ksmbd · 62e1f3b3
      Linus Torvalds authored
      Pull smb server fixes from Steve French:
       "Two small smb3 server fixes:
      
         - set xatttr fix
      
         - pathname parsing check fix"
      
      * tag '6.10-rc3-smb3-server-fixes' of git://git.samba.org/ksmbd:
        ksmbd: fix missing use of get_write in in smb2_set_ea()
        ksmbd: move leading slash check to smb2_get_name()
      62e1f3b3
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2024-06-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 08a6b55a
      Linus Torvalds authored
      Pull x86 fixes from Ingo Molnar:
      
       - Fix the 8 bytes get_user() logic on x86-32
      
       - Fix build bug that creates weird & mistaken target directory under
         arch/x86/
      
      * tag 'x86-urgent-2024-06-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/boot: Don't add the EFI stub to targets, again
        x86/uaccess: Fix missed zeroing of ia32 u64 get_user() range checking
      08a6b55a
    • Linus Torvalds's avatar
      Merge tag 'timers-urgent-2024-06-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 41d70722
      Linus Torvalds authored
      Pull timer fix from Ingo Molnar:
       "Fix boot-time warning in tick_setup_device()"
      
      * tag 'timers-urgent-2024-06-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        tick/nohz_full: Don't abuse smp_call_function_single() in tick_setup_device()
      41d70722
    • Aleksandr Nogikh's avatar
      kcov: don't lose track of remote references during softirqs · 01c8f980
      Aleksandr Nogikh authored
      In kcov_remote_start()/kcov_remote_stop(), we swap the previous KCOV
      metadata of the current task into a per-CPU variable.  However, the
      kcov_mode_enabled(mode) check is not sufficient in the case of remote KCOV
      coverage: current->kcov_mode always remains KCOV_MODE_DISABLED for remote
      KCOV objects.
      
      If the original task that has invoked the KCOV_REMOTE_ENABLE ioctl happens
      to get interrupted and kcov_remote_start() is called, it ultimately leads
      to kcov_remote_stop() NOT restoring the original KCOV reference.  So when
      the task exits, all registered remote KCOV handles remain active forever.
      
      The most uncomfortable effect (at least for syzkaller) is that the bug
      prevents the reuse of the same /sys/kernel/debug/kcov descriptor.  If
      we obtain it in the parent process and then e.g.  drop some
      capabilities and continuously fork to execute individual programs, at
      some point current->kcov of the forked process is lost,
      kcov_task_exit() takes no action, and all KCOV_REMOTE_ENABLE ioctls
      calls from subsequent forks fail.
      
      And, yes, the efficiency is also affected if we keep on losing remote
      kcov objects.
      a) kcov_remote_map keeps on growing forever.
      b) (If I'm not mistaken), we're also not freeing the memory referenced
      by kcov->area.
      
      Fix it by introducing a special kcov_mode that is assigned to the task
      that owns a KCOV remote object.  It makes kcov_mode_enabled() return true
      and yet does not trigger coverage collection in __sanitizer_cov_trace_pc()
      and write_comp_data().
      
      [nogikh@google.com: replace WRITE_ONCE() with an ordinary assignment]
        Link: https://lkml.kernel.org/r/20240614171221.2837584-1-nogikh@google.com
      Link: https://lkml.kernel.org/r/20240611133229.527822-1-nogikh@google.com
      Fixes: 5ff3b30a ("kcov: collect coverage from interrupts")
      Signed-off-by: default avatarAleksandr Nogikh <nogikh@google.com>
      Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Marco Elver <elver@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      01c8f980
    • Baolin Wang's avatar
      mm: shmem: fix getting incorrect lruvec when replacing a shmem folio · 9094b4a1
      Baolin Wang authored
      When testing shmem swapin, I encountered the warning below on my machine. 
      The reason is that replacing an old shmem folio with a new one causes
      mem_cgroup_migrate() to clear the old folio's memcg data.  As a result,
      the old folio cannot get the correct memcg's lruvec needed to remove
      itself from the LRU list when it is being freed.  This could lead to
      possible serious problems, such as LRU list crashes due to holding the
      wrong LRU lock, and incorrect LRU statistics.
      
      To fix this issue, we can fallback to use the mem_cgroup_replace_folio()
      to replace the old shmem folio.
      
      [ 5241.100311] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5d9960
      [ 5241.100317] head: order:4 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
      [ 5241.100319] flags: 0x17fffe0000040068(uptodate|lru|head|swapbacked|node=0|zone=2|lastcpupid=0x3ffff)
      [ 5241.100323] raw: 17fffe0000040068 fffffdffd6687948 fffffdffd69ae008 0000000000000000
      [ 5241.100325] raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
      [ 5241.100326] head: 17fffe0000040068 fffffdffd6687948 fffffdffd69ae008 0000000000000000
      [ 5241.100327] head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
      [ 5241.100328] head: 17fffe0000000204 fffffdffd6665801 ffffffffffffffff 0000000000000000
      [ 5241.100329] head: 0000000a00000010 0000000000000000 00000000ffffffff 0000000000000000
      [ 5241.100330] page dumped because: VM_WARN_ON_ONCE_FOLIO(!memcg && !mem_cgroup_disabled())
      [ 5241.100338] ------------[ cut here ]------------
      [ 5241.100339] WARNING: CPU: 19 PID: 78402 at include/linux/memcontrol.h:775 folio_lruvec_lock_irqsave+0x140/0x150
      [...]
      [ 5241.100374] pc : folio_lruvec_lock_irqsave+0x140/0x150
      [ 5241.100375] lr : folio_lruvec_lock_irqsave+0x138/0x150
      [ 5241.100376] sp : ffff80008b38b930
      [...]
      [ 5241.100398] Call trace:
      [ 5241.100399]  folio_lruvec_lock_irqsave+0x140/0x150
      [ 5241.100401]  __page_cache_release+0x90/0x300
      [ 5241.100404]  __folio_put+0x50/0x108
      [ 5241.100406]  shmem_replace_folio+0x1b4/0x240
      [ 5241.100409]  shmem_swapin_folio+0x314/0x528
      [ 5241.100411]  shmem_get_folio_gfp+0x3b4/0x930
      [ 5241.100412]  shmem_fault+0x74/0x160
      [ 5241.100414]  __do_fault+0x40/0x218
      [ 5241.100417]  do_shared_fault+0x34/0x1b0
      [ 5241.100419]  do_fault+0x40/0x168
      [ 5241.100420]  handle_pte_fault+0x80/0x228
      [ 5241.100422]  __handle_mm_fault+0x1c4/0x440
      [ 5241.100424]  handle_mm_fault+0x60/0x1f0
      [ 5241.100426]  do_page_fault+0x120/0x488
      [ 5241.100429]  do_translation_fault+0x4c/0x68
      [ 5241.100431]  do_mem_abort+0x48/0xa0
      [ 5241.100434]  el0_da+0x38/0xc0
      [ 5241.100436]  el0t_64_sync_handler+0x68/0xc0
      [ 5241.100437]  el0t_64_sync+0x14c/0x150
      [ 5241.100439] ---[ end trace 0000000000000000 ]---
      
      [baolin.wang@linux.alibaba.com: remove less helpful comments, per Matthew]
        Link: https://lkml.kernel.org/r/ccad3fe1375b468ebca3227b6b729f3eaf9d8046.1718423197.git.baolin.wang@linux.alibaba.com
      Link: https://lkml.kernel.org/r/3c11000dd6c1df83015a8321a859e9775ebbc23e.1718266112.git.baolin.wang@linux.alibaba.com
      Fixes: 85ce2c51 ("memcontrol: only transfer the memcg data for migration")
      Signed-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
      Reviewed-by: default avatarShakeel Butt <shakeel.butt@linux.dev>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Nhat Pham <nphamcs@gmail.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9094b4a1
    • Peter Xu's avatar
      mm/debug_vm_pgtable: drop RANDOM_ORVALUE trick · 0b1ef4fd
      Peter Xu authored
      Macro RANDOM_ORVALUE was used to make sure the pgtable entry will be
      populated with !none data in clear tests.
      
      The RANDOM_ORVALUE tried to cover mostly all the bits in a pgtable entry,
      even if there's no discussion on whether all the bits will be vaild.  Both
      S390 and PPC64 have their own masks to avoid touching some bits.  Now it's
      the turn for x86_64.
      
      The issue is there's a recent report from Mikhail Gavrilov showing that
      this can cause a warning with the newly added pte set check in commit
      8430557f on writable v.s.  userfaultfd-wp bit, even though the check
      itself was valid, the random pte is not.  We can choose to mask more bits
      out.
      
      However the need to have such random bits setup is questionable, as now
      it's already guaranteed to be true on below:
      
        - For pte level, the pgtable entry will be installed with value from
          pfn_pte(), where pfn points to a valid page.  Hence the pte will be
          !none already if populated with pfn_pte().
      
        - For upper-than-pte level, the pgtable entry should contain a directory
          entry always, which is also !none.
      
      All the cases look like good enough to test a pxx_clear() helper.  Instead
      of extending the bitmask, drop the "set random bits" trick completely.  Add
      some warning guards to make sure the entries will be !none before clear().
      
      Link: https://lkml.kernel.org/r/20240523132139.289719-1-peterx@redhat.com
      Fixes: 8430557f ("mm/page_table_check: support userfault wr-protect entries")
      Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
      Reported-by: default avatarMikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
      Link: https://lore.kernel.org/r/CABXGCsMB9A8-X+Np_Q+fWLURYL_0t3Y-MdoNabDM-Lzk58-DGA@mail.gmail.comTested-by: default avatarMikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
      Reviewed-by: default avatarPasha Tatashin <pasha.tatashin@soleen.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Gavin Shan <gshan@redhat.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0b1ef4fd
    • Kefeng Wang's avatar
      mm: fix possible OOB in numa_rebuild_large_mapping() · cfdd12b4
      Kefeng Wang authored
      The large folio is mapped with folio size(not greater PMD_SIZE) aligned
      virtual address during the pagefault, ie, 'addr = ALIGN_DOWN(vmf->address,
      nr_pages * PAGE_SIZE)' in do_anonymous_page().  But after the mremap(),
      the virtual address only requires PAGE_SIZE alignment.  Also pte is moved
      to new in move_page_tables(), then traversal of the new pte in the
      numa_rebuild_large_mapping() could hit the following issue,
      
         Unable to handle kernel paging request at virtual address 00000a80c021a788
         Mem abort info:
           ESR = 0x0000000096000004
           EC = 0x25: DABT (current EL), IL = 32 bits
           SET = 0, FnV = 0
           EA = 0, S1PTW = 0
           FSC = 0x04: level 0 translation fault
         Data abort info:
           ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
           CM = 0, WnR = 0, TnD = 0, TagAccess = 0
           GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
         user pgtable: 4k pages, 48-bit VAs, pgdp=00002040341a6000
         [00000a80c021a788] pgd=0000000000000000, p4d=0000000000000000
         Internal error: Oops: 0000000096000004 [#1] SMP
         ...
         CPU: 76 PID: 15187 Comm: git Kdump: loaded Tainted: G        W          6.10.0-rc2+ #209
         Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 1.79 08/21/2021
         pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
         pc : numa_rebuild_large_mapping+0x338/0x638
         lr : numa_rebuild_large_mapping+0x320/0x638
         sp : ffff8000b41c3b00
         x29: ffff8000b41c3b30 x28: ffff8000812a0000 x27: 00000000000a8000
         x26: 00000000000000a8 x25: 0010000000000001 x24: ffff20401c7170f0
         x23: 0000ffff33a1e000 x22: 0000ffff33a76000 x21: ffff20400869eca0
         x20: 0000ffff33976000 x19: 00000000000000a8 x18: ffffffffffffffff
         x17: 0000000000000000 x16: 0000000000000020 x15: ffff8000b41c36a8
         x14: 0000000000000000 x13: 205d373831353154 x12: 5b5d333331363732
         x11: 000000000011ff78 x10: 000000000011ff10 x9 : ffff800080273f30
         x8 : 000000320400869e x7 : c0000000ffffd87f x6 : 00000000001e6ba8
         x5 : ffff206f3fb5af88 x4 : 0000000000000000 x3 : 0000000000000000
         x2 : 0000000000000000 x1 : fffffdffc0000000 x0 : 00000a80c021a780
         Call trace:
          numa_rebuild_large_mapping+0x338/0x638
          do_numa_page+0x3e4/0x4e0
          handle_pte_fault+0x1bc/0x238
          __handle_mm_fault+0x20c/0x400
          handle_mm_fault+0xa8/0x288
          do_page_fault+0x124/0x498
          do_translation_fault+0x54/0x80
          do_mem_abort+0x4c/0xa8
          el0_da+0x40/0x110
          el0t_64_sync_handler+0xe4/0x158
          el0t_64_sync+0x188/0x190
      
      Fix it by making the start and end not only within the vma range, but also
      within the page table range.
      
      Link: https://lkml.kernel.org/r/20240612122822.4033433-1-wangkefeng.wang@huawei.com
      Fixes: d2136d74 ("mm: support multi-size THP numa balancing")
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
      Cc: "Huang, Ying" <ying.huang@intel.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Liu Shixin <liushixin2@huawei.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Ryan Roberts <ryan.roberts@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      cfdd12b4