1. 26 7月, 2020 18 次提交
    • Y
      bpf: Implement bpf iterator for map elements · a5cbe05a
      Yonghong Song 提交于
      The bpf iterator for map elements are implemented.
      The bpf program will receive four parameters:
        bpf_iter_meta *meta: the meta data
        bpf_map *map:        the bpf_map whose elements are traversed
        void *key:           the key of one element
        void *value:         the value of the same element
      
      Here, meta and map pointers are always valid, and
      key has register type PTR_TO_RDONLY_BUF_OR_NULL and
      value has register type PTR_TO_RDWR_BUF_OR_NULL.
      The kernel will track the access range of key and value
      during verification time. Later, these values will be compared
      against the values in the actual map to ensure all accesses
      are within range.
      
      A new field iter_seq_info is added to bpf_map_ops which
      is used to add map type specific information, i.e., seq_ops,
      init/fini seq_file func and seq_file private data size.
      Subsequent patches will have actual implementation
      for bpf_map_ops->iter_seq_info.
      
      In user space, BPF_ITER_LINK_MAP_FD needs to be
      specified in prog attr->link_create.flags, which indicates
      that attr->link_create.target_fd is a map_fd.
      The reason for such an explicit flag is for possible
      future cases where one bpf iterator may allow more than
      one possible customization, e.g., pid and cgroup id for
      task_file.
      
      Current kernel internal implementation only allows
      the target to register at most one required bpf_iter_link_info.
      To support the above case, optional bpf_iter_link_info's
      are needed, the target can be extended to register such link
      infos, and user provided link_info needs to match one of
      target supported ones.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200723184112.590360-1-yhs@fb.com
      a5cbe05a
    • Y
      bpf: Support readonly/readwrite buffers in verifier · afbf21dc
      Yonghong Song 提交于
      Readonly and readwrite buffer register states
      are introduced. Totally four states,
      PTR_TO_RDONLY_BUF[_OR_NULL] and PTR_TO_RDWR_BUF[_OR_NULL]
      are supported. As suggested by their respective
      names, PTR_TO_RDONLY_BUF[_OR_NULL] are for
      readonly buffers and PTR_TO_RDWR_BUF[_OR_NULL]
      for read/write buffers.
      
      These new register states will be used
      by later bpf map element iterator.
      
      New register states share some similarity to
      PTR_TO_TP_BUFFER as it will calculate accessed buffer
      size during verification time. The accessed buffer
      size will be later compared to other metrics during
      later attach/link_create time.
      
      Similar to reg_state PTR_TO_BTF_ID_OR_NULL in bpf
      iterator programs, PTR_TO_RDONLY_BUF_OR_NULL or
      PTR_TO_RDWR_BUF_OR_NULL reg_types can be set at
      prog->aux->bpf_ctx_arg_aux, and bpf verifier will
      retrieve the values during btf_ctx_access().
      Later bpf map element iterator implementation
      will show how such information will be assigned
      during target registeration time.
      
      The verifier is also enhanced such that PTR_TO_RDONLY_BUF
      can be passed to ARG_PTR_TO_MEM[_OR_NULL] helper argument, and
      PTR_TO_RDWR_BUF can be passed to ARG_PTR_TO_MEM[_OR_NULL] or
      ARG_PTR_TO_UNINIT_MEM.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200723184111.590274-1-yhs@fb.com
      afbf21dc
    • Y
      bpf: Refactor to provide aux info to bpf_iter_init_seq_priv_t · f9c79272
      Yonghong Song 提交于
      This patch refactored target bpf_iter_init_seq_priv_t callback
      function to accept additional information. This will be needed
      in later patches for map element targets since a particular
      map should be passed to traverse elements for that particular
      map. In the future, other information may be passed to target
      as well, e.g., pid, cgroup id, etc. to customize the iterator.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200723184110.590156-1-yhs@fb.com
      f9c79272
    • Y
      bpf: Refactor bpf_iter_reg to have separate seq_info member · 14fc6bd6
      Yonghong Song 提交于
      There is no functionality change for this patch.
      Struct bpf_iter_reg is used to register a bpf_iter target,
      which includes information for both prog_load, link_create
      and seq_file creation.
      
      This patch puts fields related seq_file creation into
      a different structure. This will be useful for map
      elements iterator where one iterator covers different
      map types and different map types may have different
      seq_ops, init/fini private_data function and
      private_data size.
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200723184109.590030-1-yhs@fb.com
      14fc6bd6
    • A
      bpf: Add bpf_prog iterator · a228a64f
      Alexei Starovoitov 提交于
      It's mostly a copy paste of commit 6086d29d ("bpf: Add bpf_map iterator")
      that is use to implement bpf_seq_file opreations to traverse all bpf programs.
      
      v1->v2: Tweak to use build time btf_id
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NYonghong Song <yhs@fb.com>
      Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
      a228a64f
    • Y
      bpf: Fix pos computation for bpf_iter seq_ops->start() · 3f9969f2
      Yonghong Song 提交于
      Currently, the pos pointer in bpf iterator map/task/task_file
      seq_ops->start() is always incremented.
      This is incorrect. It should be increased only if
      *pos is 0 (for SEQ_START_TOKEN) since these start()
      function actually returns the first real object.
      If *pos is not 0, it merely found the object
      based on the state in seq->private, and not really
      advancing the *pos. This patch fixed this issue
      by only incrementing *pos if it is 0.
      
      Note that the old *pos calculation, although not
      correct, does not affect correctness of bpf_iter
      as bpf_iter seq_file->read() does not support llseek.
      
      This patch also renamed "mid" in bpf_map iterator
      seq_file private data to "map_id" for better clarity.
      
      Fixes: 6086d29d ("bpf: Add bpf_map iterator")
      Fixes: eaaacd23 ("bpf: Add task and task/file iterator targets")
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20200722195156.4029817-1-yhs@fb.com
      3f9969f2
    • J
      selftests/bpf: Test BPF socket lookup and reuseport with connections · 86176a18
      Jakub Sitnicki 提交于
      Cover the case when BPF socket lookup returns a socket that belongs to a
      reuseport group, and the reuseport group contains connected UDP sockets.
      
      Ensure that the presence of connected UDP sockets in reuseport group does
      not affect the socket lookup result. Socket selected by reuseport should
      always be used as result in such case.
      Signed-off-by: NJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NKuniyuki Iwashima <kuniyu@amazon.co.jp>
      Link: https://lore.kernel.org/bpf/20200722161720.940831-3-jakub@cloudflare.com
      86176a18
    • J
      udp: Don't discard reuseport selection when group has connections · c8a2983c
      Jakub Sitnicki 提交于
      When BPF socket lookup prog selects a socket that belongs to a reuseport
      group, and the reuseport group has connected sockets in it, the socket
      selected by reuseport will be discarded, and socket returned by BPF socket
      lookup will be used instead.
      
      Modify this behavior so that the socket selected by reuseport running after
      BPF socket lookup always gets used. Ignore the fact that the reuseport
      group might have connections because it is only relevant when scoring
      sockets during regular hashtable-based lookup.
      
      Fixes: 72f7e944 ("udp: Run SK_LOOKUP BPF program on socket lookup")
      Fixes: 6d4201b1 ("udp6: Run SK_LOOKUP BPF program on socket lookup")
      Signed-off-by: NJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NKuniyuki Iwashima <kuniyu@amazon.co.jp>
      Link: https://lore.kernel.org/bpf/20200722161720.940831-2-jakub@cloudflare.com
      c8a2983c
    • A
      tools/bpftool: Strip BPF .o files before skeleton generation · f3c93a93
      Andrii Nakryiko 提交于
      Strip away DWARF info from .bpf.o files, before generating BPF skeletons.
      This reduces bpftool binary size from 3.43MB to 2.58MB.
      Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NQuentin Monnet <quentin@isovalent.com>
      Link: https://lore.kernel.org/bpf/20200722043804.2373298-1-andriin@fb.com
      f3c93a93
    • D
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net · a57066b1
      David S. Miller 提交于
      The UDP reuseport conflict was a little bit tricky.
      
      The net-next code, via bpf-next, extracted the reuseport handling
      into a helper so that the BPF sk lookup code could invoke it.
      
      At the same time, the logic for reuseport handling of unconnected
      sockets changed via commit efc6b6f6
      which changed the logic to carry on the reuseport result into the
      rest of the lookup loop if we do not return immediately.
      
      This requires moving the reuseport_has_conns() logic into the callers.
      
      While we are here, get rid of inline directives as they do not belong
      in foo.c files.
      
      The other changes were cases of more straightforward overlapping
      modifications.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a57066b1
    • L
      Merge tag 'riscv-for-linus-5.8-rc7' of... · 04300d66
      Linus Torvalds 提交于
      Merge tag 'riscv-for-linus-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux into master
      
      Pull RISC-V fixes from Palmer Dabbelt:
       "A few more fixes this week:
      
         - A fix to avoid using SBI calls during kasan initialization, as the
           SBI calls themselves have not been probed yet.
      
         - Three fixes related to systems with multiple memory regions"
      
      * tag 'riscv-for-linus-5.8-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        riscv: Parse all memory blocks to remove unusable memory
        RISC-V: Do not rely on initrd_start/end computed during early dt parsing
        RISC-V: Set maximum number of mapped pages correctly
        riscv: kasan: use local_tlb_flush_all() to avoid uninitialized __sbi_rfence
      04300d66
    • L
      Merge tag 'x86-urgent-2020-07-25' of... · fbe0d451
      Linus Torvalds 提交于
      Merge tag 'x86-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into master
      
      Pull x86 fixes from Ingo Molnar:
       "Misc fixes:
      
         - Fix a section end page alignment assumption that was causing
           crashes
      
         - Fix ORC unwinding on freshly forked tasks which haven't executed
           yet and which have empty user task stacks
      
         - Fix the debug.exception-trace=1 sysctl dumping of user stacks,
           which was broken by recent maccess changes"
      
      * tag 'x86-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/dumpstack: Dump user space code correctly again
        x86/stacktrace: Fix reliable check for empty user task stacks
        x86/unwind/orc: Fix ORC for newly forked tasks
        x86, vmlinux.lds: Page-align end of ..page_aligned sections
      fbe0d451
    • L
      Merge tag 'perf-urgent-2020-07-25' of... · 78b1afe2
      Linus Torvalds 提交于
      Merge tag 'perf-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into master
      
      Pull uprobe fix from Ingo Molnar:
       "Fix an interaction/regression between uprobes based shared library
        tracing & GDB"
      
      * tag 'perf-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        uprobes: Change handle_swbp() to send SIGTRAP with si_code=SI_KERNEL, to fix GDB regression
      78b1afe2
    • L
      Merge tag 'timers-urgent-2020-07-25' of... · a7b36c2b
      Linus Torvalds 提交于
      Merge tag 'timers-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into master
      
      Pull timer fix from Ingo Molnar:
       "Fix a suspend/resume regression (crash) on TI AM3/AM4 SoC's"
      
      * tag 'timers-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        clocksource/drivers/timer-ti-dm: Fix suspend and resume for am3 and am4
      a7b36c2b
    • L
      Merge tag 'sched-urgent-2020-07-25' of... · 3077805e
      Linus Torvalds 提交于
      Merge tag 'sched-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into master
      
      Pull scheduler fixes from Ingo Molnar:
       "Fix a race introduced by the recent loadavg race fix, plus add a debug
        check for a hard to debug case of bogus wakeup function flags"
      
      * tag 'sched-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        sched: Warn if garbage is passed to default_wake_function()
        sched: Fix race against ptrace_freeze_trace()
      3077805e
    • L
      Merge tag 'efi-urgent-2020-07-25' of... · 17baa442
      Linus Torvalds 提交于
      Merge tag 'efi-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into master
      
      Pull EFI fixes from Ingo Molnar:
       "Various EFI fixes:
      
         - Fix the layering violation in the use of the EFI runtime services
           availability mask in users of the 'efivars' abstraction
      
         - Revert build fix for GCC v4.8 which is no longer supported
      
         - Clean up some x86 EFI stub details, some of which are borderline
           bugs that copy around garbage into padding fields - let's fix these
           out of caution.
      
         - Fix build issues while working on RISC-V support
      
         - Avoid --whole-archive when linking the stub on arm64"
      
      * tag 'efi-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        efi: Revert "efi/x86: Fix build with gcc 4"
        efi/efivars: Expose RT service availability via efivars abstraction
        efi/libstub: Move the function prototypes to header file
        efi/libstub: Fix gcc error around __umoddi3 for 32 bit builds
        efi/libstub/arm64: link stub lib.a conditionally
        efi/x86: Only copy upto the end of setup_header
        efi/x86: Remove unused variables
      17baa442
    • L
      Merge tag '5.8-rc6-cifs-fix' of git://git.samba.org/sfrench/cifs-2.6 into master · 7cb3a5c5
      Linus Torvalds 提交于
      Pull cifs fix from Steve French:
       "A fix for a recently discovered regression in rename to older servers
        caused by a recent patch"
      
      * tag '5.8-rc6-cifs-fix' of git://git.samba.org/sfrench/cifs-2.6:
        Revert "cifs: Fix the target file was deleted when rename failed."
      7cb3a5c5
    • L
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net into master · 1b64b2e2
      Linus Torvalds 提交于
      Pull networking fixes from David Miller:
      
       1) Fix RCU locaking in iwlwifi, from Johannes Berg.
      
       2) mt76 can access uninitialized NAPI struct, from Felix Fietkau.
      
       3) Fix race in updating pause settings in bnxt_en, from Vasundhara
          Volam.
      
       4) Propagate error return properly during unbind failures in ax88172a,
          from George Kennedy.
      
       5) Fix memleak in adf7242_probe, from Liu Jian.
      
       6) smc_drv_probe() can leak, from Wang Hai.
      
       7) Don't muck with the carrier state if register_netdevice() fails in
          the bonding driver, from Taehee Yoo.
      
       8) Fix memleak in dpaa_eth_probe, from Liu Jian.
      
       9) Need to check skb_put_padto() return value in hsr_fill_tag(), from
          Murali Karicheri.
      
      10) Don't lose ionic RSS hash settings across FW update, from Shannon
          Nelson.
      
      11) Fix clobbered SKB control block in act_ct, from Wen Xu.
      
      12) Missing newlink in "tx_timeout" sysfs output, from Xiongfeng Wang.
      
      13) IS_UDPLITE cleanup a long time ago, incorrectly handled
          transformations involving UDPLITE_RECV_CC. From Miaohe Lin.
      
      14) Unbalanced locking in netdevsim, from Taehee Yoo.
      
      15) Suppress false-positive error messages in qed driver, from Alexander
          Lobakin.
      
      16) Out of bounds read in ax25_connect and ax25_sendmsg, from Peilin Ye.
      
      17) Missing SKB release in cxgb4's uld_send(), from Navid Emamdoost.
      
      18) Uninitialized value in geneve_changelink(), from Cong Wang.
      
      19) Fix deadlock in xen-netfront, from Andera Righi.
      
      19) flush_backlog() frees skbs with IRQs disabled, so should use
          dev_kfree_skb_irq() instead of kfree_skb(). From Subash Abhinov
          Kasiviswanathan.
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (111 commits)
        drivers/net/wan: lapb: Corrected the usage of skb_cow
        dev: Defer free of skbs in flush_backlog
        qrtr: orphan socket in qrtr_release()
        xen-netfront: fix potential deadlock in xennet_remove()
        flow_offload: Move rhashtable inclusion to the source file
        geneve: fix an uninitialized value in geneve_changelink()
        bonding: check return value of register_netdevice() in bond_newlink()
        tcp: allow at most one TLP probe per flight
        AX.25: Prevent integer overflows in connect and sendmsg
        cxgb4: add missing release on skb in uld_send()
        net: atlantic: fix PTP on AQC10X
        AX.25: Prevent out-of-bounds read in ax25_sendmsg()
        sctp: shrink stream outq when fails to do addstream reconf
        sctp: shrink stream outq only when new outcnt < old outcnt
        AX.25: Fix out-of-bounds read in ax25_connect()
        enetc: Remove the mdio bus on PF probe bailout
        net: ethernet: ti: add NETIF_F_HW_TC hw feature flag for taprio offload
        net: ethernet: ave: Fix error returns in ave_init
        drivers/net/wan/x25_asy: Fix to make it work
        ipvs: fix the connection sync failed in some cases
        ...
      1b64b2e2
  2. 25 7月, 2020 22 次提交