0125-locking-barriers-Add-implicit-smp_read_barrier_depen.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From 8b7859c0d35e5047d60c5e241fa40104b9c96f39 Mon Sep 17 00:00:00 2001
  2. From: Will Deacon <[email protected]>
  3. Date: Tue, 24 Oct 2017 11:22:47 +0100
  4. Subject: [PATCH 125/232] locking/barriers: Add implicit
  5. smp_read_barrier_depends() to READ_ONCE()
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. [ Note, this is a Git cherry-pick of the following commit:
  11. 76ebbe78f739 ("locking/barriers: Add implicit smp_read_barrier_depends() to READ_ONCE()")
  12. ... for easier x86 PTI code testing and back-porting. ]
  13. In preparation for the removal of lockless_dereference(), which is the
  14. same as READ_ONCE() on all architectures other than Alpha, add an
  15. implicit smp_read_barrier_depends() to READ_ONCE() so that it can be
  16. used to head dependency chains on all architectures.
  17. Signed-off-by: Will Deacon <[email protected]>
  18. Cc: Linus Torvalds <[email protected]>
  19. Cc: Paul E. McKenney <[email protected]>
  20. Cc: Peter Zijlstra <[email protected]>
  21. Cc: Thomas Gleixner <[email protected]>
  22. Link: http://lkml.kernel.org/r/[email protected]
  23. Signed-off-by: Ingo Molnar <[email protected]>
  24. (cherry picked from commit c2bc66082e1048c7573d72e62f597bdc5ce13fea)
  25. Signed-off-by: Andy Whitcroft <[email protected]>
  26. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  27. (cherry picked from commit 6ef3d843f8f1a8b72ca83d4b1d457c2896278ccd)
  28. Signed-off-by: Fabian Grünbichler <[email protected]>
  29. ---
  30. include/linux/compiler.h | 1 +
  31. 1 file changed, 1 insertion(+)
  32. diff --git a/include/linux/compiler.h b/include/linux/compiler.h
  33. index 043b60de041e..8af8814ebe7a 100644
  34. --- a/include/linux/compiler.h
  35. +++ b/include/linux/compiler.h
  36. @@ -314,6 +314,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
  37. __read_once_size(&(x), __u.__c, sizeof(x)); \
  38. else \
  39. __read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
  40. + smp_read_barrier_depends(); /* Enforce dependency ordering from x */ \
  41. __u.__val; \
  42. })
  43. #define READ_ONCE(x) __READ_ONCE(x, 1)
  44. --
  45. 2.14.2