Thread (32 messages) 32 messages, 7 authors, 2021-10-12

Re: [RFC][PATCH] rcu: Use typeof(p) instead of typeof(*p) *

flat view

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2021-10-05 15:58:23
Also in: lkml, netfilter-devel, rcu

On Tue, 5 Oct 2021 11:15:12 -0400 (EDT)
Mathieu Desnoyers [off-list ref] wrote:
----- On Oct 5, 2021, at 9:47 AM, rostedt rostedt@goodmis.org wrote:
[...]
quoted
#define rcu_dereference_raw(p) \
({ \
	/* Dependency order vs. p above. */ \
	typeof(p) ________p1 = READ_ONCE(p); \
-	((typeof(*p) __force __kernel *)(________p1)); \
+	((typeof(p) __force __kernel)(________p1)); \
})  
AFAIU doing so removes validation that @p is indeed a pointer, so a user might mistakenly
try to use rcu_dereference() on an integer, and get away with it. I'm not sure we want to
loosen this check. I wonder if there might be another way to achieve the same check without
requiring the structure to be declared, e.g. with __builtin_types_compatible_p ?
Is that really an issue? Because you would be assigning it to an integer.


	x = rcu_dereference_raw(y);

And that just makes 'x' a copy of 'y' and not really a reference to it, thus
if you don't have a pointer, it's just a fancy READ_ONCE(y).

-- Steve
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help