diff options
author | Matt Mullins <mmullins@fb.com> | 2018-12-12 19:42:37 -0500 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-12-18 17:08:12 -0500 |
commit | a38d1107f937ca95dcf820161ef44ea683d6a0b1 (patch) | |
tree | 6fe1371db87f368a635d6d4aa7ef58031a940cf7 /kernel/bpf/syscall.c | |
parent | a137401d85129953a1713d443216eb6b1074c12e (diff) |
bpf: support raw tracepoints in modules
Distributions build drivers as modules, including network and filesystem
drivers which export numerous tracepoints. This enables
bpf(BPF_RAW_TRACEPOINT_OPEN) to attach to those tracepoints.
Signed-off-by: Matt Mullins <mmullins@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 5db31067d85e..0607db304def 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -1604,6 +1604,7 @@ static int bpf_raw_tracepoint_release(struct inode *inode, struct file *filp) | |||
1604 | bpf_probe_unregister(raw_tp->btp, raw_tp->prog); | 1604 | bpf_probe_unregister(raw_tp->btp, raw_tp->prog); |
1605 | bpf_prog_put(raw_tp->prog); | 1605 | bpf_prog_put(raw_tp->prog); |
1606 | } | 1606 | } |
1607 | bpf_put_raw_tracepoint(raw_tp->btp); | ||
1607 | kfree(raw_tp); | 1608 | kfree(raw_tp); |
1608 | return 0; | 1609 | return 0; |
1609 | } | 1610 | } |
@@ -1629,13 +1630,15 @@ static int bpf_raw_tracepoint_open(const union bpf_attr *attr) | |||
1629 | return -EFAULT; | 1630 | return -EFAULT; |
1630 | tp_name[sizeof(tp_name) - 1] = 0; | 1631 | tp_name[sizeof(tp_name) - 1] = 0; |
1631 | 1632 | ||
1632 | btp = bpf_find_raw_tracepoint(tp_name); | 1633 | btp = bpf_get_raw_tracepoint(tp_name); |
1633 | if (!btp) | 1634 | if (!btp) |
1634 | return -ENOENT; | 1635 | return -ENOENT; |
1635 | 1636 | ||
1636 | raw_tp = kzalloc(sizeof(*raw_tp), GFP_USER); | 1637 | raw_tp = kzalloc(sizeof(*raw_tp), GFP_USER); |
1637 | if (!raw_tp) | 1638 | if (!raw_tp) { |
1638 | return -ENOMEM; | 1639 | err = -ENOMEM; |
1640 | goto out_put_btp; | ||
1641 | } | ||
1639 | raw_tp->btp = btp; | 1642 | raw_tp->btp = btp; |
1640 | 1643 | ||
1641 | prog = bpf_prog_get_type(attr->raw_tracepoint.prog_fd, | 1644 | prog = bpf_prog_get_type(attr->raw_tracepoint.prog_fd, |
@@ -1663,6 +1666,8 @@ out_put_prog: | |||
1663 | bpf_prog_put(prog); | 1666 | bpf_prog_put(prog); |
1664 | out_free_tp: | 1667 | out_free_tp: |
1665 | kfree(raw_tp); | 1668 | kfree(raw_tp); |
1669 | out_put_btp: | ||
1670 | bpf_put_raw_tracepoint(btp); | ||
1666 | return err; | 1671 | return err; |
1667 | } | 1672 | } |
1668 | 1673 | ||