lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210204150923.0140fe55@gandalf.local.home>
Date:   Thu, 4 Feb 2021 15:09:23 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc:     linux-kernel <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH] tracepoints: Do not punish non static call users

On Thu, 4 Feb 2021 14:52:51 -0500 (EST)
Mathieu Desnoyers <mathieu.desnoyers@...icios.com> wrote:

> ----- On Feb 4, 2021, at 2:17 PM, rostedt rostedt@...dmis.org wrote:
> 
> > With static calls, a tracepoint can call the callback directly if there is
> > only one callback registered to that tracepoint. When there is more than
> > one, the static call will call the tracepoint's "iterator" function, which
> > needs to reload the tracepoint's "funcs" array again, as it could have
> > changed since the first time it was loaded.
> > 
> > But an arch without static calls is punished by having to load the
> > tracepoint's "funcs" array twice. Once in the DO_TRACE macro, and once
> > again in the iterator macro.  
> 
> In addition to loading it, it needs to test it against NULL twice.

True, but it needs to be tested again because it was loaded again. So I
consider the test as a result of the reload, and only indirectly of the
double call. Thus, I left it out of the change log.

> 
> > 
> > For archs without static calls, there's no reason to load the array macro
> > in the first place, since the iterator function will do it anyway.
> > 
> > Change the __DO_TRACE_CALL() macro to do the double call only for  
> 
> Do you mean "double call" or "double load and NULL check" ?

I was thinking of it as double call, as calling once to the iterator, and
once again to the functions that are loaded. But sure, because of the
double load too (and the NULL check is only because of the load ;-)

> 
> > architectures with static calls, and just call the iterator function
> > directly for architectures without static calls.
> > 
> > [ Tested only on architectures with static calls, will test on those
> >  without later ]
> > 
> > Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
> > ---
> > diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> > index dc1d4c612cc3..966bfa6a861c 100644
> > --- a/include/linux/tracepoint.h
> > +++ b/include/linux/tracepoint.h
> > @@ -152,9 +152,18 @@ static inline struct tracepoint
> > *tracepoint_ptr_deref(tracepoint_ptr_t *p)
> > #ifdef TRACEPOINTS_ENABLED
> > 
> > #ifdef CONFIG_HAVE_STATIC_CALL
> > -#define __DO_TRACE_CALL(name)	static_call(tp_func_##name)
> > +#define __DO_TRACE_CALL(name, args)					\
> > +	do {								\
> > +		struct tracepoint_func *it_func_ptr;			\
> > +		it_func_ptr =						\
> > +			rcu_dereference_raw((&__tracepoint_##name)->funcs); \
> > +		if (it_func_ptr) {					\
> > +			__data = (it_func_ptr)->data;			\
> > +			static_call(tp_func_##name)(args);		\
> > +		}							\
> > +	} while (0)
> > #else
> > -#define __DO_TRACE_CALL(name)	__traceiter_##name
> > +#define __DO_TRACE_CALL(name, args)	__traceiter_##name(args)  
> 
> Also, we may want to comment or annotate the "void *data" argument of
> __traceiter_##_name() to state that it is unused.

Good point. (Which would have possibly been found in my more extensive
testing).

Thanks,

-- Steve

> 
> Thanks,
> 
> Mathieu
> 
> > #endif /* CONFIG_HAVE_STATIC_CALL */
> > 
> > /*
> > @@ -168,7 +177,6 @@ static inline struct tracepoint
> > *tracepoint_ptr_deref(tracepoint_ptr_t *p)
> >  */
> > #define __DO_TRACE(name, proto, args, cond, rcuidle)			\
> > 	do {								\
> > -		struct tracepoint_func *it_func_ptr;			\
> > 		int __maybe_unused __idx = 0;				\
> > 		void *__data;						\
> > 									\
> > @@ -190,12 +198,7 @@ static inline struct tracepoint
> > *tracepoint_ptr_deref(tracepoint_ptr_t *p)
> > 			rcu_irq_enter_irqson();				\
> > 		}							\
> > 									\
> > -		it_func_ptr =						\
> > -			rcu_dereference_raw((&__tracepoint_##name)->funcs); \
> > -		if (it_func_ptr) {					\
> > -			__data = (it_func_ptr)->data;			\
> > -			__DO_TRACE_CALL(name)(args);			\
> > -		}							\
> > +		__DO_TRACE_CALL(name, TP_ARGS(args));			\
> > 									\
> > 		if (rcuidle) {						\
> >  			rcu_irq_exit_irqson();				\  
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ