Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1413057
| From | tip-bot for Peter Zijlstra <tipbot@zytor.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type |
| Date | 2016-06-03 13:00 +0200 |
| Message-ID | <rFUZz-25k-9@gated-at.bofh.it> (permalink) |
| References | <rBz7j-8a7-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Commit-ID: 25841ee0e9d2a1d952828138416701f20ea831eb
Gitweb: http://git.kernel.org/tip/25841ee0e9d2a1d952828138416701f20ea831eb
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Sun, 22 May 2016 12:48:27 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 3 Jun 2016 12:06:11 +0200
locking/barriers: Validate lockless_dereference() is used on a pointer type
Add a cast to void * to validate the argument @p is indeed a pointer.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20160522104827.GP3193@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/compiler.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 793c082..e9c6417 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -545,9 +545,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
* Similar to rcu_dereference(), but for situations where the pointed-to
* object's lifetime is managed by something other than RCU. That
* "something other" might be reference counting or simple immortality.
+ *
+ * The seemingly unused void * variable is to validate @p is indeed a pointer
+ * type. All pointer types silently cast to void *.
*/
#define lockless_dereference(p) \
({ \
+ __maybe_unused const void * const _________p2 = p; \
typeof(p) _________p1 = READ_ONCE(p); \
smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
(_________p1); \
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2016-06-03 13:00 +0200
Re: [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type Mateusz Guzik <mguzik@redhat.com> - 2016-06-06 23:40 +0200
Re: [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type Peter Zijlstra <peterz@infradead.org> - 2016-06-07 09:20 +0200
csiph-web