1. 19 1月, 2021 2 次提交
  2. 02 12月, 2020 1 次提交
  3. 28 11月, 2020 1 次提交
  4. 26 11月, 2020 1 次提交
  5. 18 11月, 2020 1 次提交
  6. 10 10月, 2020 1 次提交
    • R
      net/tls: sendfile fails with ktls offload · ea1dd3e9
      Rohit Maheshwari 提交于
      At first when sendpage gets called, if there is more data, 'more' in
      tls_push_data() gets set which later sets pending_open_record_frags, but
      when there is no more data in file left, and last time tls_push_data()
      gets called, pending_open_record_frags doesn't get reset. And later when
      2 bytes of encrypted alert comes as sendmsg, it first checks for
      pending_open_record_frags, and since this is set, it creates a record with
      0 data bytes to encrypt, meaning record length is prepend_size + tag_size
      only, which causes problem.
       We should set/reset pending_open_record_frags based on more bit.
      
      Fixes: e8f69799 ("net/tls: Add generic NIC offload infrastructure")
      Signed-off-by: NRohit Maheshwari <rohitm@chelsio.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      ea1dd3e9
  7. 12 8月, 2020 1 次提交
  8. 28 6月, 2020 2 次提交
  9. 28 5月, 2020 1 次提交
  10. 22 3月, 2020 1 次提交
    • J
      net/tls: Annotate access to sk_prot with READ_ONCE/WRITE_ONCE · d5bee737
      Jakub Sitnicki 提交于
      sockmap performs lockless writes to sk->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->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->sk_prot
      +READ_ONCE(sk->sk_prot)
      |
      -sk->sk_prot = E
      +WRITE_ONCE(sk->sk_prot, E)
      |
      -sk->sk_prot
      +READ_ONCE(sk->sk_prot)
       ->I
      )
      Signed-off-by: NJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d5bee737
  11. 20 2月, 2020 1 次提交
    • R
      net/tls: Fix to avoid gettig invalid tls record · 06f5201c
      Rohit Maheshwari 提交于
      Current code doesn't check if tcp sequence number is starting from (/after)
      1st record's start sequnce number. It only checks if seq number is before
      1st record's end sequnce number. This problem will always be a possibility
      in re-transmit case. If a record which belongs to a requested seq number is
      already deleted, tls_get_record will start looking into list and as per the
      check it will look if seq number is before the end seq of 1st record, which
      will always be true and will return 1st record always, it should in fact
      return NULL.
      As part of the fix, start looking each record only if the sequence number
      lies in the list else return NULL.
      There is one more check added, driver look for the start marker record to
      handle tcp packets which are before the tls offload start sequence number,
      hence return 1st record if the record is tls start marker and seq number is
      before the 1st record's starting sequence number.
      
      Fixes: e8f69799 ("net/tls: Add generic NIC offload infrastructure")
      Signed-off-by: NRohit Maheshwari <rohitm@chelsio.com>
      Reviewed-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      06f5201c
  12. 20 12月, 2019 1 次提交
  13. 07 12月, 2019 1 次提交
  14. 07 11月, 2019 2 次提交
    • J
      net/tls: add a TX lock · 79ffe608
      Jakub Kicinski 提交于
      TLS TX needs to release and re-acquire the socket lock if send buffer
      fills up.
      
      TLS SW TX path currently depends on only allowing one thread to enter
      the function by the abuse of sk_write_pending. If another writer is
      already waiting for memory no new ones are allowed in.
      
      This has two problems:
       - writers don't wake other threads up when they leave the kernel;
         meaning that this scheme works for single extra thread (second
         application thread or delayed work) because memory becoming
         available will send a wake up request, but as Mallesham and
         Pooja report with larger number of threads it leads to threads
         being put to sleep indefinitely;
       - the delayed work does not get _scheduled_ but it may _run_ when
         other writers are present leading to crashes as writers don't
         expect state to change under their feet (same records get pushed
         and freed multiple times); it's hard to reliably bail from the
         work, however, because the mere presence of a writer does not
         guarantee that the writer will push pending records before exiting.
      
      Ensuring wakeups always happen will make the code basically open
      code a mutex. Just use a mutex.
      
      The TLS HW TX path does not have any locking (not even the
      sk_write_pending hack), yet it uses a per-socket sg_tx_data
      array to push records.
      
      Fixes: a42055e8 ("net/tls: Add support for async encryption of records for performance")
      Reported-by: NMallesham  Jatharakonda <mallesh537@gmail.com>
      Reported-by: NPooja Trivedi <poojatrivedi@gmail.com>
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: NSimon Horman <simon.horman@netronome.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      79ffe608
    • J
      net/tls: don't pay attention to sk_write_pending when pushing partial records · 02b1fa07
      Jakub Kicinski 提交于
      sk_write_pending being not zero does not guarantee that partial
      record will be pushed. If the thread waiting for memory times out
      the pending record may get stuck.
      
      In case of tls_device there is no path where parial record is
      set and writer present in the first place. Partial record is
      set only in tls_push_sg() and tls_push_sg() will return an
      error immediately. All tls_device callers of tls_push_sg()
      will return (and not wait for memory) if it failed.
      
      Fixes: a42055e8 ("net/tls: Add support for async encryption of records for performance")
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Reviewed-by: NSimon Horman <simon.horman@netronome.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      02b1fa07
  15. 07 10月, 2019 3 次提交
  16. 06 10月, 2019 3 次提交
  17. 08 9月, 2019 4 次提交
  18. 05 9月, 2019 3 次提交
  19. 01 9月, 2019 1 次提交
  20. 09 8月, 2019 1 次提交
    • J
      net/tls: prevent skb_orphan() from leaking TLS plain text with offload · 41477662
      Jakub Kicinski 提交于
      sk_validate_xmit_skb() and drivers depend on the sk member of
      struct sk_buff to identify segments requiring encryption.
      Any operation which removes or does not preserve the original TLS
      socket such as skb_orphan() or skb_clone() will cause clear text
      leaks.
      
      Make the TCP socket underlying an offloaded TLS connection
      mark all skbs as decrypted, if TLS TX is in offload mode.
      Then in sk_validate_xmit_skb() catch skbs which have no socket
      (or a socket with no validation) and decrypted flag set.
      
      Note that CONFIG_SOCK_VALIDATE_XMIT, CONFIG_TLS_DEVICE and
      sk->sk_validate_xmit_skb are slightly interchangeable right now,
      they all imply TLS offload. The new checks are guarded by
      CONFIG_TLS_DEVICE because that's the option guarding the
      sk_buff->decrypted member.
      
      Second, smaller issue with orphaning is that it breaks
      the guarantee that packets will be delivered to device
      queues in-order. All TLS offload drivers depend on that
      scheduling property. This means skb_orphan_partial()'s
      trick of preserving partial socket references will cause
      issues in the drivers. We need a full orphan, and as a
      result netem delay/throttling will cause all TLS offload
      skbs to be dropped.
      
      Reusing the sk_buff->decrypted flag also protects from
      leaking clear text when incoming, decrypted skb is redirected
      (e.g. by TC).
      
      See commit 0608c69c ("bpf: sk_msg, sock{map|hash} redirect
      through ULP") for justification why the internal flag is safe.
      The only location which could leak the flag in is tcp_bpf_sendmsg(),
      which is taken care of by clearing the previously unused bit.
      
      v2:
       - remove superfluous decrypted mark copy (Willem);
       - remove the stale doc entry (Boris);
       - rely entirely on EOR marking to prevent coalescing (Boris);
       - use an internal sendpages flag instead of marking the socket
         (Boris).
      v3 (Willem):
       - reorganize the can_skb_orphan_partial() condition;
       - fix the flag leak-in through tcp_bpf_sendmsg.
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Acked-by: NWillem de Bruijn <willemb@google.com>
      Reviewed-by: NBoris Pismenny <borisp@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      41477662
  21. 31 7月, 2019 1 次提交
  22. 23 7月, 2019 1 次提交
  23. 22 7月, 2019 2 次提交
  24. 09 7月, 2019 2 次提交
  25. 02 7月, 2019 2 次提交