1. 27 Aug, 2024 7 commits
    • Vlastimil Babka's avatar
      kunit, slub: add test_kfree_rcu() and test_leak_destroy() · 4e1c44b3
      Vlastimil Babka authored
      Add a test that will create cache, allocate one object, kfree_rcu() it
      and attempt to destroy it. As long as the usage of kvfree_rcu_barrier()
      in kmem_cache_destroy() works correctly, there should be no warnings in
      dmesg and the test should pass.
      
      Additionally add a test_leak_destroy() test that leaks an object on
      purpose and verifies that kmem_cache_destroy() catches it.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      4e1c44b3
    • Vlastimil Babka's avatar
      mm, slab: call kvfree_rcu_barrier() from kmem_cache_destroy() · 6c6c47b0
      Vlastimil Babka authored
      We would like to replace call_rcu() users with kfree_rcu() where the
      existing callback is just a kmem_cache_free(). However this causes
      issues when the cache can be destroyed (such as due to module unload).
      
      Currently such modules should be issuing rcu_barrier() before
      kmem_cache_destroy() to have their call_rcu() callbacks processed first.
      This barrier is however not sufficient for kfree_rcu() in flight due
      to the batching introduced by a35d1690 ("rcu: Add basic support for
      kfree_rcu() batching").
      
      This is not a problem for kmalloc caches which are never destroyed, but
      since removing SLOB, kfree_rcu() is allowed also for any other cache,
      that might be destroyed.
      
      In order not to complicate the API, put the responsibility for handling
      outstanding kfree_rcu() in kmem_cache_destroy() itself. Use the newly
      introduced kvfree_rcu_barrier() to wait before destroying the cache.
      This is similar to how we issue rcu_barrier() for SLAB_TYPESAFE_BY_RCU
      caches, but has to be done earlier, as the latter only needs to wait for
      the empty slab pages to finish freeing, and not objects from the slab.
      
      Users of call_rcu() with arbitrary callbacks should still issue
      rcu_barrier() before destroying the cache and unloading the module, as
      kvfree_rcu_barrier() is not a superset of rcu_barrier() and the
      callbacks may be invoking module code or performing other actions that
      are necessary for a successful unload.
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      6c6c47b0
    • Uladzislau Rezki (Sony)'s avatar
      rcu/kvfree: Add kvfree_rcu_barrier() API · 2b55d6a4
      Uladzislau Rezki (Sony) authored
      Add a kvfree_rcu_barrier() function. It waits until all
      in-flight pointers are freed over RCU machinery. It does
      not wait any GP completion and it is within its right to
      return immediately if there are no outstanding pointers.
      
      This function is useful when there is a need to guarantee
      that a memory is fully freed before destroying memory caches.
      For example, during unloading a kernel module.
      Signed-off-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      2b55d6a4
    • Vlastimil Babka's avatar
      mm, slab: reintroduce rcu_barrier() into kmem_cache_destroy() · 2eb14c1c
      Vlastimil Babka authored
      There used to be a rcu_barrier() for SLAB_TYPESAFE_BY_RCU caches in
      kmem_cache_destroy() until commit 657dc2f9 ("slab: remove
      synchronous rcu_barrier() call in memcg cache release path") moved it to
      an asynchronous work that finishes the destroying of such caches.
      
      The motivation for that commit was the MEMCG_KMEM integration that at
      the time created and removed clones of the global slab caches together
      with their cgroups, and blocking cgroups removal was unwelcome. The
      implementation later changed to per-object memcg tracking using a single
      cache, so there should be no more need for a fast non-blocking
      kmem_cache_destroy(), which is typically only done when a module is
      unloaded etc.
      
      Going back to synchronous barrier has the following advantages:
      
      - simpler implementation
      - it's easier to test the result of kmem_cache_destroy() in a kunit test
      
      Thus effectively revert commit 657dc2f9. It is not a 1:1 revert as
      the code has changed since. The main part is that kmem_cache_release(s)
      is always called from kmem_cache_destroy(), but for SLAB_TYPESAFE_BY_RCU
      caches there's a rcu_barrier() first.
      Suggested-by: default avatarMateusz Guzik <mjguzik@gmail.com>
      Reviewed-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      2eb14c1c
    • Vlastimil Babka's avatar
      mm, slab: move kfence_shutdown_cache() outside slab_mutex · f77d0cda
      Vlastimil Babka authored
      kfence_shutdown_cache() is called under slab_mutex when the cache is
      destroyed synchronously, and outside slab_mutex during the delayed
      destruction of SLAB_TYPESAFE_BY_RCU caches.
      
      It seems it should always be safe to call it outside of slab_mutex so we
      can just move the call to kmem_cache_release(), which is called outside.
      Reviewed-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      f77d0cda
    • Vlastimil Babka's avatar
      mm, slab: unlink slabinfo, sysfs and debugfs immediately · 4ec10268
      Vlastimil Babka authored
      kmem_cache_destroy() includes removing the associated sysfs and debugfs
      directories, and the cache from the list of caches that appears in
      /proc/slabinfo. Currently this might not happen immediately when:
      
      - the cache is SLAB_TYPESAFE_BY_RCU and the cleanup is delayed,
        including the directores removal
      - __kmem_cache_shutdown() fails due to outstanding objects - the
        directories remain indefinitely
      
      When a cache is recreated with the same name, such as due to module
      unload followed by a load, the directories will fail to be recreated for
      the new instance of the cache due to the old directories being present.
      The cache will also appear twice in /proc/slabinfo.
      
      While we want to convert the SLAB_TYPESAFE_BY_RCU cleanup to be
      synchronous again, the second point remains. So let's fix this first and
      have the directories and slabinfo removed immediately in
      kmem_cache_destroy() and regardless of __kmem_cache_shutdown() success.
      
      This should not make debugging harder if __kmem_cache_shutdown() fails,
      because a detailed report of outstanding objects is printed into dmesg
      already due to the failure.
      
      Also simplify kmem_cache_release() sysfs handling by using
      __is_defined(SLAB_SUPPORTS_SYSFS).
      
      Note the resulting code in kmem_cache_destroy() is a bit ugly but will
      be further simplified - this is in order to make small bisectable steps.
      Reviewed-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      4ec10268
    • Vlastimil Babka's avatar
      mm, slab: dissolve shutdown_cache() into its caller · b5959789
      Vlastimil Babka authored
      There's only one caller of shutdown_cache() so move the code into it.
      Preparatory patch for further changes, no functional change.
      Reviewed-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      b5959789
  2. 25 Aug, 2024 5 commits
    • Linus Torvalds's avatar
      Linux 6.11-rc5 · 5be63fc1
      Linus Torvalds authored
      5be63fc1
    • Linus Torvalds's avatar
      Merge tag 'bcachefs-2024-08-24' of git://evilpiepirate.org/bcachefs · 72bea05c
      Linus Torvalds authored
      Pull bcachefs fixes from Kent Overstreet:
      
       - assorted syzbot fixes
      
       - some upgrade fixes for old (pre 1.0) filesystems
      
       - fix for moving data off a device that was switched to durability=0
         after data had been written to it.
      
       - nocow deadlock fix
      
       - fix for new rebalance_work accounting
      
      * tag 'bcachefs-2024-08-24' of git://evilpiepirate.org/bcachefs: (28 commits)
        bcachefs: Fix rebalance_work accounting
        bcachefs: Fix failure to flush moves before sleeping in copygc
        bcachefs: don't use rht_bucket() in btree_key_cache_scan()
        bcachefs: add missing inode_walker_exit()
        bcachefs: clear path->should_be_locked in bch2_btree_key_cache_drop()
        bcachefs: Fix double assignment in check_dirent_to_subvol()
        bcachefs: Fix refcounting in discard path
        bcachefs: Fix compat issue with old alloc_v4 keys
        bcachefs: Fix warning in bch2_fs_journal_stop()
        fs/super.c: improve get_tree() error message
        bcachefs: Fix missing validation in bch2_sb_journal_v2_validate()
        bcachefs: Fix replay_now_at() assert
        bcachefs: Fix locking in bch2_ioc_setlabel()
        bcachefs: fix failure to relock in btree_node_fill()
        bcachefs: fix failure to relock in bch2_btree_node_mem_alloc()
        bcachefs: unlock_long() before resort in journal replay
        bcachefs: fix missing bch2_err_str()
        bcachefs: fix time_stats_to_text()
        bcachefs: Fix bch2_bucket_gens_init()
        bcachefs: Fix bch2_trigger_alloc assert
        ...
      72bea05c
    • Linus Torvalds's avatar
      Merge tag '6.11-rc5-server-fixes' of git://git.samba.org/ksmbd · 780bdc1b
      Linus Torvalds authored
      Pull smb server fixes from Steve French:
      
       - query directory flex array fix
      
       - fix potential null ptr reference in open
      
       - fix error message in some open cases
      
       - two minor cleanups
      
      * tag '6.11-rc5-server-fixes' of git://git.samba.org/ksmbd:
        smb/server: update misguided comment of smb2_allocate_rsp_buf()
        smb/server: remove useless assignment of 'file_present' in smb2_open()
        smb/server: fix potential null-ptr-deref of lease_ctx_info in smb2_open()
        smb/server: fix return value of smb2_open()
        ksmbd: the buffer of smb2 query dir response has at least 1 byte
      780bdc1b
    • Linus Torvalds's avatar
      Merge tag 's390-6.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · 48fb4b3d
      Linus Torvalds authored
      Pull s390 fixes from Vasily Gorbik:
      
       - Fix KASLR base offset to account for symbol offsets in the vmlinux
         ELF file, preventing tool breakages like the drgn debugger
      
       - Fix potential memory corruption of physmem_info during kernel
         physical address randomization
      
       - Fix potential memory corruption due to overlap between the relocated
         lowcore and identity mapping by correctly reserving lowcore memory
      
       - Fix performance regression and avoid randomizing identity mapping
         base by default
      
       - Fix unnecessary delay of AP bus binding complete uevent to prevent
         startup lag in KVM guests using AP
      
      * tag 's390-6.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        s390/boot: Fix KASLR base offset off by __START_KERNEL bytes
        s390/boot: Avoid possible physmem_info segment corruption
        s390/ap: Refine AP bus bindings complete processing
        s390/mm: Pin identity mapping base to zero
        s390/mm: Prevent lowcore vs identity mapping overlap
      48fb4b3d
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 891e811a
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "The important core fix is another tweak to our discard discovery
        issues. The off by 512 in logical block count seems bad, but in fact
        the inline was only ever used in debug prints, which is why no-one
        noticed"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: sd: Do not attempt to configure discard unless LBPME is set
        scsi: MAINTAINERS: Add header files to SCSI SUBSYSTEM
        scsi: ufs: qcom: Add UFSHCD_QUIRK_BROKEN_LSDBS_CAP for SM8550 SoC
        scsi: ufs: core: Add a quirk for handling broken LSDBS field in controller capabilities register
        scsi: core: Fix the return value of scsi_logical_block_count()
        scsi: MAINTAINERS: Update HiSilicon SAS controller driver maintainer
      891e811a
  3. 24 Aug, 2024 10 commits
    • Kent Overstreet's avatar
      bcachefs: Fix rebalance_work accounting · 49aa7830
      Kent Overstreet authored
      rebalance_work was keying off of the presence of rebelance_opts in the
      extent - but that was incorrect, we keep those around after rebalance
      for indirect extents since the inode's options are not directly
      available
      
      Fixes: 20ac515a ("bcachefs: bch_acct_rebalance_work")
      Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
      49aa7830
    • Kent Overstreet's avatar
      bcachefs: Fix failure to flush moves before sleeping in copygc · d3204616
      Kent Overstreet authored
      This fixes an apparent deadlock - rebalance would get stuck trying to
      take nocow locks because they weren't being released by copygc.
      Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
      d3204616
    • Linus Torvalds's avatar
      Merge tag 'cgroup-for-6.11-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup · d2bafcf2
      Linus Torvalds authored
      Pull cgroup fixes from Tejun Heo:
       "Three patches addressing cpuset corner cases"
      
      * tag 'cgroup-for-6.11-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
        cgroup/cpuset: Eliminate unncessary sched domains rebuilds in hotplug
        cgroup/cpuset: Clear effective_xcpus on cpus_allowed clearing only if cpus.exclusive not set
        cgroup/cpuset: fix panic caused by partcmd_update
      d2bafcf2
    • Linus Torvalds's avatar
      Merge tag 'wq-for-6.11-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq · cb2c84b3
      Linus Torvalds authored
      Pull workqueue fixes from Tejun Heo:
       "Nothing too interesting. One patch to remove spurious warning and
        others to address static checker warnings"
      
      * tag 'wq-for-6.11-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
        workqueue: Correct declaration of cpu_pwq in struct workqueue_struct
        workqueue: Fix spruious data race in __flush_work()
        workqueue: Remove incorrect "WARN_ON_ONCE(!list_empty(&worker->entry));" from dying worker
        workqueue: Fix UBSAN 'subtraction overflow' error in shift_and_mask()
        workqueue: doc: Fix function name, remove markers
      cb2c84b3
    • Linus Torvalds's avatar
      Merge tag 'mips-fixes_6.11_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux · 5bd6cf00
      Linus Torvalds authored
      Pull MIPS fixes from Thomas Bogendoerfer:
      
       - Set correct timer mode on Loongson64
      
       - Only request r4k clockevent interrupt on one CPU
      
      * tag 'mips-fixes_6.11_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
        MIPS: cevt-r4k: Don't call get_c0_compare_int if timer irq is installed
        MIPS: Loongson64: Set timer mode in cpu-probe
      5bd6cf00
    • Linus Torvalds's avatar
      Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux · a8a8dcbd
      Linus Torvalds authored
      Pull arm64 kvm fixes from Catalin Marinas:
      
       - Don't drop references on LPIs that weren't visited by the vgic-debug
         iterator
      
       - Cure lock ordering issue when unregistering vgic redistributors
      
       - Fix for misaligned stage-2 mappings when VMs are backed by hugetlb
         pages
      
       - Treat SGI registers as UNDEFINED if a VM hasn't been configured for
         GICv3
      
      * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
        KVM: arm64: Make ICC_*SGI*_EL1 undef in the absence of a vGICv3
        KVM: arm64: Ensure canonical IPA is hugepage-aligned when handling fault
        KVM: arm64: vgic: Don't hold config_lock while unregistering redistributors
        KVM: arm64: vgic-debug: Don't put unmarked LPIs
      a8a8dcbd
    • Linus Torvalds's avatar
      Merge tag 'nfs-for-6.11-2' of git://git.linux-nfs.org/projects/anna/linux-nfs · 60f0560f
      Linus Torvalds authored
      Pull NFS client fixes from Anna Schumaker:
      
       - Fix rpcrdma refcounting in xa_alloc
      
       - Fix rpcrdma usage of XA_FLAGS_ALLOC
      
       - Fix requesting FATTR4_WORD2_OPEN_ARGUMENTS
      
       - Fix attribute bitmap decoder to handle a 3rd word
      
       - Add reschedule points when returning delegations to avoid soft lockups
      
       - Fix clearing layout segments in layoutreturn
      
       - Avoid unnecessary rescanning of the per-server delegation list
      
      * tag 'nfs-for-6.11-2' of git://git.linux-nfs.org/projects/anna/linux-nfs:
        NFS: Avoid unnecessary rescanning of the per-server delegation list
        NFSv4: Fix clearing of layout segments in layoutreturn
        NFSv4: Add missing rescheduling points in nfs_client_return_marked_delegations
        nfs: fix bitmap decoder to handle a 3rd word
        nfs: fix the fetch of FATTR4_OPEN_ARGUMENTS
        rpcrdma: Trace connection registration and unregistration
        rpcrdma: Use XA_FLAGS_ALLOC instead of XA_FLAGS_ALLOC1
        rpcrdma: Device kref is over-incremented on error from xa_alloc
      60f0560f
    • Linus Torvalds's avatar
      Merge tag 'v6.11-rc4-client-fixes' of git://git.samba.org/sfrench/cifs-2.6 · 66ace9a8
      Linus Torvalds authored
      Pull smb client fixes from Steve French:
      
       - fix refcount leak (can cause rmmod fail)
      
       - fix byte range locking problem with cached reads
      
       - fix for mount failure if reparse point unrecognized
      
       - minor typo
      
      * tag 'v6.11-rc4-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
        smb/client: fix typo: GlobalMid_Sem -> GlobalMid_Lock
        smb: client: ignore unhandled reparse tags
        smb3: fix problem unloading module due to leaked refcount on shutdown
        smb3: fix broken cached reads when posix locks
      66ace9a8
    • Linus Torvalds's avatar
      Merge tag 'input-for-v6.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input · 7eb61cc6
      Linus Torvalds authored
      Pull input fixes from Dmitry Torokhov:
      
       - a tweak to uinput interface to reject requests with abnormally large
         number of slots. 100 slots/contacts should be enough for real devices
      
       - support for FocalTech FT8201 added to the edt-ft5x06 driver
      
       - tweaks to i8042 to handle more devices that have issue with its
         emulation
      
       - Synaptics touchpad switched to native SMbus/RMI mode on HP Elitebook
         840 G2
      
       - other minor fixes
      
      * tag 'input-for-v6.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
        Input: himax_hx83112b - fix incorrect size when reading product ID
        Input: i8042 - use new forcenorestore quirk to replace old buggy quirk combination
        Input: i8042 - add forcenorestore quirk to leave controller untouched even on s3
        Input: i8042 - add Fujitsu Lifebook E756 to i8042 quirk table
        Input: uinput - reject requests with unreasonable number of slots
        Input: edt-ft5x06 - add support for FocalTech FT8201
        dt-bindings: input: touchscreen: edt-ft5x06: Document FT8201 support
        Input: adc-joystick - fix optional value handling
        Input: synaptics - enable SMBus for HP Elitebook 840 G2
        Input: ads7846 - ratelimit the spi_sync error message
      7eb61cc6
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2024-08-24' of https://gitlab.freedesktop.org/drm/kernel · 79a899e3
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Weekly fixes. xe and msm are the major groups, with
        amdgpu/i915/nouveau having smaller bits. xe has a bunch of hw
        workaround fixes that were found to be missing, so that is why there
        are a bunch of scattered fixes, and one larger one. But overall size
        doesn't look too out of the ordinary.
      
        msm:
         - virtual plane fixes:
            - drop yuv on hw where not supported
            - csc vs yuv format fix
            - rotation fix
         - fix fb cleanup on close
         - reset phy before link training
         - fix visual corruption at 4K
         - fix NULL ptr crash on hotplug
         - simplify debug macros
         - sc7180 fix
         - adreno firmware name error path fix
      
        amdgpu:
         - GFX10 firmware loading fix
         - SDMA 5.2 fix
         - Debugfs parameter validation fix
         - eGPU hotplug fix
      
        i915:
         - fix HDCP timeouts
      
        nouveau:
         - fix SG_DEBUG crash
      
        xe:
         - Fix OA format masks which were breaking build with gcc-5
         - Fix opregion leak (Lucas)
         - Fix OA sysfs entry (Ashutosh)
         - Fix VM dma-resv lock (Brost)
         - Fix tile fini sequence (Brost)
         - Prevent UAF around preempt fence (Auld)
         - Fix DGFX display suspend/resume (Maarten)
         - Many Xe/Xe2 critical workarounds (Auld, Ngai-Mint, Bommu, Tejas, Daniele)
         - Fix devm/drmm issues (Daniele)
         - Fix missing workqueue destroy in xe_gt_pagefault (Stuart)
         - Drop HW fence pointer to HW fence ctx (Brost)
         - Free job before xe_exec_queue_put (Brost)"
      
      * tag 'drm-fixes-2024-08-24' of https://gitlab.freedesktop.org/drm/kernel: (35 commits)
        drm/xe: Free job before xe_exec_queue_put
        drm/xe: Drop HW fence pointer to HW fence ctx
        drm/xe: Fix missing workqueue destroy in xe_gt_pagefault
        drm/amdgpu: fix eGPU hotplug regression
        drm/amdgpu: Validate TA binary size
        drm/amdgpu/sdma5.2: limit wptr workaround to sdma 5.2.1
        drm/amdgpu: fixing rlc firmware loading failure issue
        drm/xe/uc: Use devm to register cleanup that includes exec_queues
        drm/xe: use devm instead of drmm for managed bo
        drm/xe/xe2hpg: Add Wa_14021821874
        drm/xe: fix WA 14018094691
        drm/xe/xe2: Add Wa_15015404425
        drm/xe/xe2: Make subsequent L2 flush sequential
        drm/xe/xe2lpg: Extend workaround 14021402888
        drm/xe/xe2lpm: Extend Wa_16021639441
        drm/xe/bmg: implement Wa_16023588340
        drm/xe/oa/uapi: Make bit masks unsigned
        drm/xe/display: Make display suspend/resume work on discrete
        drm/xe: prevent UAF around preempt fence
        drm/xe: Fix tile fini sequence
        ...
      79a899e3
  4. 23 Aug, 2024 10 commits
  5. 22 Aug, 2024 8 commits