1. 10 Jul, 2023 4 commits
    • Matthew Wilcox's avatar
      reiserfs: Check the return value from __getblk() · ba38980a
      Matthew Wilcox authored
      __getblk() can return a NULL pointer if we run out of memory or if we
      try to access beyond the end of the device; check it and handle it
      appropriately.
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Link: https://lore.kernel.org/lkml/CAFcO6XOacq3hscbXevPQP7sXRoYFz34ZdKPYjmd6k5sZuhGFDw@mail.gmail.com/Tested-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
      Fixes: 1da177e4 ("Linux-2.6.12-rc2") # probably introduced in 2002
      Acked-by: default avatarEdward Shishkin <edward.shishkin@gmail.com>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      ba38980a
    • Fabio M. De Francesco's avatar
      fs/ecryptfs: Use kmap_local_page() in copy_up_encrypted_with_header() · e2393b8f
      Fabio M. De Francesco authored
      kmap_atomic() has been deprecated in favor of kmap_local_page().
      
      Therefore, replace kmap_atomic() with kmap_local_page() in
      ecryptfs_copy_up_encrypted_with_header().
      
      kmap_atomic() is implemented like a kmap_local_page() which also
      disables page-faults and preemption (the latter only in !PREEMPT_RT
      kernels). The kernel virtual addresses returned by these two API are
      only valid in the context of the callers (i.e., they cannot be handed to
      other threads).
      
      With kmap_local_page() the mappings are per thread and CPU local like
      in kmap_atomic(); however, they can handle page-faults and can be called
      from any context (including interrupts). The tasks that call
      kmap_local_page() can be preempted and, when they are scheduled to run
      again, the kernel virtual addresses are restored and are still valid.
      
      In ecryptfs_copy_up_encrypted_with_header(), the block of code between
      the mapping and un-mapping does not depend on the above-mentioned side
      effects of kmap_aatomic(), so that the mere replacements of the old API
      with the new one is all that is required (i.e., there is no need to
      explicitly call pagefault_disable() and/or preempt_disable()).
      
      Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with
      HIGHMEM64GB enabled.
      
      Cc: Ira Weiny <ira.weiny@intel.com>
      Signed-off-by: default avatar"Fabio M. De Francesco" <fmdefrancesco@gmail.com>
      Message-Id: <20230426172223.8896-4-fmdefrancesco@gmail.com>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      e2393b8f
    • Fabio M. De Francesco's avatar
      fs/ecryptfs: Use kmap_local_page() in ecryptfs_write() · c3c6833e
      Fabio M. De Francesco authored
      kmap_atomic() is deprecated in favor of kmap_local_page().
      
      Therefore, replace kmap_atomic() with kmap_local_page() in
      ecryptfs_write().
      
      kmap_atomic() is implemented like kmap_local_page() which also disables
      page-faults and preemption (the latter only for !PREEMPT_RT kernels).
      
      The code within the mapping/un-mapping in ecryptfs_write() does not
      depend on the above-mentioned side effects so that a mere replacement of
      the old API with the new one is all that is required (i.e., there is no
      need to explicitly call pagefault_disable() and/or preempt_disable()).
      
      Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with
      HIGHMEM64GB enabled.
      Suggested-by: default avatarIra Weiny <ira.weiny@intel.com>
      Signed-off-by: default avatar"Fabio M. De Francesco" <fmdefrancesco@gmail.com>
      Message-Id: <20230426172223.8896-3-fmdefrancesco@gmail.com>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      c3c6833e
    • Fabio M. De Francesco's avatar
      fs/ecryptfs: Replace kmap() with kmap_local_page() · 8b70deb8
      Fabio M. De Francesco authored
      kmap() has been deprecated in favor of kmap_local_page().
      
      Therefore, replace kmap() with kmap_local_page() in fs/ecryptfs.
      
      There are two main problems with kmap(): (1) It comes with an overhead as
      the mapping space is restricted and protected by a global lock for
      synchronization and (2) it also requires global TLB invalidation when the
      kmap’s pool wraps and it might block when the mapping space is fully
      utilized until a slot becomes available.
      
      With kmap_local_page() the mappings are per thread, CPU local, can take
      page faults, and can be called from any context (including interrupts).
      It is faster than kmap() in kernels with HIGHMEM enabled. The tasks can
      be preempted and, when they are scheduled to run again, the kernel
      virtual addresses are restored and still valid.
      
      Obviously, thread locality implies that the kernel virtual addresses
      returned by kmap_local_page() are only valid in the context of the
      callers (i.e., they cannot be handed to other threads).
      
      The use of kmap_local_page() in fs/ecryptfs does not break the
      above-mentioned assumption, so it is allowed and preferred.
      
      Tested in a QEMU/KVM x86_32 VM, 6GB RAM, booting a kernel with
      HIGHMEM64GB enabled.
      Suggested-by: default avatarIra Weiny <ira.weiny@intel.com>
      Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
      Signed-off-by: default avatar"Fabio M. De Francesco" <fmdefrancesco@gmail.com>
      Message-Id: <20230426172223.8896-2-fmdefrancesco@gmail.com>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      8b70deb8
  2. 09 Jul, 2023 10 commits
  3. 08 Jul, 2023 26 commits