From: David Laight <david.laight.linux@gmail.com>
To: Ricardo Ribalda <ribalda@chromium.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
Joel Fernandes <joelagnelf@nvidia.com>,
Josh Triplett <josh@joshtriplett.org>,
Boqun Feng <boqun@kernel.org>,
Uladzislau Rezki <urezki@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>, Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Dan Carpenter <error27@gmail.com>,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] rcu: Fix casting while dereferencing rcu pointers
Date: Wed, 26 Aug 2026 10:55:27 +0100 [thread overview]
Message-ID: <20260826105527.7ebbb4b1@pumpkin> (raw)
In-Reply-To: <20260825-unqual-v1-1-7024fb81b4f9@chromium.org>
On Tue, 25 Aug 2026 20:02:10 +0000
Ricardo Ribalda <ribalda@chromium.org> wrote:
> Recent versions of smatch preserved the address space qualifiers with
> typeof()[1].
>
> This fix has discovered an invalid casting in rcu dereference logic.
>
> This patch fixes tens of smatch errors like the following:
> ./include/trace/events/vb2.h:46:1: warning: incorrect type in assignment (different address spaces)
> ./include/trace/events/vb2.h:46:1: expected struct tracepoint_func *it_func_ptr
> ./include/trace/events/vb2.h:46:1: got struct tracepoint_func __rcu *
>
> [1] https://github.com/error27/smatch/commit/e53027a4e816a772403baafa83c09e4a94c1cb8f
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> include/linux/rcupdate.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> index 44c07a66edff..80276cedda80 100644
> --- a/include/linux/rcupdate.h
> +++ b/include/linux/rcupdate.h
> @@ -488,7 +488,7 @@ static __always_inline bool lockdep_assert_rcu_helper(bool c, const struct __ctx
> context_unsafe( \
> typeof(*p) *local = (typeof(*p) *__force)(p); \
> rcu_check_sparse(p, __rcu); \
> - ((typeof(*p) __force __kernel *)(local)) \
> + ((TYPEOF_UNQUAL(*p) __force __kernel *)(local)) \
Ugg... TYPEOF_UNQUAL() is absolutely horrid...
When __CHECKER__ is undefined the whole thing is just (p).
I suspect reducing all the definitions would measurably improve
kernel compile time (even before these changes).
David
> )
> /**
> * unrcu_pointer - mark a pointer as not being RCU protected
> @@ -503,7 +503,7 @@ context_unsafe( \
> ({ \
> typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
> rcu_check_sparse(p, space); \
> - ((typeof(*p) __force __kernel *)(local)); \
> + ((TYPEOF_UNQUAL(*p) __force __kernel *)(local)); \
> }) )
> #define __rcu_dereference_check(p, local, c, space) \
> ({ \
> @@ -511,19 +511,19 @@ context_unsafe( \
> typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
> RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \
> rcu_check_sparse(p, space); \
> - ((typeof(*p) __force __kernel *)(local)); \
> + ((TYPEOF_UNQUAL(*p) __force __kernel *)(local)); \
> })
> #define __rcu_dereference_protected(p, local, c, space) \
> ({ \
> RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_protected() usage"); \
> rcu_check_sparse(p, space); \
> - ((typeof(*p) __force __kernel *)(p)); \
> + ((TYPEOF_UNQUAL(*p) __force __kernel *)(p)); \
> })
> #define __rcu_dereference_raw(p, local) \
> ({ \
> /* Dependency order vs. p above. */ \
> typeof(p) local = READ_ONCE(p); \
> - ((typeof(*p) __force __kernel *)(local)); \
> + ((TYPEOF_UNQUAL(*p) __force __kernel *)(local)); \
> })
> #define rcu_dereference_raw(p) __rcu_dereference_raw(p, __UNIQUE_ID(rcu))
>
>
next prev parent reply other threads:[~2026-08-26 9:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 20:02 [PATCH 0/2] Fix warnings with recent smatch Ricardo Ribalda
2026-08-25 20:02 ` [PATCH 1/2] rcu: Fix casting while dereferencing rcu pointers Ricardo Ribalda
2026-08-26 9:55 ` David Laight [this message]
2026-08-26 11:28 ` Ricardo Ribalda
2026-08-26 13:22 ` David Laight
2026-08-26 14:03 ` Ricardo Ribalda
2026-08-25 20:02 ` [PATCH 2/2] x86/uaccess: Fix casting in put_user Ricardo Ribalda
2026-08-25 21:06 ` Dave Hansen
2026-08-25 21:15 ` Ricardo Ribalda
2026-08-25 22:38 ` Dave Hansen
2026-08-26 9:58 ` David Laight
2026-08-26 11:11 ` Ricardo Ribalda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260826105527.7ebbb4b1@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=boqun@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=error27@gmail.com \
--cc=frederic@kernel.org \
--cc=hpa@zytor.com \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@redhat.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=paulmck@kernel.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=ribalda@chromium.org \
--cc=rostedt@goodmis.org \
--cc=tglx@kernel.org \
--cc=urezki@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).