<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/bpf, branch v4.19</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.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2018-10-11T08:19:01Z</updated>
<entry>
<title>xsk: do not call synchronize_net() under RCU read lock</title>
<updated>2018-10-11T08:19:01Z</updated>
<author>
<name>Björn Töpel</name>
<email>bjorn.topel@intel.com</email>
</author>
<published>2018-10-08T17:40:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cee271678d0e3177a25d0fcb2fa5e051d48e4262'/>
<id>urn:sha1:cee271678d0e3177a25d0fcb2fa5e051d48e4262</id>
<content type='text'>
The XSKMAP update and delete functions called synchronize_net(), which
can sleep. It is not allowed to sleep during an RCU read section.

Instead we need to make sure that the sock sk_destruct (xsk_destruct)
function is asynchronously called after an RCU grace period. Setting
the SOCK_RCU_FREE flag for XDP sockets takes care of this.

Fixes: fbfc504a24f5 ("bpf: introduce new bpf AF_XDP map type BPF_MAP_TYPE_XSKMAP")
Reported-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Signed-off-by: Björn Töpel &lt;bjorn.topel@intel.com&gt;
Acked-by: Song Liu &lt;songliubraving@fb.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: 32-bit RSH verification must truncate input before the ALU op</title>
<updated>2018-10-05T16:41:45Z</updated>
<author>
<name>Jann Horn</name>
<email>jannh@google.com</email>
</author>
<published>2018-10-05T16:17:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b799207e1e1816b09e7a5920fbb2d5fcf6edd681'/>
<id>urn:sha1:b799207e1e1816b09e7a5920fbb2d5fcf6edd681</id>
<content type='text'>
When I wrote commit 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification"), I
assumed that, in order to emulate 64-bit arithmetic with 32-bit logic, it
is sufficient to just truncate the output to 32 bits; and so I just moved
the register size coercion that used to be at the start of the function to
the end of the function.

That assumption is true for almost every op, but not for 32-bit right
shifts, because those can propagate information towards the least
significant bit. Fix it by always truncating inputs for 32-bit ops to 32
bits.

Also get rid of the coerce_reg_to_size() after the ALU op, since that has
no effect.

Fixes: 468f6eafa6c4 ("bpf: fix 32-bit ALU op verification")
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Jann Horn &lt;jannh@google.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: don't accept cgroup local storage with zero value size</title>
<updated>2018-10-02T12:42:23Z</updated>
<author>
<name>Roman Gushchin</name>
<email>guro@fb.com</email>
</author>
<published>2018-10-02T02:41:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b0584ea66d73919cbf5878a3420a837f06ab8396'/>
<id>urn:sha1:b0584ea66d73919cbf5878a3420a837f06ab8396</id>
<content type='text'>
Explicitly forbid creating cgroup local storage maps with zero value
size, as it makes no sense and might even cause a panic.

Reported-by: syzbot+18628320d3b14a5c459c@syzkaller.appspotmail.com
Signed-off-by: Roman Gushchin &lt;guro@fb.com&gt;
Cc: Alexei Starovoitov &lt;ast@kernel.org&gt;
Cc: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: harden flags check in cgroup_storage_update_elem()</title>
<updated>2018-09-28T13:50:23Z</updated>
<author>
<name>Roman Gushchin</name>
<email>guro@fb.com</email>
</author>
<published>2018-09-28T13:33:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4288ea006c73e37c2a4f60dfaef20dd167b8df31'/>
<id>urn:sha1:4288ea006c73e37c2a4f60dfaef20dd167b8df31</id>
<content type='text'>
cgroup_storage_update_elem() shouldn't accept any flags
argument values except BPF_ANY and BPF_EXIST to guarantee
the backward compatibility, had a new flag value been added.

Fixes: de9cbbaadba5 ("bpf: introduce cgroup storage maps")
Signed-off-by: Roman Gushchin &lt;guro@fb.com&gt;
Reported-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Cc: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: sockmap, fix transition through disconnect without close</title>
<updated>2018-09-22T00:46:41Z</updated>
<author>
<name>John Fastabend</name>
<email>john.fastabend@gmail.com</email>
</author>
<published>2018-09-18T16:01:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b05545e15e1ff1d6a6a8593971275f9cc3e6b92b'/>
<id>urn:sha1:b05545e15e1ff1d6a6a8593971275f9cc3e6b92b</id>
<content type='text'>
It is possible (via shutdown()) for TCP socks to go trough TCP_CLOSE
state via tcp_disconnect() without actually calling tcp_close which
would then call our bpf_tcp_close() callback. Because of this a user
could disconnect a socket then put it in a LISTEN state which would
break our assumptions about sockets always being ESTABLISHED state.

To resolve this rely on the unhash hook, which is called in the
disconnect case, to remove the sock from the sockmap.

Reported-by: Eric Dumazet &lt;edumazet@google.com&gt;
Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks")
Signed-off-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: sockmap only allow ESTABLISHED sock state</title>
<updated>2018-09-22T00:46:41Z</updated>
<author>
<name>John Fastabend</name>
<email>john.fastabend@gmail.com</email>
</author>
<published>2018-09-18T16:01:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5607fff303636d48b88414c6be353d9fed700af2'/>
<id>urn:sha1:5607fff303636d48b88414c6be353d9fed700af2</id>
<content type='text'>
After this patch we only allow socks that are in ESTABLISHED state or
are being added via a sock_ops event that is transitioning into an
ESTABLISHED state. By allowing sock_ops events we allow users to
manage sockmaps directly from sock ops programs. The two supported
sock_ops ops are BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB and
BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB.

Similar to TLS ULP this ensures sk_user_data is correct.

Reported-by: Eric Dumazet &lt;edumazet@google.com&gt;
Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks")
Signed-off-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf/verifier: disallow pointer subtraction</title>
<updated>2018-09-12T21:30:02Z</updated>
<author>
<name>Alexei Starovoitov</name>
<email>ast@kernel.org</email>
</author>
<published>2018-09-12T21:06:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dd066823db2ac4e22f721ec85190817b58059a54'/>
<id>urn:sha1:dd066823db2ac4e22f721ec85190817b58059a54</id>
<content type='text'>
Subtraction of pointers was accidentally allowed for unpriv programs
by commit 82abbf8d2fc4. Revert that part of commit.

Fixes: 82abbf8d2fc4 ("bpf: do not allow root to mangle valid pointers")
Reported-by: Jann Horn &lt;jannh@google.com&gt;
Acked-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: btf: Fix end boundary calculation for type section</title>
<updated>2018-09-12T20:00:23Z</updated>
<author>
<name>Martin KaFai Lau</name>
<email>kafai@fb.com</email>
</author>
<published>2018-09-12T17:29:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4b1c5d917d34f705096bb7dd8a2bd19b0881970e'/>
<id>urn:sha1:4b1c5d917d34f705096bb7dd8a2bd19b0881970e</id>
<content type='text'>
The end boundary math for type section is incorrect in
btf_check_all_metas().  It just happens that hdr-&gt;type_off
is always 0 for now because there are only two sections
(type and string) and string section must be at the end (ensured
in btf_parse_str_sec).

However, type_off may not be 0 if a new section would be added later.
This patch fixes it.

Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header")
Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Signed-off-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: avoid misuse of psock when TCP_ULP_BPF collides with another ULP</title>
<updated>2018-09-02T20:31:10Z</updated>
<author>
<name>John Fastabend</name>
<email>john.fastabend@gmail.com</email>
</author>
<published>2018-08-31T04:25:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=597222f72a94118f593e4f32bf58ae7e049a0df1'/>
<id>urn:sha1:597222f72a94118f593e4f32bf58ae7e049a0df1</id>
<content type='text'>
Currently we check sk_user_data is non NULL to determine if the sk
exists in a map. However, this is not sufficient to ensure the psock
or the ULP ops are not in use by another user, such as kcm or TLS. To
avoid this when adding a sock to a map also verify it is of the
correct ULP type. Additionally, when releasing a psock verify that
it is the TCP_ULP_BPF type before releasing the ULP. The error case
where we abort an update due to ULP collision can cause this error
path.

For example,

  __sock_map_ctx_update_elem()
     [...]
     err = tcp_set_ulp_id(sock, TCP_ULP_BPF) &lt;- collides with TLS
     if (err)                                &lt;- so err out here
        goto out_free
     [...]
  out_free:
     smap_release_sock() &lt;- calling tcp_cleanup_ulp releases the
                            TLS ULP incorrectly.

Fixes: 2f857d04601a ("bpf: sockmap, remove STRPARSER map_flags and add multi-map support")
Signed-off-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
<entry>
<title>bpf: sockmap, decrement copied count correctly in redirect error case</title>
<updated>2018-08-28T07:01:06Z</updated>
<author>
<name>John Fastabend</name>
<email>john.fastabend@gmail.com</email>
</author>
<published>2018-08-25T00:37:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=501ca81760c204ec59b73e4a00bee5971fc0f1b1'/>
<id>urn:sha1:501ca81760c204ec59b73e4a00bee5971fc0f1b1</id>
<content type='text'>
Currently, when a redirect occurs in sockmap and an error occurs in
the redirect call we unwind the scatterlist once in the error path
of bpf_tcp_sendmsg_do_redirect() and then again in sendmsg(). Then
in the error path of sendmsg we decrement the copied count by the
send size.

However, its possible we partially sent data before the error was
generated. This can happen if do_tcp_sendpages() partially sends the
scatterlist before encountering a memory pressure error. If this
happens we need to decrement the copied value (the value tracking
how many bytes were actually sent to TCP stack) by the number of
remaining bytes _not_ the entire send size. Otherwise we risk
confusing userspace.

Also we don't need two calls to free the scatterlist one is
good enough. So remove the one in bpf_tcp_sendmsg_do_redirect() and
then properly reduce copied by the number of remaining bytes which
may in fact be the entire send size if no bytes were sent.

To do this use bool to indicate if free_start_sg() should do mem
accounting or not.

Signed-off-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
</content>
</entry>
</feed>
