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
| ||
|
Date: Thu, 8 Feb 2018 22:31:53 -0500 From: Steven Rostedt <rostedt@...dmis.org> To: Namhyung Kim <namhyung@...nel.org> Cc: linux-kernel@...r.kernel.org, Linus Torvalds <torvalds@...ux-foundation.org>, Ingo Molnar <mingo@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>, Thomas Gleixner <tglx@...utronix.de>, Peter Zijlstra <peterz@...radead.org>, Masami Hiramatsu <mhiramat@...nel.org>, Tom Zanussi <tom.zanussi@...ux.intel.com>, linux-rt-users@...r.kernel.org, linux-trace-users@...r.kernel.org, Arnaldo Carvalho de Melo <acme@...nel.org>, Clark Williams <williams@...hat.com>, Jiri Olsa <jolsa@...hat.com>, Daniel Bristot de Oliveira <bristot@...hat.com>, Juri Lelli <juri.lelli@...hat.com>, Jonathan Corbet <corbet@....net>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, Alexei Starovoitov <alexei.starovoitov@...il.com>, kernel-team@....com Subject: Re: [PATCH 15/18] tracing: Add string type for dynamic strings in function based events On Fri, 9 Feb 2018 12:15:47 +0900 Namhyung Kim <namhyung@...nel.org> wrote: > > @@ -124,6 +128,16 @@ enum { > > FUNC_TYPE_MAX > > }; > > > > +#define MAX_STR 512 > > + > > +/* Two contexts, normal and NMI, hence the " * 2" */ > > +struct func_string { > > + char buf[MAX_STR * 2]; > > +}; > > + > > +static struct func_string __percpu *str_buffer; > > +static int nr_strings; > > What protects it? Grumble, I was thinking that the entire create_function_event was under the func_event_mutex, which it is not. So nr_strings is not fully protected. I'll fix that thanks. As for str_buffer, I should comment this as it is rather subtle. +static int read_string(char *str, unsigned long addr) +{ + unsigned long flags; + struct func_string *strbuf; + char *ptr = (void *)addr; + char *buf; + int ret; + + if (!str_buffer) + return 0; + + strbuf = this_cpu_ptr(str_buffer); + buf = &strbuf->buf[0]; + + if (in_nmi()) + buf += MAX_STR; + + local_irq_save(flags); Like I said, this is really subtle, and desperately needs a comment. The str_buffer is per cpu and can only be access under irqs disabled. If we are in NMI, then we move the starting position forward by MAX_STR. I'll add comments and protect create_function_event with the mutex. Thanks for pointing this out! -- Steve + ret = strncpy_from_unsafe(buf, ptr, MAX_STR); + if (ret < 0) + ret = 0; + if (ret > 0 && str) + memcpy(str, buf, ret); + local_irq_restore(flags); + + return ret; +}
Powered by blists - more mailing lists