From: Andi Kleen <andi@firstfloor.org>
To: Jovi Zhangwei <jovi.zhangwei@gmail.com>
Cc: Ingo Molnar <mingo@redhat.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH 07/28] ktap: add runtime/ktap.[c|h]
Date: Fri, 28 Mar 2014 11:38:27 -0700 [thread overview]
Message-ID: <87ha6inp7g.fsf@tassilo.jf.intel.com> (raw)
In-Reply-To: <1396014469-5937-8-git-send-email-jovi.zhangwei@gmail.com> (Jovi Zhangwei's message of "Fri, 28 Mar 2014 09:47:28 -0400")
Jovi Zhangwei <jovi.zhangwei@gmail.com> writes:
Quick review of the file.
> +#include <linux/version.h>
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0)
> +#error "Currently ktap don't support kernel older than 3.1"
> +#endif
> +
> +#if !CONFIG_EVENT_TRACING
> +#error "Please enable CONFIG_EVENT_TRACING before compile ktap"
> +#endif
> +
> +#if !CONFIG_PERF_EVENTS
> +#error "Please enable CONFIG_PERF_EVENTS before compile ktap"
> +#endif
This should be all in Kconfig
> +/* common helper function */
> +long gettimeofday_ns(void)
> +{
> + struct timespec now;
> +
> + getnstimeofday(&now);
> + return now.tv_sec * NSEC_PER_SEC + now.tv_nsec;
> +}
This is ktime_get()
Or more likely you want something like trace_clock(), otherwise
you may have problems on systems not using TSC.
> +
> +static int load_trunk(ktap_option_t *parm, unsigned long **buff)
> +{
> + int ret;
> + unsigned long *vmstart;
> +
> + vmstart = vmalloc(parm->trunk_len);
> + if (!vmstart)
> + return -ENOMEM;
> +
> + ret = copy_from_user(vmstart, (void __user *)parm->trunk,
> + parm->trunk_len);
Needs unsigned length check if supplied from user space.
> + if (ret < 0) {
> + vfree(vmstart);
> + return -EFAULT;
> + }
> +
> + *buff = vmstart;
> + return 0;
> +}
> +
> +static struct dentry *kp_dir_dentry;
What lock protects that?
> +static long ktap_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> +{
> + ktap_option_t parm;
> + int ret;
> +
> + switch (cmd) {
> + case KTAP_CMD_IOC_VERSION:
> + print_version();
This seems odd. Should return the version instead?
> + return 0;
> + case KTAP_CMD_IOC_RUN:
> + /*
> + * must be root to run ktap script (at least for now)
> + *
> + * TODO: check perf_paranoid sysctl and allow non-root user
> + * to use ktap for tracing process(like uprobe) ?
This would need ensuring first that there is no possible way to crash
the kernel. Probably very hard.
> + */
> + if (!capable(CAP_SYS_ADMIN))
> + return -EACCES;
> +
> + ret = copy_from_user(&parm, (void __user *)arg,
> + sizeof(ktap_option_t));
> + if (ret < 0)
> + return -EFAULT;
The check is wrong, it should be != 0
> +struct syscall_metadata **syscalls_metadata;
> +
> +/*TODO: kill this function in future */
> +static int __init init_dummy_kernel_functions(void)
> +{
> + unsigned long *addr;
> +
> + /*
> + * ktap need symbol ftrace_profile_set_filter to set event filter,
> + * export it in future.
Obviously you need to fix that. Just export the symbols.
> +
> +extern struct syscall_metadata **syscalls_metadata;
> +
> +/* get from kernel/trace/trace.h */
Use that version instead.
> +static __always_inline int trace_get_context_bit(void)
> +{
> + int bit;
> +
> + if (in_interrupt()) {
> + if (in_nmi())
> + bit = 0;
> + else if (in_irq())
> + bit = 1;
> + else
> + bit = 2;
> + } else
> + bit = 3;
> +
> + return bit;
> +}
-Andi
--
ak@linux.intel.com -- Speaking for myself only
next prev parent reply other threads:[~2014-03-28 18:40 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 13:47 [RFC PATCH 00/28] ktap: A lightweight dynamic tracing tool for Linux Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 01/28] ktap: add README file Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 02/28] ktap: add ktap tutorial Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 03/28] ktap: add sample scripts Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 04/28] ktap: add basic ktap types definition Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 05/28] ktap: add bytecode definition Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 06/28] ktap: add include/ktap_arch.h and error header file Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 07/28] ktap: add runtime/ktap.[c|h] Jovi Zhangwei
2014-03-28 18:38 ` Andi Kleen [this message]
2014-03-29 7:32 ` Jovi Zhangwei
2014-03-29 17:04 ` Greg Kroah-Hartman
2014-03-30 7:26 ` Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 08/28] ktap: add runtime/kp_bcread.[c|h] Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 09/28] ktap: add runtime/kp_vm.[c|h] Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 10/28] ktap: add runtime/kp_str.[c|h] and runtime/kp_mempool.[c|h] Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 11/28] ktap: add runtime/kp_tab.[c|h] Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 12/28] ktap: add runtime/kp_obj.[c|h] Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 13/28] ktap: add runtime/kp_transport.[c|h] Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 14/28] ktap: add runtime/kp_events.[c|h] Jovi Zhangwei
2014-03-31 9:10 ` Masami Hiramatsu
2014-03-31 10:14 ` Jovi Zhangwei
2014-04-01 6:59 ` Masami Hiramatsu
2014-04-01 7:28 ` Jovi Zhangwei
2014-04-01 8:05 ` Masami Hiramatsu
2014-03-28 13:47 ` [PATCH 15/28] ktap: add built-in functions and library (runtime/lib_*.c) Jovi Zhangwei
2014-03-28 18:51 ` Andi Kleen
2014-03-29 4:15 ` Jovi Zhangwei
2014-03-30 0:58 ` Andi Kleen
2014-03-31 2:01 ` Jovi Zhangwei
2014-03-31 13:13 ` Andi Kleen
2014-04-02 1:44 ` Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 16/28] ktap: add runtime/amalg.c Jovi Zhangwei
2014-03-28 18:52 ` Andi Kleen
2014-03-29 7:38 ` Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 17/28] ktap: add userspace/kp_main.c Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 18/28] ktap: add compiler(userspace/kp_lex.[c|h] and userspace/kp_parse.[c|h]) Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 19/28] ktap: add userspace/symbol.[c|h] Jovi Zhangwei
2014-04-01 7:28 ` Masami Hiramatsu
2014-03-28 13:47 ` [PATCH 20/28] ktap: add userspace/kp_parse_events.c Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 21/28] ktap: add userspace/kp_reader.c Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 22/28] ktap: add userspace/kp_bcwrite.c Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 23/28] ktap: add userspace/kp_util.c Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 24/28] ktap: add Makefile Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 25/28] ktap: add Kconfig Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 26/28] ktap: add testsuite Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 27/28] ktap: add vim syntax file Jovi Zhangwei
2014-03-28 13:47 ` [PATCH 28/28] ktap: add COPYRIGHT file Jovi Zhangwei
2014-03-28 16:08 ` [RFC PATCH 00/28] ktap: A lightweight dynamic tracing tool for Linux Greg Kroah-Hartman
2014-03-29 1:46 ` Jovi Zhangwei
2014-03-31 7:17 ` Ingo Molnar
2014-03-31 10:01 ` Jovi Zhangwei
2014-03-31 21:29 ` Alexei Starovoitov
2014-04-01 4:47 ` Jovi Zhangwei
2014-04-02 4:57 ` Alexei Starovoitov
2014-04-02 6:37 ` Jovi Zhangwei
2014-04-02 7:43 ` Ingo Molnar
2014-04-02 8:49 ` Jovi Zhangwei
2014-04-04 7:36 ` Ingo Molnar
2014-04-08 6:50 ` Jovi Zhangwei
2014-04-14 15:11 ` Ingo Molnar
2014-04-14 15:28 ` Daniel Borkmann
2014-04-02 7:42 ` Ingo Molnar
2014-04-07 13:55 ` Peter Zijlstra
2014-04-08 7:40 ` Masami Hiramatsu
2014-04-08 9:08 ` Peter Zijlstra
2014-04-02 7:36 ` Ingo Molnar
2014-03-31 20:06 ` Daniel Borkmann
2014-03-31 9:18 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ha6inp7g.fsf@tassilo.jf.intel.com \
--to=andi@firstfloor.org \
--cc=fweisbec@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jovi.zhangwei@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@redhat.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome