1. 02 3月, 2021 20 次提交
    • V
      net: enetc: remove bogus write to SIRXIDR from enetc_setup_rxbdr · 96a5223b
      Vladimir Oltean 提交于
      The Station Interface Receive Interrupt Detect Register (SIRXIDR)
      contains a 16-bit wide mask of 'interrupt detected' events for each ring
      associated with a port. Bit i is write-1-to-clean for RX ring i.
      
      I have no explanation whatsoever how this line of code came to be
      inserted in the blamed commit. I checked the downstream versions of that
      patch and none of them have it.
      
      The somewhat comical aspect of it is that we're writing a binary number
      to the SIRXIDR register, which is derived from enetc_bd_unused(rx_ring).
      Since the RX rings have 512 buffer descriptors, we end up writing 511 to
      this register, which is 0x1ff, so we are effectively clearing the
      'interrupt detected' event for rings 0-8.
      
      This register is not what is used for interrupt handling though - it
      only provides a summary for the entire SI. The hardware provides one
      separate Interrupt Detect Register per RX ring, which auto-clears upon
      read. So there doesn't seem to be any adverse effect caused by this
      bogus write.
      
      There is, however, one reason why this should be handled as a bugfix:
      next_to_clean _should_ be committed to hardware, just not to that
      register, and this was obscuring the fact that it wasn't. This is fixed
      in the next patch, and removing the bogus line now allows the fix patch
      to be backported beyond that point.
      
      Fixes: fd5736bf ("enetc: Workaround for MDIO register access issue")
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      96a5223b
    • V
      net: enetc: force the RGMII speed and duplex instead of operating in inband mode · c76a9721
      Vladimir Oltean 提交于
      The ENETC port 0 MAC supports in-band status signaling coming from a PHY
      when operating in RGMII mode, and this feature is enabled by default.
      
      It has been reported that RGMII is broken in fixed-link, and that is not
      surprising considering the fact that no PHY is attached to the MAC in
      that case, but a switch.
      
      This brings us to the topic of the patch: the enetc driver should have
      not enabled the optional in-band status signaling for RGMII unconditionally,
      but should have forced the speed and duplex to what was resolved by
      phylink.
      
      Note that phylink does not accept the RGMII modes as valid for in-band
      signaling, and these operate a bit differently than 1000base-x and SGMII
      (notably there is no clause 37 state machine so no ACK required from the
      MAC, instead the PHY sends extra code words on RXD[3:0] whenever it is
      not transmitting something else, so it should be safe to leave a PHY
      with this option unconditionally enabled even if we ignore it). The spec
      talks about this here:
      https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/138/RGMIIv1_5F00_3.pdf
      
      Fixes: 71b77a7a ("enetc: Migrate to PHYLINK and PCS_LYNX")
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: Russell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: NRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c76a9721
    • V
      net: enetc: don't disable VLAN filtering in IFF_PROMISC mode · a74dbce9
      Vladimir Oltean 提交于
      Quoting from the blamed commit:
      
          In promiscuous mode, it is more intuitive that all traffic is received,
          including VLAN tagged traffic. It appears that it is necessary to set
          the flag in PSIPVMR for that to be the case, so VLAN promiscuous mode is
          also temporarily enabled. On exit from promiscuous mode, the setting
          made by ethtool is restored.
      
      Intuitive or not, there isn't any definition issued by a standards body
      which says that promiscuity has anything to do with VLAN filtering - it
      only has to do with accepting packets regardless of destination MAC address.
      
      In fact people are already trying to use this misunderstanding/bug of
      the enetc driver as a justification to transform promiscuity into
      something it never was about: accepting every packet (maybe that would
      be the "rx-all" netdev feature?):
      https://lore.kernel.org/netdev/20201110153958.ci5ekor3o2ekg3ky@ipetronik.com/
      
      This is relevant because there are use cases in the kernel (such as
      tc-flower rules with the protocol 802.1Q and a vlan_id key) which do not
      (yet) use the vlan_vid_add API to be compatible with VLAN-filtering NICs
      such as enetc, so for those, disabling rx-vlan-filter is currently the
      only right solution to make these setups work:
      https://lore.kernel.org/netdev/CA+h21hoxwRdhq4y+w8Kwgm74d4cA0xLeiHTrmT-VpSaM7obhkg@mail.gmail.com/
      The blamed patch has unintentionally introduced one more way for this to
      work, which is to enable IFF_PROMISC, however this is non-portable
      because port promiscuity is not meant to disable VLAN filtering.
      Therefore, it could invite people to write broken scripts for enetc, and
      then wonder why they are broken when migrating to other drivers that
      don't handle promiscuity in the same way.
      
      Fixes: 7070eea5 ("enetc: permit configuration of rx-vlan-filter with ethtool")
      Cc: Markus Blöchl <Markus.Bloechl@ipetronik.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a74dbce9
    • V
      net: enetc: fix incorrect TPID when receiving 802.1ad tagged packets · 827b6fd0
      Vladimir Oltean 提交于
      When the enetc ports have rx-vlan-offload enabled, they report a TPID of
      ETH_P_8021Q regardless of what was actually in the packet. When
      rx-vlan-offload is disabled, packets have the proper TPID. Fix this
      inconsistency by finishing the TODO left in the code.
      
      Fixes: d4fd0404 ("enetc: Introduce basic PF and VF ENETC ethernet drivers")
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      827b6fd0
    • V
      net: enetc: take the MDIO lock only once per NAPI poll cycle · 6d36ecdb
      Vladimir Oltean 提交于
      The workaround for the ENETC MDIO erratum caused a performance
      degradation of 82 Kpps (seen with IP forwarding of two 1Gbps streams of
      64B packets). This is due to excessive locking and unlocking in the fast
      path, which can be avoided.
      
      By taking the MDIO read-side lock only once per NAPI poll cycle, we are
      able to regain 54 Kpps (65%) of the performance hit. The rest of the
      performance degradation comes from the TX data path, but unfortunately
      it doesn't look like we can optimize that away easily, even with
      netdev_xmit_more(), there just isn't any skb batching done, to help with
      taking the MDIO lock less often than once per packet.
      
      We need to change the register accessor type for enetc_get_tx_tstamp,
      because it now runs under the enetc_lock_mdio as per the new call path
      detailed below:
      
      enetc_msix
      -> napi_schedule
         -> enetc_poll
            -> enetc_lock_mdio
            -> enetc_clean_tx_ring
               -> enetc_get_tx_tstamp
            -> enetc_clean_rx_ring
            -> enetc_unlock_mdio
      
      Fixes: fd5736bf ("enetc: Workaround for MDIO register access issue")
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6d36ecdb
    • V
      net: enetc: initialize RFS/RSS memories for unused ports too · 3222b5b6
      Vladimir Oltean 提交于
      Michael reports that since linux-next-20210211, the AER messages for ECC
      errors have started reappearing, and this time they can be reliably
      reproduced with the first ping on one of his LS1028A boards.
      
      $ ping 1[   33.258069] pcieport 0000:00:1f.0: AER: Multiple Corrected error received: 0000:00:00.0
      72.16.0.1
      PING [   33.267050] pcieport 0000:00:1f.0: AER: can't find device of ID0000
      172.16.0.1 (172.16.0.1): 56 data bytes
      64 bytes from 172.16.0.1: seq=0 ttl=64 time=17.124 ms
      64 bytes from 172.16.0.1: seq=1 ttl=64 time=0.273 ms
      
      $ devmem 0x1f8010e10 32
      0xC0000006
      
      It isn't clear why this is necessary, but it seems that for the errors
      to go away, we must clear the entire RFS and RSS memory, not just for
      the ports in use.
      
      Sadly the code is structured in such a way that we can't have unified
      logic for the used and unused ports. For the minimal initialization of
      an unused port, we need just to enable and ioremap the PF memory space,
      and a control buffer descriptor ring. Unused ports must then free the
      CBDR because the driver will exit, but used ports can not pick up from
      where that code path left, since the CBDR API does not reinitialize a
      ring when setting it up, so its producer and consumer indices are out of
      sync between the software and hardware state. So a separate
      enetc_init_unused_port function was created, and it gets called right
      after the PF memory space is enabled.
      
      Fixes: 07bf34a5 ("net: enetc: initialize the RFS and RSS memories")
      Reported-by: NMichael Walle <michael@walle.cc>
      Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Tested-by: NMichael Walle <michael@walle.cc>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3222b5b6
    • V
      net: enetc: don't overwrite the RSS indirection table when initializing · c646d10d
      Vladimir Oltean 提交于
      After the blamed patch, all RX traffic gets hashed to CPU 0 because the
      hashing indirection table set up in:
      
      enetc_pf_probe
      -> enetc_alloc_si_resources
         -> enetc_configure_si
            -> enetc_setup_default_rss_table
      
      is overwritten later in:
      
      enetc_pf_probe
      -> enetc_init_port_rss_memory
      
      which zero-initializes the entire port RSS table in order to avoid ECC errors.
      
      The trouble really is that enetc_init_port_rss_memory really neads
      enetc_alloc_si_resources to be called, because it depends upon
      enetc_alloc_cbdr and enetc_setup_cbdr. But that whole enetc_configure_si
      thing could have been better thought out, it has nothing to do in a
      function called "alloc_si_resources", especially since its counterpart,
      "free_si_resources", does nothing to unwind the configuration of the SI.
      
      The point is, we need to pull out enetc_configure_si out of
      enetc_alloc_resources, and move it after enetc_init_port_rss_memory.
      This allows us to set up the default RSS indirection table after
      initializing the memory.
      
      Fixes: 07bf34a5 ("net: enetc: initialize the RFS and RSS memories")
      Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c646d10d
    • Y
      inetpeer: use div64_ul() and clamp_val() calculate inet_peer_threshold · 8bd2a055
      Yejune Deng 提交于
      In inet_initpeers(), struct inet_peer on IA32 uses 128 bytes in nowdays.
      Get rid of the cascade and use div64_ul() and clamp_val() calculate that
      will not need to be adjusted in the future as suggested by Eric Dumazet.
      Suggested-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NYejune Deng <yejune.deng@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8bd2a055
    • P
      net/qrtr: fix __netdev_alloc_skb call · 093b036a
      Pavel Skripkin 提交于
      syzbot found WARNING in __alloc_pages_nodemask()[1] when order >= MAX_ORDER.
      It was caused by a huge length value passed from userspace to qrtr_tun_write_iter(),
      which tries to allocate skb. Since the value comes from the untrusted source
      there is no need to raise a warning in __alloc_pages_nodemask().
      
      [1] WARNING in __alloc_pages_nodemask+0x5f8/0x730 mm/page_alloc.c:5014
      Call Trace:
       __alloc_pages include/linux/gfp.h:511 [inline]
       __alloc_pages_node include/linux/gfp.h:524 [inline]
       alloc_pages_node include/linux/gfp.h:538 [inline]
       kmalloc_large_node+0x60/0x110 mm/slub.c:3999
       __kmalloc_node_track_caller+0x319/0x3f0 mm/slub.c:4496
       __kmalloc_reserve net/core/skbuff.c:150 [inline]
       __alloc_skb+0x4e4/0x5a0 net/core/skbuff.c:210
       __netdev_alloc_skb+0x70/0x400 net/core/skbuff.c:446
       netdev_alloc_skb include/linux/skbuff.h:2832 [inline]
       qrtr_endpoint_post+0x84/0x11b0 net/qrtr/qrtr.c:442
       qrtr_tun_write_iter+0x11f/0x1a0 net/qrtr/tun.c:98
       call_write_iter include/linux/fs.h:1901 [inline]
       new_sync_write+0x426/0x650 fs/read_write.c:518
       vfs_write+0x791/0xa30 fs/read_write.c:605
       ksys_write+0x12d/0x250 fs/read_write.c:658
       do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Reported-by: syzbot+80dccaee7c6630fa9dcf@syzkaller.appspotmail.com
      Signed-off-by: NPavel Skripkin <paskripkin@gmail.com>
      Acked-by: NAlexander Lobakin <alobakin@pm.me>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      093b036a
    • D
      Merge branch 'sh_eth-masks' · 5db4f74e
      David S. Miller 提交于
      Sergey Shtylyov says:
      
      ====================
      Fix TRSCER masks in the Ether driver
      
      Here are 3 patches against DaveM's 'net' repo. I'm fixing the TRSCER masks in
      the driver to match the manuals...
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5db4f74e
    • S
      sh_eth: fix TRSCER mask for R7S9210 · 165bc5a4
      Sergey Shtylyov 提交于
      According  to the RZ/A2M Group User's Manual: Hardware, Rev. 2.00,
      the TRSCER register has bit 9 reserved, hence we can't use the driver's
      default TRSCER mask.  Add the explicit initializer for sh_eth_cpu_data::
      trscer_err_mask for R7S9210.
      
      Fixes: 6e0bb04d ("sh_eth: Add R7S9210 support")
      Signed-off-by: NSergey Shtylyov <s.shtylyov@omprussia.ru>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      165bc5a4
    • S
      sh_eth: fix TRSCER mask for R7S72100 · 75be7fb7
      Sergey Shtylyov 提交于
      According  to  the RZ/A1H Group, RZ/A1M Group User's Manual: Hardware,
      Rev. 4.00, the TRSCER register has bit 9 reserved, hence we can't use
      the driver's default TRSCER mask.  Add the explicit initializer for
      sh_eth_cpu_data::trscer_err_mask for R7S72100.
      
      Fixes: db893473 ("sh_eth: Add support for r7s72100")
      Signed-off-by: NSergey Shtylyov <s.shtylyov@omprussia.ru>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      75be7fb7
    • S
      sh_eth: fix TRSCER mask for SH771x · 8c91bc3d
      Sergey Shtylyov 提交于
      According  to  the SH7710, SH7712, SH7713 Group User's Manual: Hardware,
      Rev. 3.00, the TRSCER register actually has only bit 7 valid (and named
      differently), with all the other bits reserved. Apparently, this was not
      the case with some early revisions of the manual as we have the other
      bits declared (and set) in the original driver.  Follow the suit and add
      the explicit sh_eth_cpu_data::trscer_err_mask initializer for SH771x...
      
      Fixes: 86a74ff2 ("net: sh_eth: add support for Renesas SuperH Ethernet")
      Signed-off-by: NSergey Shtylyov <s.shtylyov@omprussia.ru>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8c91bc3d
    • T
      atm: lanai: dont run lanai_dev_close if not open · a2bd4583
      Tong Zhang 提交于
      lanai_dev_open() can fail. When it fail, lanai->base is unmapped and the
      pci device is disabled. The caller, lanai_init_one(), then tries to run
      atm_dev_deregister(). This will subsequently call lanai_dev_close() and
      use the already released MMIO area.
      
      To fix this issue, set the lanai->base to NULL if open fail,
      and test the flag in lanai_dev_close().
      
      [    8.324153] lanai: lanai_start() failed, err=19
      [    8.324819] lanai(itf 0): shutting down interface
      [    8.325211] BUG: unable to handle page fault for address: ffffc90000180024
      [    8.325781] #PF: supervisor write access in kernel mode
      [    8.326215] #PF: error_code(0x0002) - not-present page
      [    8.326641] PGD 100000067 P4D 100000067 PUD 100139067 PMD 10013a067 PTE 0
      [    8.327206] Oops: 0002 [#1] SMP KASAN NOPTI
      [    8.327557] CPU: 0 PID: 95 Comm: modprobe Not tainted 5.11.0-rc7-00090-gdcc0b490 #12
      [    8.328229] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-48-gd9c812dda519-4
      [    8.329145] RIP: 0010:lanai_dev_close+0x4f/0xe5 [lanai]
      [    8.329587] Code: 00 48 c7 c7 00 d3 01 c0 e8 49 4e 0a c2 48 8d bd 08 02 00 00 e8 6e 52 14 c1 48 80
      [    8.330917] RSP: 0018:ffff8881029ef680 EFLAGS: 00010246
      [    8.331196] RAX: 000000000003fffe RBX: ffff888102fb4800 RCX: ffffffffc001a98a
      [    8.331572] RDX: ffffc90000180000 RSI: 0000000000000246 RDI: ffff888102fb4000
      [    8.331948] RBP: ffff888102fb4000 R08: ffffffff8115da8a R09: ffffed102053deaa
      [    8.332326] R10: 0000000000000003 R11: ffffed102053dea9 R12: ffff888102fb48a4
      [    8.332701] R13: ffffffffc00123c0 R14: ffff888102fb4b90 R15: ffff888102fb4b88
      [    8.333077] FS:  00007f08eb9056a0(0000) GS:ffff88815b400000(0000) knlGS:0000000000000000
      [    8.333502] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    8.333806] CR2: ffffc90000180024 CR3: 0000000102a28000 CR4: 00000000000006f0
      [    8.334182] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    8.334557] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    8.334932] Call Trace:
      [    8.335066]  atm_dev_deregister+0x161/0x1a0 [atm]
      [    8.335324]  lanai_init_one.cold+0x20c/0x96d [lanai]
      [    8.335594]  ? lanai_send+0x2a0/0x2a0 [lanai]
      [    8.335831]  local_pci_probe+0x6f/0xb0
      [    8.336039]  pci_device_probe+0x171/0x240
      [    8.336255]  ? pci_device_remove+0xe0/0xe0
      [    8.336475]  ? kernfs_create_link+0xb6/0x110
      [    8.336704]  ? sysfs_do_create_link_sd.isra.0+0x76/0xe0
      [    8.336983]  really_probe+0x161/0x420
      [    8.337181]  driver_probe_device+0x6d/0xd0
      [    8.337401]  device_driver_attach+0x82/0x90
      [    8.337626]  ? device_driver_attach+0x90/0x90
      [    8.337859]  __driver_attach+0x60/0x100
      [    8.338065]  ? device_driver_attach+0x90/0x90
      [    8.338298]  bus_for_each_dev+0xe1/0x140
      [    8.338511]  ? subsys_dev_iter_exit+0x10/0x10
      [    8.338745]  ? klist_node_init+0x61/0x80
      [    8.338956]  bus_add_driver+0x254/0x2a0
      [    8.339164]  driver_register+0xd3/0x150
      [    8.339370]  ? 0xffffffffc0028000
      [    8.339550]  do_one_initcall+0x84/0x250
      [    8.339755]  ? trace_event_raw_event_initcall_finish+0x150/0x150
      [    8.340076]  ? free_vmap_area_noflush+0x1a5/0x5c0
      [    8.340329]  ? unpoison_range+0xf/0x30
      [    8.340532]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    8.340806]  ? unpoison_range+0xf/0x30
      [    8.341014]  ? unpoison_range+0xf/0x30
      [    8.341217]  do_init_module+0xf8/0x350
      [    8.341419]  load_module+0x3fe6/0x4340
      [    8.341621]  ? vm_unmap_ram+0x1d0/0x1d0
      [    8.341826]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    8.342101]  ? module_frob_arch_sections+0x20/0x20
      [    8.342358]  ? __do_sys_finit_module+0x108/0x170
      [    8.342604]  __do_sys_finit_module+0x108/0x170
      [    8.342841]  ? __ia32_sys_init_module+0x40/0x40
      [    8.343083]  ? file_open_root+0x200/0x200
      [    8.343298]  ? do_sys_open+0x85/0xe0
      [    8.343491]  ? filp_open+0x50/0x50
      [    8.343675]  ? exit_to_user_mode_prepare+0xfc/0x130
      [    8.343935]  do_syscall_64+0x33/0x40
      [    8.344132]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [    8.344401] RIP: 0033:0x7f08eb887cf7
      [    8.344594] Code: 48 89 57 30 48 8b 04 24 48 89 47 38 e9 1d a0 02 00 48 89 f8 48 89 f7 48 89 d6 41
      [    8.345565] RSP: 002b:00007ffcd5c98ad8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [    8.345962] RAX: ffffffffffffffda RBX: 00000000008fea70 RCX: 00007f08eb887cf7
      [    8.346336] RDX: 0000000000000000 RSI: 00000000008fd9e0 RDI: 0000000000000003
      [    8.346711] RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000001
      [    8.347085] R10: 00007f08eb8eb300 R11: 0000000000000246 R12: 00000000008fd9e0
      [    8.347460] R13: 0000000000000000 R14: 00000000008fddd0 R15: 0000000000000001
      [    8.347836] Modules linked in: lanai(+) atm
      [    8.348065] CR2: ffffc90000180024
      [    8.348244] ---[ end trace 7fdc1c668f2003e5 ]---
      [    8.348490] RIP: 0010:lanai_dev_close+0x4f/0xe5 [lanai]
      [    8.348772] Code: 00 48 c7 c7 00 d3 01 c0 e8 49 4e 0a c2 48 8d bd 08 02 00 00 e8 6e 52 14 c1 48 80
      [    8.349745] RSP: 0018:ffff8881029ef680 EFLAGS: 00010246
      [    8.350022] RAX: 000000000003fffe RBX: ffff888102fb4800 RCX: ffffffffc001a98a
      [    8.350397] RDX: ffffc90000180000 RSI: 0000000000000246 RDI: ffff888102fb4000
      [    8.350772] RBP: ffff888102fb4000 R08: ffffffff8115da8a R09: ffffed102053deaa
      [    8.351151] R10: 0000000000000003 R11: ffffed102053dea9 R12: ffff888102fb48a4
      [    8.351525] R13: ffffffffc00123c0 R14: ffff888102fb4b90 R15: ffff888102fb4b88
      [    8.351918] FS:  00007f08eb9056a0(0000) GS:ffff88815b400000(0000) knlGS:0000000000000000
      [    8.352343] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    8.352647] CR2: ffffc90000180024 CR3: 0000000102a28000 CR4: 00000000000006f0
      [    8.353022] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    8.353397] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    8.353958] modprobe (95) used greatest stack depth: 26216 bytes left
      Signed-off-by: NTong Zhang <ztong0001@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a2bd4583
    • T
      atm: eni: dont release is never initialized · 4deb550b
      Tong Zhang 提交于
      label err_eni_release is reachable when eni_start() fail.
      In eni_start() it calls dev->phy->start() in the last step, if start()
      fail we don't need to call phy->stop(), if start() is never called, we
      neither need to call phy->stop(), otherwise null-ptr-deref will happen.
      
      In order to fix this issue, don't call phy->stop() in label err_eni_release
      
      [    4.875714] ==================================================================
      [    4.876091] BUG: KASAN: null-ptr-deref in suni_stop+0x47/0x100 [suni]
      [    4.876433] Read of size 8 at addr 0000000000000030 by task modprobe/95
      [    4.876778]
      [    4.876862] CPU: 0 PID: 95 Comm: modprobe Not tainted 5.11.0-rc7-00090-gdcc0b490 #2
      [    4.877290] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-48-gd94
      [    4.877876] Call Trace:
      [    4.878009]  dump_stack+0x7d/0xa3
      [    4.878191]  kasan_report.cold+0x10c/0x10e
      [    4.878410]  ? __slab_free+0x2f0/0x340
      [    4.878612]  ? suni_stop+0x47/0x100 [suni]
      [    4.878832]  suni_stop+0x47/0x100 [suni]
      [    4.879043]  eni_do_release+0x3b/0x70 [eni]
      [    4.879269]  eni_init_one.cold+0x1152/0x1747 [eni]
      [    4.879528]  ? _raw_spin_lock_irqsave+0x7b/0xd0
      [    4.879768]  ? eni_ioctl+0x270/0x270 [eni]
      [    4.879990]  ? __mutex_lock_slowpath+0x10/0x10
      [    4.880226]  ? eni_ioctl+0x270/0x270 [eni]
      [    4.880448]  local_pci_probe+0x6f/0xb0
      [    4.880650]  pci_device_probe+0x171/0x240
      [    4.880864]  ? pci_device_remove+0xe0/0xe0
      [    4.881086]  ? kernfs_create_link+0xb6/0x110
      [    4.881315]  ? sysfs_do_create_link_sd.isra.0+0x76/0xe0
      [    4.881594]  really_probe+0x161/0x420
      [    4.881791]  driver_probe_device+0x6d/0xd0
      [    4.882010]  device_driver_attach+0x82/0x90
      [    4.882233]  ? device_driver_attach+0x90/0x90
      [    4.882465]  __driver_attach+0x60/0x100
      [    4.882671]  ? device_driver_attach+0x90/0x90
      [    4.882903]  bus_for_each_dev+0xe1/0x140
      [    4.883114]  ? subsys_dev_iter_exit+0x10/0x10
      [    4.883346]  ? klist_node_init+0x61/0x80
      [    4.883557]  bus_add_driver+0x254/0x2a0
      [    4.883764]  driver_register+0xd3/0x150
      [    4.883971]  ? 0xffffffffc0038000
      [    4.884149]  do_one_initcall+0x84/0x250
      [    4.884355]  ? trace_event_raw_event_initcall_finish+0x150/0x150
      [    4.884674]  ? unpoison_range+0xf/0x30
      [    4.884875]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    4.885150]  ? unpoison_range+0xf/0x30
      [    4.885352]  ? unpoison_range+0xf/0x30
      [    4.885557]  do_init_module+0xf8/0x350
      [    4.885760]  load_module+0x3fe6/0x4340
      [    4.885960]  ? vm_unmap_ram+0x1d0/0x1d0
      [    4.886166]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    4.886441]  ? module_frob_arch_sections+0x20/0x20
      [    4.886697]  ? __do_sys_finit_module+0x108/0x170
      [    4.886941]  __do_sys_finit_module+0x108/0x170
      [    4.887178]  ? __ia32_sys_init_module+0x40/0x40
      [    4.887419]  ? file_open_root+0x200/0x200
      [    4.887634]  ? do_sys_open+0x85/0xe0
      [    4.887826]  ? filp_open+0x50/0x50
      [    4.888009]  ? fpregs_assert_state_consistent+0x4d/0x60
      [    4.888287]  ? exit_to_user_mode_prepare+0x2f/0x130
      [    4.888547]  do_syscall_64+0x33/0x40
      [    4.888739]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [    4.889010] RIP: 0033:0x7ff62fcf1cf7
      [    4.889202] Code: 48 89 57 30 48 8b 04 24 48 89 47 38 e9 1d a0 02 00 48 89 f8 48 89 f71
      [    4.890172] RSP: 002b:00007ffe6644ade8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [    4.890570] RAX: ffffffffffffffda RBX: 0000000000f2ca70 RCX: 00007ff62fcf1cf7
      [    4.890944] RDX: 0000000000000000 RSI: 0000000000f2b9e0 RDI: 0000000000000003
      [    4.891318] RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000001
      [    4.891691] R10: 00007ff62fd55300 R11: 0000000000000246 R12: 0000000000f2b9e0
      [    4.892064] R13: 0000000000000000 R14: 0000000000f2bdd0 R15: 0000000000000001
      [    4.892439] ==================================================================
      Signed-off-by: NTong Zhang <ztong0001@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4deb550b
    • G
      net: phy: fix save wrong speed and duplex problem if autoneg is on · d9032dba
      Guangbin Huang 提交于
      If phy uses generic driver and autoneg is on, enter command
      "ethtool -s eth0 speed 50" will not change phy speed actually, but
      command "ethtool eth0" shows speed is 50Mb/s because phydev->speed
      has been set to 50 and no update later.
      
      And duplex setting has same problem too.
      
      However, if autoneg is on, phy only changes speed and duplex according to
      phydev->advertising, but not phydev->speed and phydev->duplex. So in this
      case, phydev->speed and phydev->duplex don't need to be set in function
      phy_ethtool_ksettings_set() if autoneg is on.
      
      Fixes: 51e2a384 ("PHY: Avoid unnecessary aneg restarts")
      Signed-off-by: NGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d9032dba
    • J
      net: always use icmp{,v6}_ndo_send from ndo_start_xmit · 4372339e
      Jason A. Donenfeld 提交于
      There were a few remaining tunnel drivers that didn't receive the prior
      conversion to icmp{,v6}_ndo_send. Knowing now that this could lead to
      memory corrution (see ee576c47 ("net: icmp: pass zeroed opts from
      icmp{,v6}_ndo_send before sending") for details), there's even more
      imperative to have these all converted. So this commit goes through the
      remaining cases that I could find and does a boring translation to the
      ndo variety.
      
      The Fixes: line below is the merge that originally added icmp{,v6}_
      ndo_send and converted the first batch of icmp{,v6}_send users. The
      rationale then for the change applies equally to this patch. It's just
      that these drivers were left out of the initial conversion because these
      network devices are hiding in net/ rather than in drivers/net/.
      
      Cc: Florian Westphal <fw@strlen.de>
      Cc: Willem de Bruijn <willemb@google.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      Cc: David Ahern <dsahern@kernel.org>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Steffen Klassert <steffen.klassert@secunet.com>
      Fixes: 803381f9 ("Merge branch 'icmp-account-for-NAT-when-sending-icmps-from-ndo-layer'")
      Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
      Acked-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4372339e
    • D
      net: dsa: tag_rtl4_a: fix egress tags · 9eb8bc59
      DENG Qingfang 提交于
      Commit 86dd9868 has several issues, but was accepted too soon
      before anyone could take a look.
      
      - Double free. dsa_slave_xmit() will free the skb if the xmit function
        returns NULL, but the skb is already freed by eth_skb_pad(). Use
        __skb_put_padto() to avoid that.
      - Unnecessary allocation. It has been done by DSA core since commit
        a3b0b647.
      - A u16 pointer points to skb data. It should be __be16 for network
        byte order.
      - Typo in comments. "numer" -> "number".
      
      Fixes: 86dd9868 ("net: dsa: tag_rtl4_a: Support also egress tags")
      Signed-off-by: NDENG Qingfang <dqfext@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9eb8bc59
    • J
      xen-netback: use local var in xenvif_tx_check_gop() instead of re-calculating · 826d8217
      Jan Beulich 提交于
      shinfo already holds the result of skb_shinfo(skb) at this point - no
      need to re-invoke the construct even twice.
      Signed-off-by: NJan Beulich <jbeulich@suse.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      826d8217
    • I
      net: phy: ti: take into account all possible interrupt sources · 73f476aa
      Ioana Ciornei 提交于
      The previous implementation of .handle_interrupt() did not take into
      account the fact that all the interrupt status registers should be
      acknowledged since multiple interrupt sources could be asserted.
      
      Fix this by reading all the status registers before exiting with
      IRQ_NONE or triggering the PHY state machine.
      
      Fixes: 1d1ae3c6 ("net: phy: ti: implement generic .handle_interrupt() callback")
      Reported-by: NSven Schuchmann <schuchmann@schleissheimer.de>
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Link: https://lore.kernel.org/r/20210226153020.867852-1-ciorneiioana@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      73f476aa
  2. 01 3月, 2021 7 次提交
    • J
      Merge branch 'net-hns3-fixes-fot-net' · 447621e3
      Jakub Kicinski 提交于
      Huazhong Tan says:
      
      ====================
      net: hns3: fixes fot -net
      
      The patchset includes some fixes for the HNS3 ethernet driver.
      ====================
      
      Link: https://lore.kernel.org/r/1614410693-8107-1-git-send-email-tanhuazhong@huawei.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      447621e3
    • J
      net: hns3: fix bug when calculating the TCAM table info · b36fc875
      Jian Shen 提交于
      The function hclge_fd_convert_tuple() is used to convert tuples
      and tuples mask to TCAM x and y.  But it misuses the source mac
      as source mac mask when convert INNER_SRC_MAC, which may cause
      the flow director rule works unexpectedly. So fix it.
      
      Fixes: 11732868 ("net: hns3: Add input key and action config support for flow director")
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      b36fc875
    • J
      net: hns3: fix query vlan mask value error for flow director · c75ec148
      Jian Shen 提交于
      Currently, the driver returns VLAN_VID_MASK for vlan mask field,
      when get flow director rule information for rule doesn't use vlan.
      It may cause the vlan mask value display as 0xf000 in this
      case, like below:
      
      estuary:/$ ethtool -u eth1
      50 RX rings available
      Total 1 rules
      
      Filter: 2
      Rule Type: TCP over IPv4
      Src IP addr: 0.0.0.0 mask: 255.255.255.255
      Dest IP addr: 0.0.0.0 mask: 255.255.255.255
      TOS: 0x0 mask: 0xff
      Src port: 0 mask: 0xffff
      Dest port: 0 mask: 0xffff
      VLAN EtherType: 0x0 mask: 0xffff
      VLAN: 0x0 mask: 0xf000
      User-defined: 0x1234 mask: 0x0
      Action: Direct to queue 3
      
      Fix it by return 0.
      
      Fixes: 05c2314f ("net: hns3: Add support for rule query of flow director")
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      c75ec148
    • J
      net: hns3: fix error mask definition of flow director · ae85ddda
      Jian Shen 提交于
      Currently, some bit filed definitions of flow director TCAM
      configuration command are incorrect. Since the wrong MSB is
      always 0, and these fields are assgined in order, so it still works.
      
      Fix it by redefine them.
      
      Fixes: 11732868 ("net: hns3: Add input key and action config support for flow director")
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      ae85ddda
    • D
      net: Fix gro aggregation for udp encaps with zero csum · 89e5c58f
      Daniel Borkmann 提交于
      We noticed a GRO issue for UDP-based encaps such as vxlan/geneve when the
      csum for the UDP header itself is 0. In that case, GRO aggregation does
      not take place on the phys dev, but instead is deferred to the vxlan/geneve
      driver (see trace below).
      
      The reason is essentially that GRO aggregation bails out in udp_gro_receive()
      for such case when drivers marked the skb with CHECKSUM_UNNECESSARY (ice, i40e,
      others) where for non-zero csums 2abb7cdc ("udp: Add support for doing
      checksum unnecessary conversion") promotes those skbs to CHECKSUM_COMPLETE
      and napi context has csum_valid set. This is however not the case for zero
      UDP csum (here: csum_cnt is still 0 and csum_valid continues to be false).
      
      At the same time 57c67ff4 ("udp: additional GRO support") added matches
      on !uh->check ^ !uh2->check as part to determine candidates for aggregation,
      so it certainly is expected to handle zero csums in udp_gro_receive(). The
      purpose of the check added via 662880f4 ("net: Allow GRO to use and set
      levels of checksum unnecessary") seems to catch bad csum and stop aggregation
      right away.
      
      One way to fix aggregation in the zero case is to only perform the !csum_valid
      check in udp_gro_receive() if uh->check is infact non-zero.
      
      Before:
      
        [...]
        swapper     0 [008]   731.946506: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100400 len=1500   (1)
        swapper     0 [008]   731.946507: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100200 len=1500
        swapper     0 [008]   731.946507: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101100 len=1500
        swapper     0 [008]   731.946508: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101700 len=1500
        swapper     0 [008]   731.946508: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101b00 len=1500
        swapper     0 [008]   731.946508: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100600 len=1500
        swapper     0 [008]   731.946508: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100f00 len=1500
        swapper     0 [008]   731.946509: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100a00 len=1500
        swapper     0 [008]   731.946516: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100500 len=1500
        swapper     0 [008]   731.946516: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100700 len=1500
        swapper     0 [008]   731.946516: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101d00 len=1500   (2)
        swapper     0 [008]   731.946517: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101000 len=1500
        swapper     0 [008]   731.946517: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101c00 len=1500
        swapper     0 [008]   731.946517: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101400 len=1500
        swapper     0 [008]   731.946518: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100e00 len=1500
        swapper     0 [008]   731.946518: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497101600 len=1500
        swapper     0 [008]   731.946521: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff966497100800 len=774
        swapper     0 [008]   731.946530: net:netif_receive_skb: dev=test_vxlan skbaddr=0xffff966497100400 len=14032 (1)
        swapper     0 [008]   731.946530: net:netif_receive_skb: dev=test_vxlan skbaddr=0xffff966497101d00 len=9112  (2)
        [...]
      
        # netperf -H 10.55.10.4 -t TCP_STREAM -l 20
        MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.55.10.4 () port 0 AF_INET : demo
        Recv   Send    Send
        Socket Socket  Message  Elapsed
        Size   Size    Size     Time     Throughput
        bytes  bytes   bytes    secs.    10^6bits/sec
      
         87380  16384  16384    20.01    13129.24
      
      After:
      
        [...]
        swapper     0 [026]   521.862641: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff93ab0d479000 len=11286 (1)
        swapper     0 [026]   521.862643: net:netif_receive_skb: dev=test_vxlan skbaddr=0xffff93ab0d479000 len=11236 (1)
        swapper     0 [026]   521.862650: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff93ab0d478500 len=2898  (2)
        swapper     0 [026]   521.862650: net:netif_receive_skb: dev=enp10s0f0  skbaddr=0xffff93ab0d479f00 len=8490  (3)
        swapper     0 [026]   521.862653: net:netif_receive_skb: dev=test_vxlan skbaddr=0xffff93ab0d478500 len=2848  (2)
        swapper     0 [026]   521.862653: net:netif_receive_skb: dev=test_vxlan skbaddr=0xffff93ab0d479f00 len=8440  (3)
        [...]
      
        # netperf -H 10.55.10.4 -t TCP_STREAM -l 20
        MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.55.10.4 () port 0 AF_INET : demo
        Recv   Send    Send
        Socket Socket  Message  Elapsed
        Size   Size    Size     Time     Throughput
        bytes  bytes   bytes    secs.    10^6bits/sec
      
         87380  16384  16384    20.01    24576.53
      
      Fixes: 57c67ff4 ("udp: additional GRO support")
      Fixes: 662880f4 ("net: Allow GRO to use and set levels of checksum unnecessary")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
      Cc: Tom Herbert <tom@herbertland.com>
      Acked-by: NWillem de Bruijn <willemb@google.com>
      Acked-by: NJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/r/20210226212248.8300-1-daniel@iogearbox.netSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      89e5c58f
    • R
      net: broadcom: bcm4908_enet: enable RX after processing packets · d313d16b
      Rafał Miłecki 提交于
      When receiving a lot of packets hardware may run out of free
      descriptiors and stop RX ring. Enable it every time after handling
      received packets.
      
      Fixes: 4feffead ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
      Signed-off-by: NRafał Miłecki <rafal@milecki.pl>
      Acked-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20210226132038.29849-1-zajec5@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      d313d16b
    • Y
      ethtool: fix the check logic of at least one channel for RX/TX · a4fc088a
      Yinjun Zhang 提交于
      The command "ethtool -L <intf> combined 0" may clean the RX/TX channel
      count and skip the error path, since the attrs
      tb[ETHTOOL_A_CHANNELS_RX_COUNT] and tb[ETHTOOL_A_CHANNELS_TX_COUNT]
      are NULL in this case when recent ethtool is used.
      
      Tested using ethtool v5.10.
      
      Fixes: 7be92514 ("ethtool: check if there is at least one channel for TX/RX in the core")
      Signed-off-by: NYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: NSimon Horman <simon.horman@netronome.com>
      Signed-off-by: NLouis Peens <louis.peens@netronome.com>
      Link: https://lore.kernel.org/r/20210225125102.23989-1-simon.horman@netronome.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      a4fc088a
  3. 27 2月, 2021 13 次提交