1. 01 Jun, 2020 1 commit
  2. 02 Jun, 2020 19 commits
  3. 01 Jun, 2020 20 commits
    • David S. Miller's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next · 9a25c1df
      David S. Miller authored
      Alexei Starovoitov says:
      
      ====================
      pull-request: bpf-next 2020-06-01
      
      The following pull-request contains BPF updates for your *net-next* tree.
      
      We've added 55 non-merge commits during the last 1 day(s) which contain
      a total of 91 files changed, 4986 insertions(+), 463 deletions(-).
      
      The main changes are:
      
      1) Add rx_queue_mapping to bpf_sock from Amritha.
      
      2) Add BPF ring buffer, from Andrii.
      
      3) Attach and run programs through devmap, from David.
      
      4) Allow SO_BINDTODEVICE opt in bpf_setsockopt, from Ferenc.
      
      5) link based flow_dissector, from Jakub.
      
      6) Use tracing helpers for lsm programs, from Jiri.
      
      7) Several sk_msg fixes and extensions, from John.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9a25c1df
    • Jules Irenge's avatar
      sfc: add missing annotation for efx_ef10_try_update_nic_stats_vf() · efd7ed0f
      Jules Irenge authored
      Sparse reports a warning at efx_ef10_try_update_nic_stats_vf()
      warning: context imbalance in efx_ef10_try_update_nic_stats_vf()
      	- unexpected unlock
      The root cause is the missing annotation at
      efx_ef10_try_update_nic_stats_vf()
      Add the missing _must_hold(&efx->stats_lock) annotation
      Signed-off-by: default avatarJules Irenge <jbi.octave@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      efd7ed0f
    • Vinay Kumar Yadav's avatar
      crypto/chtls: IPv6 support for inline TLS · 6abde0b2
      Vinay Kumar Yadav authored
      Extends support to IPv6 for Inline TLS server.
      Signed-off-by: default avatarVinay Kumar Yadav <vinay.yadav@chelsio.com>
      
      v1->v2:
      - cc'd tcp folks.
      
      v2->v3:
      - changed EXPORT_SYMBOL() to EXPORT_SYMBOL_GPL()
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6abde0b2
    • David S. Miller's avatar
      Merge branch 'chelsio-crypto-fixes' · a56772dc
      David S. Miller authored
      Ayush Sawal says:
      
      ====================
      Fixing compilation warnings and errors
      
      Patch 1: Fixes the warnings seen when compiling using sparse tool.
      
      Patch 2: Fixes a cocci check error introduced after commit
      567be3a5 ("crypto: chelsio -
      Use multiple txq/rxq per tfm to process the requests").
      
      V1->V2
      
      patch1: Avoid type casting by using get_unaligned_be32() and
          	put_unaligned_be16/32() functions.
      
      patch2: Modified subject of the patch.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a56772dc
    • Ayush Sawal's avatar
      Crypto/chcr: Fixes a coccinile check error · 055be686
      Ayush Sawal authored
      This fixes an error observed after running coccinile check.
      drivers/crypto/chelsio/chcr_algo.c:1462:5-8: Unneeded variable:
      "err". Return "0" on line 1480
      
      This line is missed in the commit 567be3a5 ("crypto:
      chelsio - Use multiple txq/rxq per tfm to process the requests").
      
      Fixes: 567be3a5 ("crypto:
      chelsio - Use multiple txq/rxq per tfm to process the requests").
      
      V1->V2
      -Modified subject.
      Signed-off-by: default avatarAyush Sawal <ayush.sawal@chelsio.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      055be686
    • Ayush Sawal's avatar
      Crypto/chcr: Fixes compilations warnings · f3b140ad
      Ayush Sawal authored
      This patch fixes the compilation warnings displayed by sparse tool for
      chcr driver.
      
      V1->V2
      
      Avoid type casting by using get_unaligned_be32() and
      put_unaligned_be16/32() functions.
      
      The key which comes from stack is an u8 byte stream so we store it in
      an unsigned char array(ablkctx->key). The function get_aes_decrypt_key()
      is a used to calculate  the reverse round key for decryption, for this
      operation the key has to be divided into 4 bytes, so to extract 4 bytes
      from an u8 byte stream and store it in an u32 variable, get_aligned_be32()
      is used. Similarly for copying back the key from u32 variable to the
      original u8 key stream, put_aligned_be32() is used.
      Signed-off-by: default avatarAyush Sawal <ayush.sawal@chelsio.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f3b140ad
    • Rohit Maheshwari's avatar
      crypto/chcr: IPV6 code needs to be in CONFIG_IPV6 · 76d7728d
      Rohit Maheshwari authored
      Error messages seen while building kernel with CONFIG_IPV6
      disabled.
      Signed-off-by: default avatarRohit Maheshwari <rohitm@chelsio.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      76d7728d
    • Rohit Maheshwari's avatar
      cxgb4/chcr: Enable ktls settings at run time · a3ac249a
      Rohit Maheshwari authored
      Current design enables ktls setting from start, which is not
      efficient. Now the feature will be enabled when user demands
      TLS offload on any interface.
      
      v1->v2:
      - taking ULD module refcount till any single connection exists.
      - taking rtnl_lock() before clearing tls_devops.
      
      v2->v3:
      - cxgb4 is now registering to tlsdev_ops.
      - module refcount inc/dec in chcr.
      - refcount is only for connections.
      - removed new code from cxgb_set_feature().
      
      v3->v4:
      - fixed warning message.
      Signed-off-by: default avatarRohit Maheshwari <rohitm@chelsio.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a3ac249a
    • Hangbin Liu's avatar
      ipv6: fix IPV6_ADDRFORM operation logic · 79a1f0cc
      Hangbin Liu authored
      Socket option IPV6_ADDRFORM supports UDP/UDPLITE and TCP at present.
      Previously the checking logic looks like:
      if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
      	do_some_check;
      else if (sk->sk_protocol != IPPROTO_TCP)
      	break;
      
      After commit b6f61189 ("ipv6: restrict IPV6_ADDRFORM operation"), TCP
      was blocked as the logic changed to:
      if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
      	do_some_check;
      else if (sk->sk_protocol == IPPROTO_TCP)
      	do_some_check;
      	break;
      else
      	break;
      
      Then after commit 82c9ae44 ("ipv6: fix restrict IPV6_ADDRFORM operation")
      UDP/UDPLITE were blocked as the logic changed to:
      if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
      	do_some_check;
      if (sk->sk_protocol == IPPROTO_TCP)
      	do_some_check;
      
      if (sk->sk_protocol != IPPROTO_TCP)
      	break;
      
      Fix it by using Eric's code and simply remove the break in TCP check, which
      looks like:
      if (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_UDPLITE)
      	do_some_check;
      else if (sk->sk_protocol == IPPROTO_TCP)
      	do_some_check;
      else
      	break;
      
      Fixes: 82c9ae44 ("ipv6: fix restrict IPV6_ADDRFORM operation")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      79a1f0cc
    • YueHaibing's avatar
      tipc: Fix NULL pointer dereference in __tipc_sendstream() · 4c21daae
      YueHaibing authored
      tipc_sendstream() may send zero length packet, then tipc_msg_append()
      do not alloc skb, skb_peek_tail() will get NULL, msg_set_ack_required
      will trigger NULL pointer dereference.
      
      Reported-by: syzbot+8eac6d030e7807c21d32@syzkaller.appspotmail.com
      Fixes: 0a3e060f ("tipc: add test for Nagle algorithm effectiveness")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4c21daae
    • Alexei Starovoitov's avatar
      Merge branch 'Link-based-attach-to-netns' · cf51abcd
      Alexei Starovoitov authored
      Jakub Sitnicki says:
      
      ====================
      One of the pieces of feedback from recent review of BPF hooks for socket
      lookup [0] was that new program types should use bpf_link-based
      attachment.
      
      This series introduces new bpf_link type for attaching to network
      namespace. All link operations are supported. Errors returned from ops
      follow cgroup example. Patch 4 description goes into error semantics.
      
      The major change in v2 is a switch away from RCU to mutex-only
      synchronization. Andrii pointed out that it is not needed, and it makes
      sense to keep locking straightforward.
      
      Also, there were a couple of bugs in update_prog and fill_info initial
      implementation, one picked up by kbuild. Those are now fixed. Tests have
      been extended to cover them. Full changelog below.
      
      Series is organized as so:
      
      Patches 1-3 prepare a space in struct net to keep state for attached BPF
      programs, and massage the code in flow_dissector to make it attach type
      agnostic, to finally move it under kernel/bpf/.
      
      Patch 4, the most important one, introduces new bpf_link link type for
      attaching to network namespace.
      
      Patch 5 unifies the update error (ENOLINK) between BPF cgroup and netns.
      
      Patches 6-8 make libbpf and bpftool aware of the new link type.
      
      Patches 9-12 Add and extend tests to check that link low- and high-level
      API for operating on links to netns works as intended.
      
      Thanks to Alexei, Andrii, Lorenz, Marek, and Stanislav for feedback.
      
      -jkbs
      
      [0] https://lore.kernel.org/bpf/20200511185218.1422406-1-jakub@cloudflare.com/
      
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Lorenz Bauer <lmb@cloudflare.com>
      Cc: Marek Majkowski <marek@cloudflare.com>
      Cc: Stanislav Fomichev <sdf@google.com>
      
      v1 -> v2:
      
      - Switch to mutex-only synchronization. Don't rely on RCU grace period
        guarantee when accessing struct net from link release / update /
        fill_info, and when accessing bpf_link from pernet pre_exit
        callback. (Andrii)
      - Drop patch 1, no longer needed with mutex-only synchronization.
      - Don't leak uninitialized variable contents from fill_info callback
        when link is in defunct state. (kbuild)
      - Make fill_info treat the link as defunct (i.e. no attached netns) when
        struct net refcount is 0, but link has not been yet auto-detached.
      - Add missing BPF_LINK_TYPE define in bpf_types.h for new link type.
      - Fix link update_prog callback to update the prog that will run, and
        not just the link itself.
      - Return EEXIST on prog attach when link already exists, and on link
        create when prog is already attached directly. (Andrii)
      - Return EINVAL on prog detach when link is attached. (Andrii)
      - Fold __netns_bpf_link_attach into its only caller. (Stanislav)
      - Get rid of a wrapper around container_of() (Andrii)
      - Use rcu_dereference_protected instead of rcu_access_pointer on
        update-side. (Stanislav)
      - Make return-on-success from netns_bpf_link_create less
        confusing. (Andrii)
      - Adapt bpf_link for cgroup to return ENOLINK when updating a defunct
        link. (Andrii, Alexei)
      - Order new exported symbols in libbpf.map alphabetically (Andrii)
      - Keep libbpf's "failed to attach link" warning message clear as to what
        we failed to attach to (cgroup vs netns). (Andrii)
      - Extract helpers for printing link attach type. (bpftool, Andrii)
      - Switch flow_dissector tests to BPF skeleton and extend them to
        exercise link-based flow dissector attachment. (Andrii)
      - Harden flow dissector attachment tests with prog query checks after
        prog attach/detach, or link create/update/close.
      - Extend flow dissector tests to cover fill_info for defunct links.
      - Rebase onto recent bpf-next
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      cf51abcd
    • Jakub Sitnicki's avatar
      selftests/bpf: Extend test_flow_dissector to cover link creation · 06716e04
      Jakub Sitnicki authored
      Extend the existing flow_dissector test case to run tests once using direct
      prog attachments, and then for the second time using indirect attachment
      via link.
      
      The intention is to exercises the newly added high-level API for attaching
      programs to network namespace with links (bpf_program__attach_netns).
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-13-jakub@cloudflare.com
      06716e04
    • Jakub Sitnicki's avatar
      selftests/bpf: Convert test_flow_dissector to use BPF skeleton · b4b8a3bf
      Jakub Sitnicki authored
      Switch flow dissector test setup from custom BPF object loader to BPF
      skeleton to save boilerplate and prepare for testing higher-level API for
      attaching flow dissector with bpf_link.
      
      To avoid depending on program order in the BPF object when populating the
      flow dissector PROG_ARRAY map, change the program section names to contain
      the program index into the map. This follows the example set by tailcall
      tests.
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-12-jakub@cloudflare.com
      b4b8a3bf
    • Jakub Sitnicki's avatar
      selftests/bpf, flow_dissector: Close TAP device FD after the test · b8215dce
      Jakub Sitnicki authored
      test_flow_dissector leaves a TAP device after it's finished, potentially
      interfering with other tests that will run after it. Fix it by closing the
      TAP descriptor on cleanup.
      
      Fixes: 0905beec ("selftests/bpf: run flow dissector tests in skb-less mode")
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-11-jakub@cloudflare.com
      b8215dce
    • Jakub Sitnicki's avatar
      selftests/bpf: Add tests for attaching bpf_link to netns · 1f043f87
      Jakub Sitnicki authored
      Extend the existing test case for flow dissector attaching to cover:
      
       - link creation,
       - link updates,
       - link info querying,
       - mixing links with direct prog attachment.
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-10-jakub@cloudflare.com
      1f043f87
    • Jakub Sitnicki's avatar
      bpftool: Support link show for netns-attached links · e948947a
      Jakub Sitnicki authored
      Make `bpf link show` aware of new link type, that is links attached to
      netns. When listing netns-attached links, display netns inode number as its
      identifier and link attach type.
      
      Sample session:
      
        # readlink /proc/self/ns/net
        net:[4026532251]
        # bpftool prog show
        357: flow_dissector  tag a04f5eef06a7f555  gpl
                loaded_at 2020-05-30T16:53:51+0200  uid 0
                xlated 16B  jited 37B  memlock 4096B
        358: flow_dissector  tag a04f5eef06a7f555  gpl
                loaded_at 2020-05-30T16:53:51+0200  uid 0
                xlated 16B  jited 37B  memlock 4096B
        # bpftool link show
        108: netns  prog 357
                netns_ino 4026532251  attach_type flow_dissector
        # bpftool link -jp show
        [{
                "id": 108,
                "type": "netns",
                "prog_id": 357,
                "netns_ino": 4026532251,
                "attach_type": "flow_dissector"
            }
        ]
      
        (... after netns is gone ...)
      
        # bpftool link show
        108: netns  prog 357
                netns_ino 0  attach_type flow_dissector
        # bpftool link -jp show
        [{
                "id": 108,
                "type": "netns",
                "prog_id": 357,
                "netns_ino": 0,
                "attach_type": "flow_dissector"
            }
        ]
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-9-jakub@cloudflare.com
      e948947a
    • Jakub Sitnicki's avatar
      bpftool: Extract helpers for showing link attach type · be6e1981
      Jakub Sitnicki authored
      Code for printing link attach_type is duplicated in a couple of places, and
      likely will be duplicated for future link types as well. Create helpers to
      prevent duplication.
      Suggested-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-8-jakub@cloudflare.com
      be6e1981
    • Jakub Sitnicki's avatar
      libbpf: Add support for bpf_link-based netns attachment · d60d81ac
      Jakub Sitnicki authored
      Add bpf_program__attach_nets(), which uses LINK_CREATE subcommand to create
      an FD-based kernel bpf_link, for attach types tied to network namespace,
      that is BPF_FLOW_DISSECTOR for the moment.
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-7-jakub@cloudflare.com
      d60d81ac
    • Jakub Sitnicki's avatar
      bpf, cgroup: Return ENOLINK for auto-detached links on update · 0c047ecb
      Jakub Sitnicki authored
      Failure to update a bpf_link because it has been auto-detached by a dying
      cgroup currently results in EINVAL error, even though the arguments passed
      to bpf() syscall are not wrong.
      
      bpf_links attaching to netns in this case will return ENOLINK, which
      carries the message that the link is no longer attached to anything.
      
      Change cgroup bpf_links to do the same to keep the uAPI errors consistent.
      
      Fixes: 0c991ebc ("bpf: Implement bpf_prog replacement for an active bpf_cgroup_link")
      Suggested-by: default avatarLorenz Bauer <lmb@cloudflare.com>
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-6-jakub@cloudflare.com
      0c047ecb
    • Jakub Sitnicki's avatar
      bpf: Add link-based BPF program attachment to network namespace · 7f045a49
      Jakub Sitnicki authored
      Extend bpf() syscall subcommands that operate on bpf_link, that is
      LINK_CREATE, LINK_UPDATE, OBJ_GET_INFO, to accept attach types tied to
      network namespaces (only flow dissector at the moment).
      
      Link-based and prog-based attachment can be used interchangeably, but only
      one can exist at a time. Attempts to attach a link when a prog is already
      attached directly, and the other way around, will be met with -EEXIST.
      Attempts to detach a program when link exists result in -EINVAL.
      
      Attachment of multiple links of same attach type to one netns is not
      supported with the intention to lift the restriction when a use-case
      presents itself. Because of that link create returns -E2BIG when trying to
      create another netns link, when one already exists.
      
      Link-based attachments to netns don't keep a netns alive by holding a ref
      to it. Instead links get auto-detached from netns when the latter is being
      destroyed, using a pernet pre_exit callback.
      
      When auto-detached, link lives in defunct state as long there are open FDs
      for it. -ENOLINK is returned if a user tries to update a defunct link.
      
      Because bpf_link to netns doesn't hold a ref to struct net, special care is
      taken when releasing, updating, or filling link info. The netns might be
      getting torn down when any of these link operations are in progress. That
      is why auto-detach and update/release/fill_info are synchronized by the
      same mutex. Also, link ops have to always check if auto-detach has not
      happened yet and if netns is still alive (refcnt > 0).
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200531082846.2117903-5-jakub@cloudflare.com
      7f045a49