From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425895AbcFHOUW (ORCPT ); Wed, 8 Jun 2016 10:20:22 -0400 Received: from terminus.zytor.com ([198.137.202.10]:34070 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161761AbcFHOUR (ORCPT ); Wed, 8 Jun 2016 10:20:17 -0400 Date: Wed, 8 Jun 2016 07:19:38 -0700 From: tip-bot for Peter Zijlstra Message-ID: Cc: tglx@linutronix.de, peterz@infradead.org, akpm@linux-foundation.org, hpa@zytor.com, paulmck@linux.vnet.ibm.com, adobriyan@gmail.com, mingo@kernel.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org Reply-To: paulmck@linux.vnet.ibm.com, adobriyan@gmail.com, mingo@kernel.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, hpa@zytor.com, akpm@linux-foundation.org, peterz@infradead.org, tglx@linutronix.de In-Reply-To: <20160522104827.GP3193@twins.programming.kicks-ass.net> References: <20160522104827.GP3193@twins.programming.kicks-ass.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/barriers: Validate lockless_dereference() is used on a pointer type Git-Commit-ID: 331b6d8c7afc2e5b900b9dcd850c265e1ba8d8e7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 331b6d8c7afc2e5b900b9dcd850c265e1ba8d8e7 Gitweb: http://git.kernel.org/tip/331b6d8c7afc2e5b900b9dcd850c265e1ba8d8e7 Author: Peter Zijlstra AuthorDate: Sun, 22 May 2016 12:48:27 +0200 Committer: Ingo Molnar CommitDate: Wed, 8 Jun 2016 14:22:47 +0200 locking/barriers: Validate lockless_dereference() is used on a pointer type Use the type to validate the argument @p is indeed a pointer type. Signed-off-by: Peter Zijlstra (Intel) Cc: Alexey Dobriyan Cc: Andrew Morton Cc: Linus Torvalds Cc: Paul E. McKenney Cc: Paul McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20160522104827.GP3193@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar --- include/linux/compiler.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 793c082..06f27fd 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -545,10 +545,14 @@ 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) \ ({ \ typeof(p) _________p1 = READ_ONCE(p); \ + __maybe_unused const void * const _________p2 = _________p1; \ smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ (_________p1); \ })