<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/net/tls/tls_main.c, branch linux-5.7.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.7.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.7.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-04-08T21:34:02Z</updated>
<entry>
<title>net/tls: fix const assignment warning</title>
<updated>2020-04-08T21:34:02Z</updated>
<author>
<name>Arnd Bergmann</name>
</author>
<published>2020-04-08T18:54:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f691a25ce5e5e405156ad4091c8e660b2622b7ad'/>
<id>urn:sha1:f691a25ce5e5e405156ad4091c8e660b2622b7ad</id>
<content type='text'>
Building with some experimental patches, I came across a warning
in the tls code:

include/linux/compiler.h:215:30: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  215 |  *(volatile typeof(x) *)&amp;(x) = (val);  \
      |                              ^
net/tls/tls_main.c:650:4: note: in expansion of macro 'smp_store_release'
  650 |    smp_store_release(&amp;saved_tcpv4_prot, prot);

This appears to be a legitimate warning about assigning a const pointer
into the non-const 'saved_tcpv4_prot' global. Annotate both the ipv4 and
ipv6 pointers 'const' to make the code internally consistent.

Fixes: 5bb4c45d466c ("net/tls: Read sk_prot once when building tls proto ops")
Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/tls: Annotate access to sk_prot with READ_ONCE/WRITE_ONCE</title>
<updated>2020-03-22T03:08:17Z</updated>
<author>
<name>Jakub Sitnicki</name>
</author>
<published>2020-03-17T17:04:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d5bee7374b68de3c44586d46e9e61ffc97a1e886'/>
<id>urn:sha1:d5bee7374b68de3c44586d46e9e61ffc97a1e886</id>
<content type='text'>
sockmap performs lockless writes to sk-&gt;sk_prot on the following paths:

tcp_bpf_{recvmsg|sendmsg} / sock_map_unref
  sk_psock_put
    sk_psock_drop
      sk_psock_restore_proto
        WRITE_ONCE(sk-&gt;sk_prot, proto)

To prevent load/store tearing [1], and to make tooling aware of intentional
shared access [2], we need to annotate other sites that access sk_prot with
READ_ONCE/WRITE_ONCE macros.

Change done with Coccinelle with following semantic patch:

@@
expression E;
identifier I;
struct sock *sk;
identifier sk_prot =~ "^sk_prot$";
@@
(
 E =
-sk-&gt;sk_prot
+READ_ONCE(sk-&gt;sk_prot)
|
-sk-&gt;sk_prot = E
+WRITE_ONCE(sk-&gt;sk_prot, E)
|
-sk-&gt;sk_prot
+READ_ONCE(sk-&gt;sk_prot)
 -&gt;I
)

Signed-off-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/tls: Read sk_prot once when building tls proto ops</title>
<updated>2020-03-22T03:08:17Z</updated>
<author>
<name>Jakub Sitnicki</name>
</author>
<published>2020-03-17T17:04:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5bb4c45d466cb28dd0a7f15f80c4cb7768054e94'/>
<id>urn:sha1:5bb4c45d466cb28dd0a7f15f80c4cb7768054e94</id>
<content type='text'>
Apart from being a "tremendous" win when it comes to generated machine
code (see bloat-o-meter output for x86-64 below) this mainly prepares
ground for annotating access to sk_prot with READ_ONCE, so that we don't
pepper the code with access annotations and needlessly repeat loads.

add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-46 (-46)
Function                                     old     new   delta
tls_init                                     851     805     -46
Total: Before=21063, After=21017, chg -0.22%

Signed-off-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/tls: Constify base proto ops used for building tls proto</title>
<updated>2020-03-22T03:08:17Z</updated>
<author>
<name>Jakub Sitnicki</name>
</author>
<published>2020-03-17T17:04:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f13fe3e60c799e0fce643458b3bb336bf444cd25'/>
<id>urn:sha1:f13fe3e60c799e0fce643458b3bb336bf444cd25</id>
<content type='text'>
The helper that builds kTLS proto ops doesn't need to and should not modify
the base proto ops. Annotate the parameter as read-only.

Signed-off-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net, sk_msg: Annotate lockless access to sk_prot on clone</title>
<updated>2020-02-21T21:29:45Z</updated>
<author>
<name>Jakub Sitnicki</name>
</author>
<published>2020-02-18T17:10:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b8e202d1d1d0f182f01062804efb523ea9a9008c'/>
<id>urn:sha1:b8e202d1d1d0f182f01062804efb523ea9a9008c</id>
<content type='text'>
sk_msg and ULP frameworks override protocol callbacks pointer in
sk-&gt;sk_prot, while tcp accesses it locklessly when cloning the listening
socket, that is with neither sk_lock nor sk_callback_lock held.

Once we enable use of listening sockets with sockmap (and hence sk_msg),
there will be shared access to sk-&gt;sk_prot if socket is getting cloned
while being inserted/deleted to/from the sockmap from another CPU:

Read side:

tcp_v4_rcv
  sk = __inet_lookup_skb(...)
  tcp_check_req(sk)
    inet_csk(sk)-&gt;icsk_af_ops-&gt;syn_recv_sock
      tcp_v4_syn_recv_sock
        tcp_create_openreq_child
          inet_csk_clone_lock
            sk_clone_lock
              READ_ONCE(sk-&gt;sk_prot)

Write side:

sock_map_ops-&gt;map_update_elem
  sock_map_update_elem
    sock_map_update_common
      sock_map_link_no_progs
        tcp_bpf_init
          tcp_bpf_update_sk_prot
            sk_psock_update_proto
              WRITE_ONCE(sk-&gt;sk_prot, ops)

sock_map_ops-&gt;map_delete_elem
  sock_map_delete_elem
    __sock_map_delete
     sock_map_unref
       sk_psock_put
         sk_psock_drop
           sk_psock_restore_proto
             tcp_update_ulp
               WRITE_ONCE(sk-&gt;sk_prot, proto)

Mark the shared access with READ_ONCE/WRITE_ONCE annotations.

Signed-off-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20200218171023.844439-2-jakub@cloudflare.com
</content>
</entry>
<entry>
<title>bpf: Sockmap/tls, push write_space updates through ulp updates</title>
<updated>2020-01-15T22:26:13Z</updated>
<author>
<name>John Fastabend</name>
</author>
<published>2020-01-11T06:12:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=33bfe20dd7117dd81fd896a53f743a233e1ad64f'/>
<id>urn:sha1:33bfe20dd7117dd81fd896a53f743a233e1ad64f</id>
<content type='text'>
When sockmap sock with TLS enabled is removed we cleanup bpf/psock state
and call tcp_update_ulp() to push updates to TLS ULP on top. However, we
don't push the write_space callback up and instead simply overwrite the
op with the psock stored previous op. This may or may not be correct so
to ensure we don't overwrite the TLS write space hook pass this field to
the ULP and have it fixup the ctx.

This completes a previous fix that pushed the ops through to the ULP
but at the time missed doing this for write_space, presumably because
write_space TLS hook was added around the same time.

Fixes: 95fa145479fbc ("bpf: sockmap/tls, close can race with map free")
Signed-off-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Reviewed-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Acked-by: Jonathan Lemon &lt;jonathan.lemon@gmail.com&gt;
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/bpf/20200111061206.8028-4-john.fastabend@gmail.com
</content>
</entry>
<entry>
<title>net/tls: Fix return values to avoid ENOTSUPP</title>
<updated>2019-12-07T04:15:39Z</updated>
<author>
<name>Valentin Vidic</name>
</author>
<published>2019-12-05T06:41:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4a5cdc604b9cf645e6fa24d8d9f055955c3c8516'/>
<id>urn:sha1:4a5cdc604b9cf645e6fa24d8d9f055955c3c8516</id>
<content type='text'>
ENOTSUPP is not available in userspace, for example:

  setsockopt failed, 524, Unknown error 524

Signed-off-by: Valentin Vidic &lt;vvidic@valentin-vidic.from.hr&gt;
Acked-by: Jakub Kicinski &lt;jakub.kicinski@netronome.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/tls: use sg_next() to walk sg entries</title>
<updated>2019-11-29T06:40:29Z</updated>
<author>
<name>Jakub Kicinski</name>
</author>
<published>2019-11-27T20:16:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c5daa6cccdc2f94aca2c9b3fa5f94e4469997293'/>
<id>urn:sha1:c5daa6cccdc2f94aca2c9b3fa5f94e4469997293</id>
<content type='text'>
Partially sent record cleanup path increments an SG entry
directly instead of using sg_next(). This should not be a
problem today, as encrypted messages should be always
allocated as arrays. But given this is a cleanup path it's
easy to miss was this ever to change. Use sg_next(), and
simplify the code.

Signed-off-by: Jakub Kicinski &lt;jakub.kicinski@netronome.com&gt;
Reviewed-by: Simon Horman &lt;simon.horman@netronome.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net</title>
<updated>2019-11-23T00:27:24Z</updated>
<author>
<name>Jakub Kicinski</name>
</author>
<published>2019-11-23T00:27:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a9f852e92e40992c4ff09ac3940f7725e016317a'/>
<id>urn:sha1:a9f852e92e40992c4ff09ac3940f7725e016317a</id>
<content type='text'>
Minor conflict in drivers/s390/net/qeth_l2_main.c, kept the lock
from commit c8183f548902 ("s390/qeth: fix potential deadlock on
workqueue flush"), removed the code which was removed by commit
9897d583b015 ("s390/qeth: consolidate some duplicated HW cmd code").

Signed-off-by: Jakub Kicinski &lt;jakub.kicinski@netronome.com&gt;
</content>
</entry>
<entry>
<title>net/tls: enable sk_msg redirect to tls socket egress</title>
<updated>2019-11-19T23:03:02Z</updated>
<author>
<name>Willem de Bruijn</name>
</author>
<published>2019-11-18T15:40:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d4ffb02dee2fcb20e0c8086a8d1305bf885820bb'/>
<id>urn:sha1:d4ffb02dee2fcb20e0c8086a8d1305bf885820bb</id>
<content type='text'>
Bring back tls_sw_sendpage_locked. sk_msg redirection into a socket
with TLS_TX takes the following path:

  tcp_bpf_sendmsg_redir
    tcp_bpf_push_locked
      tcp_bpf_push
        kernel_sendpage_locked
          sock-&gt;ops-&gt;sendpage_locked

Also update the flags test in tls_sw_sendpage_locked to allow flag
MSG_NO_SHARED_FRAGS. bpf_tcp_sendmsg sets this.

Link: https://lore.kernel.org/netdev/CA+FuTSdaAawmZ2N8nfDDKu3XLpXBbMtcCT0q4FntDD2gn8ASUw@mail.gmail.com/T/#t
Link: https://github.com/wdebruij/kerneltools/commits/icept.2
Fixes: 0608c69c9a80 ("bpf: sk_msg, sock{map|hash} redirect through ULP")
Fixes: f3de19af0f5b ("Revert \"net/tls: remove unused function tls_sw_sendpage_locked\"")
Signed-off-by: Willem de Bruijn &lt;willemb@google.com&gt;
Acked-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
