[bug report] tracing: Add a probe that attaches to trace events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Tzvetomir Stoyanov (VMware),

The patch 7491e2c44278: "tracing: Add a probe that attaches to trace
events" from Aug 19, 2021, leads to the following
Smatch static checker warning:

	kernel/trace/trace_eprobe.c:664 enable_trace_eprobe()
	error: we previously assumed 'file' could be null (see line 652)

kernel/trace/trace_eprobe.c
    638 static int enable_trace_eprobe(struct trace_event_call *call,
    639 			       struct trace_event_file *file)
    640 {
    641 	struct trace_probe *pos, *tp;
    642 	struct trace_eprobe *ep;
    643 	bool enabled;
    644 	int ret = 0;
    645 
    646 	tp = trace_probe_primary_from_call(call);
    647 	if (WARN_ON_ONCE(!tp))
    648 		return -ENODEV;
    649 	enabled = trace_probe_is_enabled(tp);
    650 
    651 	/* This also changes "enabled" state */

Since adding a file sets it to enabled, then shouldn't we set
enabled = true on this path?

    652 	if (file) {
                    ^^^^
Check for NULL

    653 		ret = trace_probe_add_file(tp, file);
    654 		if (ret)
    655 			return ret;
    656 	} else
    657 		trace_probe_set_flag(tp, TP_FLAG_PROFILE);
    658 
    659 	if (enabled)
    660 		return 0;
    661 
    662 	list_for_each_entry(pos, trace_probe_probe_list(tp), list) {
    663 		ep = container_of(pos, struct trace_eprobe, tp);
--> 664 		ret = enable_eprobe(ep, file);
                                                ^^^^
Unchecked dereference.  See also:

kernel/trace/trace_eprobe.c:705 disable_trace_eprobe() error: we previously assumed 'file' could be null (see line 693)

    665 		if (ret)
    666 			break;
    667 		enabled = true;
    668 	}
    669 
    670 	if (ret) {
    671 		/* Failed to enable one of them. Roll back all */
    672 		if (enabled)
    673 			disable_eprobe(ep, file->tr);
    674 		if (file)
    675 			trace_probe_remove_file(tp, file);
    676 		else
    677 			trace_probe_clear_flag(tp, TP_FLAG_PROFILE);
    678 	}
    679 
    680 	return ret;
    681 }

regards,
dan carpenter



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux