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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150402092708.0616199d@gandalf.local.home>
Date:	Thu, 2 Apr 2015 09:27:08 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Namhyung Kim <namhyung@...nel.org>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	Guilherme Cox <cox@...puter.org>,
	Tony Luck <tony.luck@...il.com>,
	Xie XiuQi <xiexiuqi@...wei.com>
Subject: Re: [RFC][PATCH 06/17 v2] tracing: Add TRACE_DEFINE_ENUM() macro to
 map enums to their values

On Thu, 2 Apr 2015 16:47:40 +0900
Namhyung Kim <namhyung@...nel.org> wrote:


> > +static void update_event_printk(struct ftrace_event_call *call,
> > +				struct trace_enum_map *map)
> > +{
> > +	char *ptr;
> > +	int quote = 0;
> > +	int len = strlen(map->enum_string);
> > +
> > +	for (ptr = call->print_fmt; *ptr; ptr++) {
> > +		if (*ptr == '\\') {
> > +			ptr++;
> > +			/* paranoid */
> > +			if (!*ptr)
> > +				break;
> > +			continue;
> > +		}
> > +		if (*ptr == '"') {
> > +			quote ^= 1;
> > +			continue;
> > +		}
> > +		if (quote)
> > +			continue;
> > +		if (isdigit(*ptr)) {
> > +			/* skip numbers */
> > +			do {
> > +				ptr++;
> > +			} while (isalnum(*ptr) || *ptr == '_');
> > +			/* we went one too many */
> 
> Hmm.. it looks like to skip variable name after a number.  Shouldn't it be 
> 
> 			do { ptr++; } while (isdigit(*ptr));
> 
> ?

A variable can not be appended to a number in C. But alpha characters
like 1ULL can be, and they need to be skipped. Hmm, I probably could
remove the check for '_' though.

> 
> 
> > +			ptr--;
> > +			continue;
> > +		}
> > +		if (isalpha(*ptr) || *ptr == '_') {
> > +			if (strncmp(map->enum_string, ptr, len) == 0 &&
> > +			    !isalnum(ptr[len]) && ptr[len] != '_') {
> > +				ptr = enum_replace(ptr, map, len);
> > +				/* Hmm, enum string smaller than value */
> > +				if (WARN_ON_ONCE(!ptr))
> > +					return;
> > +				continue;
> 
> I guess it also needs to decrease the ptr here.

I thought about this when writing it and realized that it just replaced
a variable and two variables can not be bumped against each other.
There must be something in between them, and we can skip whatever that
something is.

I could add a comment about that.

> 
> 
> > +			}
> > +			do {
> > +				ptr++;
> > +			} while (isalnum(*ptr) || *ptr == '_');
> > +			/* we went one too many */
> > +			ptr--;
> > +			continue;
> > +		}
> > +	}
> > +}
> > +
> > +void trace_event_enum_update(struct trace_enum_map *map, int len)
> > +{
> > +	struct ftrace_event_call *call, *p;
> > +	const char *last_system = NULL;
> > +	int last_i;
> > +	int i;
> > +
> > +	down_write(&trace_event_sem);
> > +	list_for_each_entry_safe(call, p, &ftrace_events, list) {
> > +		/* events are usually grouped together with systems */
> > +		if (!last_system || call->class->system != last_system)
> > +			last_i = 0;
> 
> I think it needs to update the last_system here.

Ouch, yeah you're right!

Will fix.

Thanks,

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ