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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250418074523.ae5e9f56950e431d60fc0c79@kernel.org>
Date: Fri, 18 Apr 2025 07:45:23 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH v2] tracing: Record trace_clock and recover when reboot

On Thu, 17 Apr 2025 10:18:04 -0400
Steven Rostedt <rostedt@...dmis.org> wrote:

> On Thu, 17 Apr 2025 14:17:29 +0900
> "Masami Hiramatsu (Google)" <mhiramat@...nel.org> wrote:
> 
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -6004,6 +6004,7 @@ struct trace_mod_entry {
> >  };
> >  
> >  struct trace_scratch {
> > +	char			clock[TRACE_CLOCK_NAME_MAX];
> >  	unsigned long		text_addr;
> >  	unsigned long		nr_entries;
> >  	struct trace_mod_entry	entries[];
> > @@ -6114,6 +6115,8 @@ static void update_last_data(struct trace_array *tr)
> >  	if (tr->scratch) {
> >  		struct trace_scratch *tscratch = tr->scratch;
> >  
> > +		strscpy(tscratch->clock, trace_clocks[tr->clock_id].name,
> 
> Why copy the name and not the clock_id?

The name is more robust if we rebooted in the different kernel.

> 
> The clock ids should not change between kernels.

Hmm, I thought it could be changed because we didn't define it.

----
static struct {
	u64 (*func)(void);
	const char *name;
	int in_ns;		/* is this clock in nanoseconds? */
} trace_clocks[] = {
	{ trace_clock_local,		"local",	1 },
	{ trace_clock_global,		"global",	1 },
	{ trace_clock_counter,		"counter",	0 },
	{ trace_clock_jiffies,		"uptime",	0 },
	{ trace_clock,			"perf",		1 },
	{ ktime_get_mono_fast_ns,	"mono",		1 },
	{ ktime_get_raw_fast_ns,	"mono_raw",	1 },
	{ ktime_get_boot_fast_ns,	"boot",		1 },
	{ ktime_get_tai_fast_ns,	"tai",		1 },
	ARCH_TRACE_CLOCKS
};
----

So the clock id is just an index of this array. That can be changed
easily between the kernel version. If we discard the previous boot
data in that case, I agree with using clock ids.

(Another reason for the implementation is that tracing_set_clock()
 only accepts a name, but this is just due to laziness on my part. :-( )

Thank you,

> 
> -- Steve
> 
> > +			TRACE_CLOCK_NAME_MAX);
> >  		memset(tscratch->entries, 0,
> >  		       flex_array_size(tscratch, entries, tscratch->nr_entries));
> >  		tscratch->nr_entries = 0;


-- 
Masami Hiramatsu (Google) <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ