<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/bpf_trace.c, branch v4.7</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.7</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.7'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2016-06-16T06:37:54Z</updated>
<entry>
<title>bpf, trace: check event type in bpf_perf_event_read</title>
<updated>2016-06-16T06:37:54Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-06-16T01:25:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ad572d174787daa59e24b8b5c83028c09cdb5ddb'/>
<id>urn:sha1:ad572d174787daa59e24b8b5c83028c09cdb5ddb</id>
<content type='text'>
similar to bpf_perf_event_output() the bpf_perf_event_read() helper
needs to check the type of the perf_event before reading the counter.

Fixes: a43eec304259 ("bpf: introduce bpf_perf_event_output() helper")
Reported-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf: fix matching of data/data_end in verifier</title>
<updated>2016-06-16T06:37:54Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-06-16T01:25:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=19de99f70b87fcc3338da52a89c439b088cbff71'/>
<id>urn:sha1:19de99f70b87fcc3338da52a89c439b088cbff71</id>
<content type='text'>
The ctx structure passed into bpf programs is different depending on bpf
program type. The verifier incorrectly marked ctx-&gt;data and ctx-&gt;data_end
access based on ctx offset only. That caused loads in tracing programs
int bpf_prog(struct pt_regs *ctx) { .. ctx-&gt;ax .. }
to be incorrectly marked as PTR_TO_PACKET which later caused verifier
to reject the program that was actually valid in tracing context.
Fix this by doing program type specific matching of ctx offsets.

Fixes: 969bf05eb3ce ("bpf: direct packet access")
Reported-by: Sasha Goldshtein &lt;goldshtn@gmail.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf, trace: use READ_ONCE for retrieving file ptr</title>
<updated>2016-06-07T21:48:03Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2016-06-04T18:50:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5b6c1b4d46b0dae4edea636a776d09f2064f4cd7'/>
<id>urn:sha1:5b6c1b4d46b0dae4edea636a776d09f2064f4cd7</id>
<content type='text'>
In bpf_perf_event_read() and bpf_perf_event_output(), we must use
READ_ONCE() for fetching the struct file pointer, which could get
updated concurrently, so we must prevent the compiler from potential
refetching.

We already do this with tail calls for fetching the related bpf_prog,
but not so on stored perf events. Semantics for both are the same
with regards to updates.

Fixes: a43eec304259 ("bpf: introduce bpf_perf_event_output() helper")
Fixes: 35578d798400 ("bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter")
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf: add event output helper for notifications/sampling/logging</title>
<updated>2016-04-20T00:26:11Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2016-04-18T19:01:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bd570ff970a54df653b48ed0cfb373f2ebed083d'/>
<id>urn:sha1:bd570ff970a54df653b48ed0cfb373f2ebed083d</id>
<content type='text'>
This patch adds a new helper for cls/act programs that can push events
to user space applications. For networking, this can be f.e. for sampling,
debugging, logging purposes or pushing of arbitrary wake-up events. The
idea is similar to a43eec304259 ("bpf: introduce bpf_perf_event_output()
helper") and 39111695b1b8 ("samples: bpf: add bpf_perf_event_output example").

The eBPF program utilizes a perf event array map that user space populates
with fds from perf_event_open(), the eBPF program calls into the helper
f.e. as skb_event_output(skb, &amp;my_map, BPF_F_CURRENT_CPU, raw, sizeof(raw))
so that the raw data is pushed into the fd f.e. at the map index of the
current CPU.

User space can poll/mmap/etc on this and has a data channel for receiving
events that can be post-processed. The nice thing is that since the eBPF
program and user space application making use of it are tightly coupled,
they can define their own arbitrary raw data format and what/when they
want to push.

While f.e. packet headers could be one part of the meta data that is being
pushed, this is not a substitute for things like packet sockets as whole
packet is not being pushed and push is only done in a single direction.
Intention is more of a generically usable, efficient event pipe to applications.
Workflow is that tc can pin the map and applications can attach themselves
e.g. after cls/act setup to one or multiple map slots, demuxing is done by
the eBPF program.

Adding this facility is with minimal effort, it reuses the helper
introduced in a43eec304259 ("bpf: introduce bpf_perf_event_output() helper")
and we get its functionality for free by overloading its BPF_FUNC_ identifier
for cls/act programs, ctx is currently unused, but will be made use of in
future. Example will be added to iproute2's BPF example files.

Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf, trace: add BPF_F_CURRENT_CPU flag for bpf_perf_event_output</title>
<updated>2016-04-20T00:26:11Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2016-04-18T19:01:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1e33759c788c78f31d4d6f65bac647b23624734c'/>
<id>urn:sha1:1e33759c788c78f31d4d6f65bac647b23624734c</id>
<content type='text'>
Add a BPF_F_CURRENT_CPU flag to optimize the use-case where user space has
per-CPU ring buffers and the eBPF program pushes the data into the current
CPU's ring buffer which saves us an extra helper function call in eBPF.
Also, make sure to properly reserve the remaining flags which are not used.

Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf: avoid warning for wrong pointer cast</title>
<updated>2016-04-19T00:58:55Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2016-04-16T20:29:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=266a0a790fb545fa1802a899ac44f61b1d6335a7'/>
<id>urn:sha1:266a0a790fb545fa1802a899ac44f61b1d6335a7</id>
<content type='text'>
Two new functions in bpf contain a cast from a 'u64' to a
pointer. This works on 64-bit architectures but causes a warning
on all 32-bit architectures:

kernel/trace/bpf_trace.c: In function 'bpf_perf_event_output_tp':
kernel/trace/bpf_trace.c:350:13: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  u64 ctx = *(long *)r1;

This changes the cast to first convert the u64 argument into a uintptr_t,
which is guaranteed to be the same size as a pointer.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Fixes: 9940d67c93b5 ("bpf: support bpf_get_stackid() and bpf_perf_event_output() in tracepoint programs")
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf: convert relevant helper args to ARG_PTR_TO_RAW_STACK</title>
<updated>2016-04-15T01:40:41Z</updated>
<author>
<name>Daniel Borkmann</name>
<email>daniel@iogearbox.net</email>
</author>
<published>2016-04-12T22:10:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=074f528eed408b467516e142fa4c45e5b0d2ba16'/>
<id>urn:sha1:074f528eed408b467516e142fa4c45e5b0d2ba16</id>
<content type='text'>
This patch converts all helpers that can use ARG_PTR_TO_RAW_STACK as argument
type. For tc programs this is bpf_skb_load_bytes(), bpf_skb_get_tunnel_key(),
bpf_skb_get_tunnel_opt(). For tracing, this optimizes bpf_get_current_comm()
and bpf_probe_read(). The check in bpf_skb_load_bytes() for MAX_BPF_STACK can
also be removed since the verifier already makes sure we stay within bounds
on stack buffers.

Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf: support bpf_get_stackid() and bpf_perf_event_output() in tracepoint programs</title>
<updated>2016-04-08T01:04:26Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-04-07T01:43:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9940d67c93b5bb7ddcf862b41b1847cb728186c4'/>
<id>urn:sha1:9940d67c93b5bb7ddcf862b41b1847cb728186c4</id>
<content type='text'>
needs two wrapper functions to fetch 'struct pt_regs *' to convert
tracepoint bpf context into kprobe bpf context to reuse existing
helper functions

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf: register BPF_PROG_TYPE_TRACEPOINT program type</title>
<updated>2016-04-08T01:04:26Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-04-07T01:43:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9fd82b610ba3351f05a59c3e9117cfefe82f7751'/>
<id>urn:sha1:9fd82b610ba3351f05a59c3e9117cfefe82f7751</id>
<content type='text'>
register tracepoint bpf program type and let it call the same set
of helper functions as BPF_PROG_TYPE_KPROBE

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>bpf: prevent kprobe+bpf deadlocks</title>
<updated>2016-03-08T20:28:30Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@fb.com</email>
</author>
<published>2016-03-08T05:57:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b121d1e74d1f24654bdc3165d3db1ca149501356'/>
<id>urn:sha1:b121d1e74d1f24654bdc3165d3db1ca149501356</id>
<content type='text'>
if kprobe is placed within update or delete hash map helpers
that hold bucket spin lock and triggered bpf program is trying to
grab the spinlock for the same bucket on the same cpu, it will
deadlock.
Fix it by extending existing recursion prevention mechanism.

Note, map_lookup and other tracing helpers don't have this problem,
since they don't hold any locks and don't modify global data.
bpf_trace_printk has its own recursive check and ok as well.

Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
