Skip to content

Commit 29db00c

Browse files
committed
Merge tag 'trace-v6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt: - Do not allow histogram values to have modifies. They can cause a NULL pointer dereference if they do. - Warn if hist_field_name() is passed a NULL. Prevent the NULL pointer dereference mentioned above. - Fix invalid address look up race in lookup_rec() - Define ftrace_stub_graph conditionally to prevent linker errors - Always check if RCU is watching at all tracepoint locations * tag 'trace-v6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Make tracepoint lockdep check actually test something ftrace,kcfi: Define ftrace_stub_graph conditionally ftrace: Fix invalid address access in lookup_rec() when index is 0 tracing: Check field value in hist_field_name() tracing: Do not let histogram values have some modifiers
2 parents ed38ff1 + c267925 commit 29db00c

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

arch/x86/kernel/ftrace_64.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ SYM_TYPED_FUNC_START(ftrace_stub)
136136
RET
137137
SYM_FUNC_END(ftrace_stub)
138138

139+
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
139140
SYM_TYPED_FUNC_START(ftrace_stub_graph)
140141
CALL_DEPTH_ACCOUNT
141142
RET
142143
SYM_FUNC_END(ftrace_stub_graph)
144+
#endif
143145

144146
#ifdef CONFIG_DYNAMIC_FTRACE
145147

include/linux/tracepoint.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,11 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
242242
* not add unwanted padding between the beginning of the section and the
243243
* structure. Force alignment to the same alignment as the section start.
244244
*
245-
* When lockdep is enabled, we make sure to always do the RCU portions of
246-
* the tracepoint code, regardless of whether tracing is on. However,
247-
* don't check if the condition is false, due to interaction with idle
248-
* instrumentation. This lets us find RCU issues triggered with tracepoints
249-
* even when this tracepoint is off. This code has no purpose other than
250-
* poking RCU a bit.
245+
* When lockdep is enabled, we make sure to always test if RCU is
246+
* "watching" regardless if the tracepoint is enabled or not. Tracepoints
247+
* require RCU to be active, and it should always warn at the tracepoint
248+
* site if it is not watching, as it will need to be active when the
249+
* tracepoint is enabled.
251250
*/
252251
#define __DECLARE_TRACE(name, proto, args, cond, data_proto) \
253252
extern int __traceiter_##name(data_proto); \
@@ -260,9 +259,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
260259
TP_ARGS(args), \
261260
TP_CONDITION(cond), 0); \
262261
if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \
263-
rcu_read_lock_sched_notrace(); \
264-
rcu_dereference_sched(__tracepoint_##name.funcs);\
265-
rcu_read_unlock_sched_notrace(); \
262+
WARN_ON_ONCE(!rcu_is_watching()); \
266263
} \
267264
} \
268265
__DECLARE_TRACE_RCU(name, PARAMS(proto), PARAMS(args), \

kernel/trace/ftrace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,8 @@ static struct dyn_ftrace *lookup_rec(unsigned long start, unsigned long end)
15641564
key.flags = end; /* overload flags, as it is unsigned long */
15651565

15661566
for (pg = ftrace_pages_start; pg; pg = pg->next) {
1567-
if (end < pg->records[0].ip ||
1567+
if (pg->index == 0 ||
1568+
end < pg->records[0].ip ||
15681569
start >= (pg->records[pg->index - 1].ip + MCOUNT_INSN_SIZE))
15691570
continue;
15701571
rec = bsearch(&key, pg->records, pg->index,

kernel/trace/trace_events_hist.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,9 @@ static const char *hist_field_name(struct hist_field *field,
13311331
{
13321332
const char *field_name = "";
13331333

1334+
if (WARN_ON_ONCE(!field))
1335+
return field_name;
1336+
13341337
if (level > 1)
13351338
return field_name;
13361339

@@ -4235,6 +4238,15 @@ static int __create_val_field(struct hist_trigger_data *hist_data,
42354238
goto out;
42364239
}
42374240

4241+
/* Some types cannot be a value */
4242+
if (hist_field->flags & (HIST_FIELD_FL_GRAPH | HIST_FIELD_FL_PERCENT |
4243+
HIST_FIELD_FL_BUCKET | HIST_FIELD_FL_LOG2 |
4244+
HIST_FIELD_FL_SYM | HIST_FIELD_FL_SYM_OFFSET |
4245+
HIST_FIELD_FL_SYSCALL | HIST_FIELD_FL_STACKTRACE)) {
4246+
hist_err(file->tr, HIST_ERR_BAD_FIELD_MODIFIER, errpos(field_str));
4247+
ret = -EINVAL;
4248+
}
4249+
42384250
hist_data->fields[val_idx] = hist_field;
42394251

42404252
++hist_data->n_vals;

0 commit comments

Comments
 (0)