1. Oct 08, 2020
  2. Oct 07, 2020
  3. Oct 06, 2020
    • Andrii Nakryiko's avatar
      bpf, doc: Update Andrii's email in MAINTAINERS · dca4121c
      Andrii Nakryiko authored
      
      
      Update Andrii Nakryiko's reviewer email to kernel.org account. This optimizes
      email logistics on my side and makes it less likely for me to miss important
      patches.
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20201005223648.2437130-1-andrii@kernel.org
      dca4121c
    • Song Liu's avatar
      bpf: Use raw_spin_trylock() for pcpu_freelist_push/pop in NMI · 39d8f0d1
      Song Liu authored
      
      
      Recent improvements in LOCKDEP highlighted a potential A-A deadlock with
      pcpu_freelist in NMI:
      
      ./tools/testing/selftests/bpf/test_progs -t stacktrace_build_id_nmi
      
      [   18.984807] ================================
      [   18.984807] WARNING: inconsistent lock state
      [   18.984808] 5.9.0-rc6-01771-g1466de1330e1 #2967 Not tainted
      [   18.984809] --------------------------------
      [   18.984809] inconsistent {INITIAL USE} -> {IN-NMI} usage.
      [   18.984810] test_progs/1990 [HC2[2]:SC0[0]:HE0:SE1] takes:
      [   18.984810] ffffe8ffffc219c0 (&head->lock){....}-{2:2}, at: __pcpu_freelist_pop+0xe3/0x180
      [   18.984813] {INITIAL USE} state was registered at:
      [   18.984814]   lock_acquire+0x175/0x7c0
      [   18.984814]   _raw_spin_lock+0x2c/0x40
      [   18.984815]   __pcpu_freelist_pop+0xe3/0x180
      [   18.984815]   pcpu_freelist_pop+0x31/0x40
      [   18.984816]   htab_map_alloc+0xbbf/0xf40
      [   18.984816]   __do_sys_bpf+0x5aa/0x3ed0
      [   18.984817]   do_syscall_64+0x2d/0x40
      [   18.984818]   entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [   18.984818] irq event stamp: 12
      [...]
      [   18.984822] other info that might help us debug this:
      [   18.984823]  Possible unsafe locking scenario:
      [   18.984823]
      [   18.984824]        CPU0
      [   18.984824]        ----
      [   18.984824]   lock(&head->lock);
      [   18.984826]   <Interrupt>
      [   18.984826]     lock(&head->lock);
      [   18.984827]
      [   18.984828]  *** DEADLOCK ***
      [   18.984828]
      [   18.984829] 2 locks held by test_progs/1990:
      [...]
      [   18.984838]  <NMI>
      [   18.984838]  dump_stack+0x9a/0xd0
      [   18.984839]  lock_acquire+0x5c9/0x7c0
      [   18.984839]  ? lock_release+0x6f0/0x6f0
      [   18.984840]  ? __pcpu_freelist_pop+0xe3/0x180
      [   18.984840]  _raw_spin_lock+0x2c/0x40
      [   18.984841]  ? __pcpu_freelist_pop+0xe3/0x180
      [   18.984841]  __pcpu_freelist_pop+0xe3/0x180
      [   18.984842]  pcpu_freelist_pop+0x17/0x40
      [   18.984842]  ? lock_release+0x6f0/0x6f0
      [   18.984843]  __bpf_get_stackid+0x534/0xaf0
      [   18.984843]  bpf_prog_1fd9e30e1438d3c5_oncpu+0x73/0x350
      [   18.984844]  bpf_overflow_handler+0x12f/0x3f0
      
      This is because pcpu_freelist_head.lock is accessed in both NMI and
      non-NMI context. Fix this issue by using raw_spin_trylock() in NMI.
      
      Since NMI interrupts non-NMI context, when NMI context tries to lock the
      raw_spinlock, non-NMI context of the same CPU may already have locked a
      lock and is blocked from unlocking the lock. For a system with N CPUs,
      there could be N NMIs at the same time, and they may block N non-NMI
      raw_spinlocks. This is tricky for pcpu_freelist_push(), where unlike
      _pop(), failing _push() means leaking memory. This issue is more likely to
      trigger in non-SMP system.
      
      Fix this issue with an extra list, pcpu_freelist.extralist. The extralist
      is primarily used to take _push() when raw_spin_trylock() failed on all
      the per CPU lists. It should be empty most of the time. The following
      table summarizes the behavior of pcpu_freelist in NMI and non-NMI:
      
      non-NMI pop(): 	use _lock(); check per CPU lists first;
                      if all per CPU lists are empty, check extralist;
                      if extralist is empty, return NULL.
      
      non-NMI push(): use _lock(); only push to per CPU lists.
      
      NMI pop():    use _trylock(); check per CPU lists first;
                    if all per CPU lists are locked or empty, check extralist;
                    if extralist is locked or empty, return NULL.
      
      NMI push():   use _trylock(); check per CPU lists first;
                    if all per CPU lists are locked; try push to extralist;
                    if extralist is also locked, keep trying on per CPU lists.
      
      Reported-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20201005165838.3735218-1-songliubraving@fb.com
      39d8f0d1
  4. Oct 05, 2020
  5. Oct 03, 2020
  6. Oct 02, 2020
    • Stanislav Fomichev's avatar
      selftests/bpf: Properly initialize linfo in sockmap_basic · 48ca6243
      Stanislav Fomichev authored
      
      
      When using -Werror=missing-braces, compiler complains about missing braces.
      Let's use use ={} initialization which should do the job:
      
      tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: In function 'test_sockmap_iter':
      tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: missing braces around initializer [-Werror=missing-braces]
        union bpf_iter_link_info linfo = {0};
              ^
      tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: (near initialization for 'linfo.map') [-Werror=missing-braces]
      tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: At top level:
      
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20201002000451.1794044-1-sdf@google.com
      48ca6243
    • Stanislav Fomichev's avatar
      selftests/bpf: Initialize duration in xdp_noinline.c · cffcdbff
      Stanislav Fomichev authored
      
      
      Fixes clang error:
      tools/testing/selftests/bpf/prog_tests/xdp_noinline.c:35:6: error: variable 'duration' is uninitialized when used here [-Werror,-Wuninitialized]
              if (CHECK(!skel, "skel_open_and_load", "failed\n"))
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20201001225440.1373233-1-sdf@google.com
      cffcdbff
    • Armin Wolf's avatar
      lib8390: Use netif_msg_init to initialize msg_enable bits · 360f8987
      Armin Wolf authored
      
      
      Use netif_msg_init() to process param settings
      and use only the proper initialized value of
      ei_local->msg_level for later processing;
      
      Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      360f8987
    • Willy Liu's avatar
      net: phy: realtek: Modify 2.5G PHY name to RTL8226 · 7a333af6
      Willy Liu authored
      
      
      Realtek single-chip Ethernet PHY solutions can be separated as below:
      10M/100Mbps: RTL8201X
      1Gbps: RTL8211X
      2.5Gbps: RTL8226/RTL8221X
      RTL8226 is the first version for realtek that compatible 2.5Gbps single PHY.
      Since RTL8226 is single port only, realtek changes its name to RTL8221B from
      the second version.
      PHY ID for RTL8226 is 0x001cc800 and RTL8226B/RTL8221B is 0x001cc840.
      
      RTL8125 is not a single PHY solution, it integrates PHY/MAC/PCIE bus
      controller and embedded memory.
      
      Signed-off-by: default avatarWilly Liu <willy.liu@realtek.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7a333af6
    • Jing Xiangfeng's avatar
      caif_virtio: Remove redundant initialization of variable err · f1638a4c
      Jing Xiangfeng authored
      After commit a8c7687b
      
       ("caif_virtio: Check that vringh_config is not
      null"), the variable err is being initialized with '-EINVAL' that is
      meaningless. So remove it.
      
      Signed-off-by: default avatarJing Xiangfeng <jingxiangfeng@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f1638a4c
    • Ye Bin's avatar
      net-sysfs: Fix inconsistent of format with argument type in net-sysfs.c · 000fe268
      Ye Bin authored
      
      
      Fix follow warnings:
      [net/core/net-sysfs.c:1161]: (warning) %u in format string (no. 1)
      	requires 'unsigned int' but the argument type is 'int'.
      [net/core/net-sysfs.c:1162]: (warning) %u in format string (no. 1)
      	requires 'unsigned int' but the argument type is 'int'.
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      000fe268
    • Ye Bin's avatar
      pktgen: Fix inconsistent of format with argument type in pktgen.c · 32be425b
      Ye Bin authored
      
      
      Fix follow warnings:
      [net/core/pktgen.c:925]: (warning) %u in format string (no. 1)
      	requires 'unsigned int' but the argument type is 'signed int'.
      [net/core/pktgen.c:942]: (warning) %u in format string (no. 1)
      	requires 'unsigned int' but the argument type is 'signed int'.
      [net/core/pktgen.c:962]: (warning) %u in format string (no. 1)
      	requires 'unsigned int' but the argument type is 'signed int'.
      [net/core/pktgen.c:984]: (warning) %u in format string (no. 1)
      	requires 'unsigned int' but the argument type is 'signed int'.
      [net/core/pktgen.c:1149]: (warning) %d in format string (no. 1)
      	requires 'int' but the argument type is 'unsigned int'.
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      32be425b
    • Xie He's avatar
      drivers/net/wan/hdlc_fr: Correctly handle special skb->protocol values · 8306266c
      Xie He authored
      
      
      The fr_hard_header function is used to prepend the header to skbs before
      transmission. It is used in 3 situations:
      1) When a control packet is generated internally in this driver;
      2) When a user sends an skb on an Ethernet-emulating PVC device;
      3) When a user sends an skb on a normal PVC device.
      
      These 3 situations need to be handled differently by fr_hard_header.
      Different headers should be prepended to the skb in different situations.
      
      Currently fr_hard_header distinguishes these 3 situations using
      skb->protocol. For situation 1 and 2, a special skb->protocol value
      will be assigned before calling fr_hard_header, so that it can recognize
      these 2 situations. All skb->protocol values other than these special ones
      are treated by fr_hard_header as situation 3.
      
      However, it is possible that in situation 3, the user sends an skb with
      one of the special skb->protocol values. In this case, fr_hard_header
      would incorrectly treat it as situation 1 or 2.
      
      This patch tries to solve this issue by using skb->dev instead of
      skb->protocol to distinguish between these 3 situations. For situation
      1, skb->dev would be NULL; for situation 2, skb->dev->type would be
      ARPHRD_ETHER; and for situation 3, skb->dev->type would be ARPHRD_DLCI.
      
      This way fr_hard_header would be able to distinguish these 3 situations
      correctly regardless what skb->protocol value the user tries to use in
      situation 3.
      
      Cc: Krzysztof Halasa <khc@pm.waw.pl>
      Signed-off-by: default avatarXie He <xie.he.0141@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8306266c
    • David S. Miller's avatar
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next · 23a1f682
      David S. Miller authored
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf-next 2020-10-01
      
      The following pull-request contains BPF updates for your *net-next* tree.
      
      We've added 90 non-merge commits during the last 8 day(s) which contain
      a total of 103 files changed, 7662 insertions(+), 1894 deletions(-).
      
      Note that once bpf(/net) tree gets merged into net-next, there will be a small
      merge conflict in tools/lib/bpf/btf.c between commit 12450081 ("libbpf: Fix
      native endian assumption when parsing BTF") from the bpf tree and the commit
      3289959b ("libbpf: Support BTF loading and raw data output in both endianness")
      from the bpf-next tree. Correct resolution would be to stick with bpf-next, it
      should look like:
      
        [...]
              /* check BTF magic */
              if (fread(&magic, 1, sizeof(magic), f) < sizeof(magic)) {
                      err = -EIO;
                      goto err_out;
              }
              if (magic != BTF_MAGIC && magic != bswap_16(BTF_MAGIC)) {
         ...
      23a1f682