]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Merge branch 'nocache-cleanup'
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 Apr 2026 15:39:51 +0000 (08:39 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 Apr 2026 15:39:51 +0000 (08:39 -0700)
This series cleans up some of the special user copy functions naming and
semantics.  In particular, get rid of the (very traditional) double
underscore names and behavior: the whole "optimize away the range check"
model has been largely excised from the other user accessors because
it's so subtle and can be unsafe, but also because it's just not a
relevant optimization any more.

To do that, a couple of drivers that misused the "user" copies as kernel
copies in order to get non-temporal stores had to be fixed up, but that
kind of code should never have been allowed anyway.

The x86-only "nocache" version was also renamed to more accurately
reflect what it actually does.

This was all done because I looked at this code due to a report by Jann
Horn, and I just couldn't stand the inconsistent naming, the horrible
semantics, and the random misuse of these functions.  This code should
probably be cleaned up further, but it's at least slightly closer to
normal semantics.

I had a more intrusive series that went even further in trying to
normalize the semantics, but that ended up hitting so many other
inconsistencies between different architectures in this area (eg
'size_t' vs 'unsigned long' vs 'int' as size arguments, and various
iovec check differences that Vasily Gorbik pointed out) that I ended up
with this more limited version that fixed the worst of the issues.

Reported-by: Jann Horn <jannh@google.com>
Tested-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/all/CAHk-=wgg1QVWNWG-UCFo1hx0zqrPnB3qhPzUTrWNft+MtXQXig@mail.gmail.com/
* nocache-cleanup:
  x86-64/arm64/powerpc: clean up and rename __copy_from_user_flushcache
  x86: rename and clean up __copy_from_user_inatomic_nocache()
  x86-64: rename misleadingly named '__copy_user_nocache()' function

1  2 
arch/arm64/include/asm/uaccess.h
arch/powerpc/include/asm/uaccess.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/qxl/qxl_ioctl.c
drivers/infiniband/sw/rdmavt/qp.c
drivers/ntb/ntb_transport.c
include/linux/uaccess.h
lib/iov_iter.c
tools/objtool/check.c

Simple merge
index 17e63244e88552451d9da4df2d65952f4403ae4e,c4221dae9750a610b1f91a9d6618261393bf8b12..e98c628e3899384db2d1312ba2772327e084efac
@@@ -434,11 -405,9 +434,10 @@@ copy_mc_to_user(void __user *to, const 
  }
  #endif
  
- extern long __copy_from_user_flushcache(void *dst, const void __user *src,
-               unsigned size);
+ extern size_t copy_from_user_flushcache(void *dst, const void __user *src, size_t size);
  
 -static __must_check __always_inline bool user_access_begin(const void __user *ptr, size_t len)
 +static __must_check __always_inline bool __user_access_begin(const void __user *ptr, size_t len,
 +                                                           unsigned long dir)
  {
        if (unlikely(!access_ok(ptr, len)))
                return false;
Simple merge
Simple merge
Simple merge
index 78e02fe6caba0cabe6a94871a7ae1cd5beedd6fa,21e1d238bc31ef6ff4a9fd725b5e6bc519bbf355..2e77b699be2a40c47d12e89b4534b5508f662bc9
@@@ -1777,14 -1808,15 +1777,15 @@@ static void ntb_tx_copy_callback(void *
        ntb_list_add(&qp->ntb_tx_free_q_lock, &entry->entry, &qp->tx_free_q);
  }
  
 -static void ntb_memcpy_tx(struct ntb_queue_entry *entry, void __iomem *offset)
 +static void ntb_memcpy_tx_on_stack(struct ntb_queue_entry *entry, void __iomem *offset)
  {
- #ifdef ARCH_HAS_NOCACHE_UACCESS
+ #ifdef copy_to_nontemporal
        /*
         * Using non-temporal mov to improve performance on non-cached
-        * writes, even though we aren't actually copying from user space.
+        * writes. This only works if __iomem is strictly memory-like,
+        * but that is the case on x86-64
         */
-       __copy_from_user_inatomic_nocache(offset, entry->buf, entry->len);
+       copy_to_nontemporal(offset, entry->buf, entry->len);
  #else
        memcpy_toio(offset, entry->buf, entry->len);
  #endif
Simple merge
diff --cc lib/iov_iter.c
Simple merge
Simple merge