]> Git Repo - J-linux.git/commitdiff
Merge tag 'trace-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
authorLinus Torvalds <[email protected]>
Thu, 6 May 2021 17:03:38 +0000 (10:03 -0700)
committerLinus Torvalds <[email protected]>
Thu, 6 May 2021 17:03:38 +0000 (10:03 -0700)
Pull tracing fix from Steven Rostedt:
 "Fix probes written to the set_ftrace_filter file

  Now that there's a library that accesses the tracefs file system
  (libtracefs), the way the files are interacted with is slightly
  different than the command line. For instance, the write() system call
  is used directly instead of an echo. This exposes some old bugs.

  If a probe is written to "set_ftrace_filter" without any white space
  after it, it will be ignored. This is because the write expects that a
  string written to it that does not end with white spaces thinks there
  is more to come. But if the file is closed, the release function needs
  to finish it. The "set_ftrace_filter" release function handles the
  filter part of the "set_ftrace_filter" file, but did not handle the
  probe part"

* tag 'trace-v5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  ftrace: Handle commands when closing set_ftrace_filter file

1  2 
kernel/trace/ftrace.c

diff --combined kernel/trace/ftrace.c
index 792b5589ba645bafb707c2ce9fe4d75a108c90d4,c57508445faa816c69fa7dedba9fce894cd4853d..2e8a3fde710446e52cf48d593e453da0bf5b057b
@@@ -5039,20 -5039,6 +5039,20 @@@ struct ftrace_direct_func *ftrace_find_
        return NULL;
  }
  
 +static struct ftrace_direct_func *ftrace_alloc_direct_func(unsigned long addr)
 +{
 +      struct ftrace_direct_func *direct;
 +
 +      direct = kmalloc(sizeof(*direct), GFP_KERNEL);
 +      if (!direct)
 +              return NULL;
 +      direct->addr = addr;
 +      direct->count = 0;
 +      list_add_rcu(&direct->next, &ftrace_direct_funcs);
 +      ftrace_direct_func_count++;
 +      return direct;
 +}
 +
  /**
   * register_ftrace_direct - Call a custom trampoline directly
   * @ip: The address of the nop at the beginning of a function
@@@ -5128,11 -5114,15 +5128,11 @@@ int register_ftrace_direct(unsigned lon
  
        direct = ftrace_find_direct_func(addr);
        if (!direct) {
 -              direct = kmalloc(sizeof(*direct), GFP_KERNEL);
 +              direct = ftrace_alloc_direct_func(addr);
                if (!direct) {
                        kfree(entry);
                        goto out_unlock;
                }
 -              direct->addr = addr;
 -              direct->count = 0;
 -              list_add_rcu(&direct->next, &ftrace_direct_funcs);
 -              ftrace_direct_func_count++;
        }
  
        entry->ip = ip;
@@@ -5333,7 -5323,6 +5333,7 @@@ int __weak ftrace_modify_direct_caller(
  int modify_ftrace_direct(unsigned long ip,
                         unsigned long old_addr, unsigned long new_addr)
  {
 +      struct ftrace_direct_func *direct, *new_direct = NULL;
        struct ftrace_func_entry *entry;
        struct dyn_ftrace *rec;
        int ret = -ENODEV;
        if (entry->direct != old_addr)
                goto out_unlock;
  
 +      direct = ftrace_find_direct_func(old_addr);
 +      if (WARN_ON(!direct))
 +              goto out_unlock;
 +      if (direct->count > 1) {
 +              ret = -ENOMEM;
 +              new_direct = ftrace_alloc_direct_func(new_addr);
 +              if (!new_direct)
 +                      goto out_unlock;
 +              direct->count--;
 +              new_direct->count++;
 +      } else {
 +              direct->addr = new_addr;
 +      }
 +
        /*
         * If there's no other ftrace callback on the rec->ip location,
         * then it can be changed directly by the architecture.
                ret = 0;
        }
  
 +      if (unlikely(ret && new_direct)) {
 +              direct->count++;
 +              list_del_rcu(&new_direct->next);
 +              synchronize_rcu_tasks();
 +              kfree(new_direct);
 +              ftrace_direct_func_count--;
 +      }
 +
   out_unlock:
        mutex_unlock(&ftrace_lock);
        mutex_unlock(&direct_mutex);
@@@ -5624,7 -5591,10 +5624,10 @@@ int ftrace_regex_release(struct inode *
  
        parser = &iter->parser;
        if (trace_parser_loaded(parser)) {
-               ftrace_match_records(iter->hash, parser->buffer, parser->idx);
+               int enable = !(iter->flags & FTRACE_ITER_NOTRACE);
+               ftrace_process_regex(iter, parser->buffer,
+                                    parser->idx, enable);
        }
  
        trace_parser_put(parser);
This page took 0.063617 seconds and 4 git commands to generate.