1. 06 11月, 2018 3 次提交
    • A
      ipv6: properly check return value in inet6_dump_all() · e22d0bfa
      Alexey Kodanev 提交于
      Make sure we call fib6_dump_end() if it happens that skb->len
      is zero. rtnl_dump_all() can reset cb->args on the next loop
      iteration there.
      
      Fixes: 08e814c9 ("net/ipv6: Bail early if user only wants cloned entries")
      Fixes: ae677bbb ("net: Don't return invalid table id error when dumping all families")
      Signed-off-by: NAlexey Kodanev <alexey.kodanev@oracle.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e22d0bfa
    • A
      rtnetlink: restore handling of dumpit return value in rtnl_dump_all() · 5e1acb4a
      Alexey Kodanev 提交于
      For non-zero return from dumpit() we should break the loop
      in rtnl_dump_all() and return the result. Otherwise, e.g.,
      we could get the memory leak in inet6_dump_fib() [1]. The
      pointer to the allocated struct fib6_walker there (saved
      in cb->args) can be lost, reset on the next iteration.
      
      Fix it by partially restoring the previous behavior before
      commit c63586dc ("net: rtnl_dump_all needs to propagate
      error from dumpit function"). The returned error from
      dumpit() is still passed further.
      
      [1]:
      unreferenced object 0xffff88001322a200 (size 96):
        comm "sshd", pid 1484, jiffies 4296032768 (age 1432.542s)
        hex dump (first 32 bytes):
          00 01 00 00 00 00 ad de 00 02 00 00 00 00 ad de  ................
          18 09 41 36 00 88 ff ff 18 09 41 36 00 88 ff ff  ..A6......A6....
        backtrace:
          [<0000000095846b39>] kmem_cache_alloc_trace+0x151/0x220
          [<000000007d12709f>] inet6_dump_fib+0x68d/0x940
          [<000000002775a316>] rtnl_dump_all+0x1d9/0x2d0
          [<00000000d7cd302b>] netlink_dump+0x945/0x11a0
          [<000000002f43485f>] __netlink_dump_start+0x55d/0x800
          [<00000000f76bbeec>] rtnetlink_rcv_msg+0x4fa/0xa00
          [<000000009b5761f3>] netlink_rcv_skb+0x29c/0x420
          [<0000000087a1dae1>] rtnetlink_rcv+0x15/0x20
          [<00000000691b703b>] netlink_unicast+0x4e3/0x6c0
          [<00000000b5be0204>] netlink_sendmsg+0x7f2/0xba0
          [<0000000096d2aa60>] sock_sendmsg+0xba/0xf0
          [<000000008c1b786f>] __sys_sendto+0x1e4/0x330
          [<0000000019587b3f>] __x64_sys_sendto+0xe1/0x1a0
          [<00000000071f4d56>] do_syscall_64+0x9f/0x300
          [<000000002737577f>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
          [<0000000057587684>] 0xffffffffffffffff
      
      Fixes: c63586dc ("net: rtnl_dump_all needs to propagate error from dumpit function")
      Signed-off-by: NAlexey Kodanev <alexey.kodanev@oracle.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5e1acb4a
    • J
      net/ipv6: Move anycast init/cleanup functions out of CONFIG_PROC_FS · 6915ed86
      Jeff Barnhill 提交于
      Move the anycast.c init and cleanup functions which were inadvertently
      added inside the CONFIG_PROC_FS definition.
      
      Fixes: 2384d025 ("net/ipv6: Add anycast addresses to a global hashtable")
      Signed-off-by: NJeff Barnhill <0xeffeff@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6915ed86
  2. 05 11月, 2018 2 次提交
    • J
      bonding/802.3ad: fix link_failure_count tracking · ea53abfa
      Jarod Wilson 提交于
      Commit 4d2c0cda set slave->link to
      BOND_LINK_DOWN for 802.3ad bonds whenever invalid speed/duplex values
      were read, to fix a problem with slaves getting into weird states, but
      in the process, broke tracking of link failures, as going straight to
      BOND_LINK_DOWN when a link is indeed down (cable pulled, switch rebooted)
      means we broke out of bond_miimon_inspect()'s BOND_LINK_DOWN case because
      !link_state was already true, we never incremented commit, and never got
      a chance to call bond_miimon_commit(), where slave->link_failure_count
      would be incremented. I believe the simple fix here is to mark the slave
      as BOND_LINK_FAIL, and let bond_miimon_inspect() transition the link from
      _FAIL to either _UP or _DOWN, and in the latter case, we now get proper
      incrementing of link_failure_count again.
      
      Fixes: 4d2c0cda ("bonding: speed/duplex update at NETDEV_UP event")
      CC: Mahesh Bandewar <maheshb@google.com>
      CC: David S. Miller <davem@davemloft.net>
      CC: netdev@vger.kernel.org
      CC: stable@vger.kernel.org
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ea53abfa
    • H
      net: phy: realtek: fix RTL8201F sysfs name · 0432e833
      Holger Hoffstätte 提交于
      Since 4.19 the following error in sysfs has appeared when using the
      r8169 NIC driver:
      
      $cd /sys/module/realtek/drivers
      $ls -l
      ls: cannot access 'mdio_bus:RTL8201F 10/100Mbps Ethernet': No such file or directory
      [..garbled dir entries follow..]
      
      Apparently the forward slash in "10/100Mbps Ethernet" is interpreted
      as directory separator that leads nowhere, and was introduced in commit
      513588dd ("net: phy: realtek: add RTL8201F phy-id and functions").
      
      Fix this by removing the offending slash in the driver name.
      
      Other drivers in net/phy seem to have the same problem, but I cannot
      test/verify them.
      
      Fixes: 513588dd ("net: phy: realtek: add RTL8201F phy-id and functions")
      Signed-off-by: NHolger Hoffstätte <holger@applied-asynchrony.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0432e833
  3. 04 11月, 2018 18 次提交
    • X
      sctp: define SCTP_SS_DEFAULT for Stream schedulers · 12480e3b
      Xin Long 提交于
      According to rfc8260#section-4.3.2, SCTP_SS_DEFAULT is required to
      defined as SCTP_SS_FCFS or SCTP_SS_RR.
      
      SCTP_SS_FCFS is used for SCTP_SS_DEFAULT's value in this patch.
      
      Fixes: 5bbbbe32 ("sctp: introduce stream scheduler foundations")
      Reported-by: NJianwen Ji <jiji@redhat.com>
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      12480e3b
    • X
      sctp: fix strchange_flags name for Stream Change Event · fd82d61b
      Xin Long 提交于
      As defined in rfc6525#section-6.1.3, SCTP_STREAM_CHANGE_DENIED
      and SCTP_STREAM_CHANGE_FAILED should be used instead of
      SCTP_ASSOC_CHANGE_DENIED and SCTP_ASSOC_CHANGE_FAILED.
      
      To keep the compatibility, fix it by adding two macros.
      
      Fixes: b444153f ("sctp: add support for generating add stream change event notification")
      Reported-by: NJianwen Ji <jiji@redhat.com>
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fd82d61b
    • D
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · 1e2d3c49
      David S. Miller 提交于
      Daniel Borkmann says:
      
      ====================
      pull-request: bpf 2018-11-03
      
      The following pull-request contains BPF updates for your *net* tree.
      
      The main changes are:
      
      1) Fix BPF prog kallsyms and bpf_prog_get_info_by_fd() jited address export
         to not use page start but actual start instead to work correctly with
         profiling e.g. finding hot instructions from stack traces. Also fix latter
         with regards to dumping address and jited len for !multi prog, from Song.
      
      2) Fix bpf_prog_get_info_by_fd() for !root to zero info.nr_jited_func_lens
         instead of leaving the user provided length, from Daniel.
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1e2d3c49
    • S
      mlxsw: spectrum: Fix IP2ME CPU policer configuration · 96801552
      Shalom Toledo 提交于
      The CPU policer used to police packets being trapped via a local route
      (IP2ME) was incorrectly configured to police based on bytes per second
      instead of packets per second.
      
      Change the policer to police based on packets per second and avoid
      packet loss under certain circumstances.
      
      Fixes: 9148e7cf ("mlxsw: spectrum: Add policers for trap groups")
      Signed-off-by: NShalom Toledo <shalomt@mellanox.com>
      Signed-off-by: NIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      96801552
    • A
      openvswitch: fix linking without CONFIG_NF_CONNTRACK_LABELS · a277d516
      Arnd Bergmann 提交于
      When CONFIG_CC_OPTIMIZE_FOR_DEBUGGING is enabled, the compiler
      fails to optimize out a dead code path, which leads to a link failure:
      
      net/openvswitch/conntrack.o: In function `ovs_ct_set_labels':
      conntrack.c:(.text+0x2e60): undefined reference to `nf_connlabels_replace'
      
      In this configuration, we can take a shortcut, and completely
      remove the contrack label code. This may also help the regular
      optimization.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a277d516
    • A
      qed: fix link config error handling · 92619210
      Arnd Bergmann 提交于
      gcc-8 notices that qed_mcp_get_transceiver_data() may fail to
      return a result to the caller:
      
      drivers/net/ethernet/qlogic/qed/qed_mcp.c: In function 'qed_mcp_trans_speed_mask':
      drivers/net/ethernet/qlogic/qed/qed_mcp.c:1955:2: error: 'transceiver_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      When an error is returned by qed_mcp_get_transceiver_data(), we
      should propagate that to the caller of qed_mcp_trans_speed_mask()
      rather than continuing with uninitialized data.
      
      Fixes: c56a8be7 ("qed: Add supported link and advertise link to display in ethtool.")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      92619210
    • Y
      net: hns3: Fix for out-of-bounds access when setting pfc back pressure · e8ccbb7d
      Yunsheng Lin 提交于
      The vport should be initialized to hdev->vport for each bp group,
      otherwise it will cause out-of-bounds access and bp setting not
      correct problem.
      
      [   35.254124] BUG: KASAN: slab-out-of-bounds in hclge_pause_setup_hw+0x2a0/0x3f8 [hclge]
      [   35.254126] Read of size 2 at addr ffff803b6651581a by task kworker/0:1/14
      
      [   35.254132] CPU: 0 PID: 14 Comm: kworker/0:1 Not tainted 4.19.0-rc7-hulk+ #85
      [   35.254133] Hardware name: Huawei D06/D06, BIOS Hisilicon D06 UEFI RC0 - B052 (V0.52) 09/14/2018
      [   35.254141] Workqueue: events work_for_cpu_fn
      [   35.254144] Call trace:
      [   35.254147]  dump_backtrace+0x0/0x2f0
      [   35.254149]  show_stack+0x24/0x30
      [   35.254154]  dump_stack+0x110/0x184
      [   35.254157]  print_address_description+0x168/0x2b0
      [   35.254160]  kasan_report+0x184/0x310
      [   35.254162]  __asan_load2+0x7c/0xa0
      [   35.254170]  hclge_pause_setup_hw+0x2a0/0x3f8 [hclge]
      [   35.254177]  hclge_tm_init_hw+0x794/0x9f0 [hclge]
      [   35.254184]  hclge_tm_schd_init+0x48/0x58 [hclge]
      [   35.254191]  hclge_init_ae_dev+0x778/0x1168 [hclge]
      [   35.254196]  hnae3_register_ae_dev+0x14c/0x298 [hnae3]
      [   35.254206]  hns3_probe+0x88/0xa8 [hns3]
      [   35.254210]  local_pci_probe+0x7c/0xf0
      [   35.254212]  work_for_cpu_fn+0x34/0x50
      [   35.254214]  process_one_work+0x4d4/0xa38
      [   35.254216]  worker_thread+0x55c/0x8d8
      [   35.254219]  kthread+0x1b0/0x1b8
      [   35.254222]  ret_from_fork+0x10/0x1c
      
      [   35.254224] The buggy address belongs to the page:
      [   35.254228] page:ffff7e00ed994400 count:1 mapcount:0 mapping:0000000000000000 index:0x0 compound_mapcount: 0
      [   35.273835] flags: 0xfffff8000008000(head)
      [   35.282007] raw: 0fffff8000008000 dead000000000100 dead000000000200 0000000000000000
      [   35.282010] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
      [   35.282012] page dumped because: kasan: bad access detected
      
      [   35.282014] Memory state around the buggy address:
      [   35.282017]  ffff803b66515700: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
      [   35.282019]  ffff803b66515780: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
      [   35.282021] >ffff803b66515800: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
      [   35.282022]                             ^
      [   35.282024]  ffff803b66515880: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
      [   35.282026]  ffff803b66515900: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
      [   35.282028] ==================================================================
      [   35.282029] Disabling lock debugging due to kernel taint
      [   35.282747] hclge driver initialization finished.
      
      Fixes: 67bf2541 ("net: hns3: Fixes the back pressure setting when sriov is enabled")
      Signed-off-by: NYunsheng Lin <linyunsheng@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e8ccbb7d
    • D
      Merge branch 'net-bql-better-deal-with-GSO' · cb53fd54
      David S. Miller 提交于
      Eric Dumazet says:
      
      ====================
      net: bql: better deal with GSO
      
      While BQL bulk dequeue works well for TSO packets, it is
      not very efficient as soon as GSO is involved.
      
      On a GSO only workload (UDP or TCP), this patch series
      can save about 8 % of cpu cycles on a 40Gbit mlx4 NIC,
      by keeping optimal batching, and avoiding expensive
      doorbells, qdisc requeues and reschedules.
      
      This patch series :
      
      - Add __netdev_tx_sent_queue() so that drivers
        can implement efficient BQL and xmit_more support.
      
      - Implement a work around in dev_hard_start_xmit()
        for drivers not using __netdev_tx_sent_queue()
      
      - changes mlx4 to use __netdev_tx_sent_queue()
      
      v2: Tariq and Willem feedback addressed.
          added __netdev_tx_sent_queue() (Willem suggestion)
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cb53fd54
    • E
      net/mlx4_en: use __netdev_tx_sent_queue() · c2973444
      Eric Dumazet 提交于
      doorbell only depends on xmit_more and netif_tx_queue_stopped()
      
      Using __netdev_tx_sent_queue() avoids messing with BQL stop flag,
      and is more generic.
      
      This patch increases performance on GSO workload by keeping
      doorbells to the minimum required.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Cc: Tariq Toukan <tariqt@mellanox.com>
      Reviewed-by: NTariq Toukan <tariqt@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c2973444
    • E
      net: do not abort bulk send on BQL status · fe60faa5
      Eric Dumazet 提交于
      Before calling dev_hard_start_xmit(), upper layers tried
      to cook optimal skb list based on BQL budget.
      
      Problem is that GSO packets can end up comsuming more than
      the BQL budget.
      
      Breaking the loop is not useful, since requeued packets
      are ahead of any packets still in the qdisc.
      
      It is also more expensive, since next TX completion will
      push these packets later, while skbs are not in cpu caches.
      
      It is also a behavior difference with TSO packets, that can
      break the BQL limit by a large amount.
      
      Note that drivers should use __netdev_tx_sent_queue()
      in order to have optimal xmit_more support, and avoid
      useless atomic operations as shown in the following patch.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fe60faa5
    • E
      net: bql: add __netdev_tx_sent_queue() · 3e59020a
      Eric Dumazet 提交于
      When qdisc_run() tries to use BQL budget to bulk-dequeue a batch
      of packets, GSO can later transform this list in another list
      of skbs, and each skb is sent to device ndo_start_xmit(),
      one at a time, with skb->xmit_more being set to one but
      for last skb.
      
      Problem is that very often, BQL limit is hit in the middle of
      the packet train, forcing dev_hard_start_xmit() to stop the
      bulk send and requeue the end of the list.
      
      BQL role is to avoid head of line blocking, making sure
      a qdisc can deliver high priority packets before low priority ones.
      
      But there is no way requeued packets can be bypassed by fresh
      packets in the qdisc.
      
      Aborting the bulk send increases TX softirqs, and hot cache
      lines (after skb_segment()) are wasted.
      
      Note that for TSO packets, we never split a packet in the middle
      because of BQL limit being hit.
      
      Drivers should be able to update BQL counters without
      flipping/caring about BQL status, if the current skb
      has xmit_more set.
      
      Upper layers are ultimately responsible to stop sending another
      packet train when BQL limit is hit.
      
      Code template in a driver might look like the following :
      
      	send_doorbell = __netdev_tx_sent_queue(tx_queue, nr_bytes, skb->xmit_more);
      
      Note that __netdev_tx_sent_queue() use is not mandatory,
      since following patch will change dev_hard_start_xmit()
      to not care about BQL status.
      
      But it is highly recommended so that xmit_more full benefits
      can be reached (less doorbells sent, and less atomic operations as well)
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3e59020a
    • D
      Merge branch 's390-qeth-fixes' · b8a5d06a
      David S. Miller 提交于
      Julian Wiedmann says:
      
      ====================
      s390/qeth: fixes 2018-11-02
      
      please apply one round of qeth fixes for -net.
      
      Patch 1 is rather large and removes a use-after-free hazard from many of our
      debug trace entries.
      Patch 2 is yet another fix-up for the L3 subdriver's new IP address management
      code.
      Patch 3 and 4 resolve some fallout from the recent changes wrt how/when qeth
      allocates its net_device.
      Patch 5 makes sure we don't set reserved bits when building HW commands from
      user-provided data.
      And finally, patch 6 allows ethtool to play nice with new HW.
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b8a5d06a
    • J
      s390/qeth: report 25Gbit link speed · 54e049c2
      Julian Wiedmann 提交于
      This adds the various identifiers for 25Gbit cards, and wires them up
      into sysfs and ethtool.
      Signed-off-by: NJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      54e049c2
    • J
      s390/qeth: sanitize ARP requests · 125d7d30
      Julian Wiedmann 提交于
      The ARP_{ADD,REMOVE}_ENTRY cmd structs contain reserved fields.
      Introduce a common helper that doesn't raw-copy the user-provided data
      into the cmd, but only sets those fields that are strictly needed for
      the command.
      
      This also sets the correct command length for ARP_REMOVE_ENTRY.
      Signed-off-by: NJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      125d7d30
    • J
      s390/qeth: fix initial operstate · 9fae5c3b
      Julian Wiedmann 提交于
      Setting the carrier 'on' for an unregistered netdevice doesn't update
      its operstate. Fix this by delaying the update until the netdevice has
      been registered.
      
      Fixes: 91cc98f5 ("s390/qeth: remove duplicated carrier state tracking")
      Signed-off-by: NJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9fae5c3b
    • J
      s390/qeth: unregister netdevice only when registered · 30356d08
      Julian Wiedmann 提交于
      qeth only registers its netdevice when the qeth device is first set
      online. Thus a device that has never been set online will trigger
      a WARN ("network todo 'hsi%d' but state 0") in unregister_netdev() when
      removed.
      
      Fix this by protecting the unregister step, just like we already protect
      against repeated registering of the netdevice.
      
      Fixes: d3d1b205 ("s390/qeth: allocate netdevice early")
      Reported-by: NKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: NJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      30356d08
    • J
      s390/qeth: fix HiperSockets sniffer · bd74a7f9
      Julian Wiedmann 提交于
      Sniffing mode for L3 HiperSockets requires that no IP addresses are
      registered with the HW. The preferred way to achieve this is for
      userspace to delete all the IPs on the interface. But qeth is expected
      to also tolerate a configuration where that is not the case, by skipping
      the IP registration when in sniffer mode.
      Since commit 5f78e29c ("qeth: optimize IP handling in rx_mode callback")
      reworked the IP registration logic in the L3 subdriver, this no longer
      works. When the qeth device is set online, qeth_l3_recover_ip() now
      unconditionally registers all unicast addresses from our internal
      IP table.
      
      While we could fix this particular problem by skipping
      qeth_l3_recover_ip() on a sniffer device, the more future-proof change
      is to skip the IP address registration at the lowest level. This way we
      a) catch any future code path that attempts to register an IP address
         without considering the sniffer scenario, and
      b) continue to build up our internal IP table, so that if sniffer mode
         is switched off later we can operate just like normal.
      
      Fixes: 5f78e29c ("qeth: optimize IP handling in rx_mode callback")
      Signed-off-by: NJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bd74a7f9
    • J
      s390/qeth: sanitize strings in debug messages · e19e5be8
      Julian Wiedmann 提交于
      As Documentation/s390/s390dbf.txt states quite clearly, using any
      pointer in sprinf-formatted s390dbf debug entries is dangerous.
      The pointers are dereferenced whenever the trace file is read from.
      So if the referenced data has a shorter life-time than the trace file,
      any read operation can result in a use-after-free.
      
      So rip out all hazardous use of indirect data, and replace any usage of
      dev_name() and such by the Bus ID number.
      Signed-off-by: NJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e19e5be8
  4. 03 11月, 2018 13 次提交
    • D
      Merge branch 'net-timeout-fixes-for-GENET-and-SYSTEMPORT' · 265ad063
      David S. Miller 提交于
      Florian Fainelli says:
      
      ====================
      net: timeout fixes for GENET and SYSTEMPORT
      
      This patch series fixes occasional transmit timeout around the time
      the system goes into suspend. GENET and SYSTEMPORT have nearly the same
      logic in that regard and were both affected in the same way.
      
      Please queue up for stable, thanks!
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      265ad063
    • F
      net: systemport: Protect stop from timeout · 7cb6a2a2
      Florian Fainelli 提交于
      A timing hazard exists when the network interface is stopped that
      allows a watchdog timeout to be processed by a separate core in
      parallel. This creates the potential for the timeout handler to
      wake the queues while the driver is shutting down, or access
      registers after their clocks have been removed.
      
      The more common case is that the watchdog timeout will produce a
      warning message which doesn't lead to a crash. The chances of this
      are greatly increased by the fact that bcm_sysport_netif_stop stops
      the transmit queues which can easily precipitate a watchdog time-
      out because of stale trans_start data in the queues.
      
      This commit corrects the behavior by ensuring that the watchdog
      timeout is disabled before enterring bcm_sysport_netif_stop. There
      are currently only two users of the bcm_sysport_netif_stop function:
      close and suspend.
      
      The close case already handles the issue by exiting the RUNNING
      state before invoking the driver close service.
      
      The suspend case now performs the netif_device_detach to exit the
      PRESENT state before the call to bcm_sysport_netif_stop rather than
      after it.
      
      These behaviors prevent any future scheduling of the driver timeout
      service during the window. The netif_tx_stop_all_queues function
      in bcm_sysport_netif_stop is replaced with netif_tx_disable to ensure
      synchronization with any transmit or timeout threads that may
      already be executing on other cores.
      
      For symmetry, the netif_device_attach call upon resume is moved to
      after the call to bcm_sysport_netif_start. Since it wakes the transmit
      queues it is not necessary to invoke netif_tx_start_all_queues from
      bcm_sysport_netif_start so it is moved into the driver open service.
      
      Fixes: 40755a0f ("net: systemport: add suspend and resume support")
      Fixes: 80105bef ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7cb6a2a2
    • D
      net: bcmgenet: protect stop from timeout · 09e805d2
      Doug Berger 提交于
      A timing hazard exists when the network interface is stopped that
      allows a watchdog timeout to be processed by a separate core in
      parallel. This creates the potential for the timeout handler to
      wake the queues while the driver is shutting down, or access
      registers after their clocks have been removed.
      
      The more common case is that the watchdog timeout will produce a
      warning message which doesn't lead to a crash. The chances of this
      are greatly increased by the fact that bcmgenet_netif_stop stops
      the transmit queues which can easily precipitate a watchdog time-
      out because of stale trans_start data in the queues.
      
      This commit corrects the behavior by ensuring that the watchdog
      timeout is disabled before enterring bcmgenet_netif_stop. There
      are currently only two users of the bcmgenet_netif_stop function:
      close and suspend.
      
      The close case already handles the issue by exiting the RUNNING
      state before invoking the driver close service.
      
      The suspend case now performs the netif_device_detach to exit the
      PRESENT state before the call to bcmgenet_netif_stop rather than
      after it.
      
      These behaviors prevent any future scheduling of the driver timeout
      service during the window. The netif_tx_stop_all_queues function
      in bcmgenet_netif_stop is replaced with netif_tx_disable to ensure
      synchronization with any transmit or timeout threads that may
      already be executing on other cores.
      
      For symmetry, the netif_device_attach call upon resume is moved to
      after the call to bcmgenet_netif_start. Since it wakes the transmit
      queues it is not necessary to invoke netif_tx_start_all_queues from
      bcmgenet_netif_start so it is moved into the driver open service.
      
      Fixes: 1c1008c7 ("net: bcmgenet: add main driver file")
      Signed-off-by: NDoug Berger <opendmb@gmail.com>
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      09e805d2
    • D
      rxrpc: Fix lockup due to no error backoff after ack transmit error · c7e86acf
      David Howells 提交于
      If the network becomes (partially) unavailable, say by disabling IPv6, the
      background ACK transmission routine can get itself into a tizzy by
      proposing immediate ACK retransmission.  Since we're in the call event
      processor, that happens immediately without returning to the workqueue
      manager.
      
      The condition should clear after a while when either the network comes back
      or the call times out.
      
      Fix this by:
      
       (1) When re-proposing an ACK on failed Tx, don't schedule it immediately.
           This will allow a certain amount of time to elapse before we try
           again.
      
       (2) Enforce a return to the workqueue manager after a certain number of
           iterations of the call processing loop.
      
       (3) Add a backoff delay that increases the delay on deferred ACKs by a
           jiffy per failed transmission to a limit of HZ.  The backoff delay is
           cleared on a successful return from kernel_sendmsg().
      
       (4) Cancel calls immediately if the opening sendmsg fails.  The layer
           above can arrange retransmission or rotate to another server.
      
      Fixes: 248f219c ("rxrpc: Rewrite the data and ack handling code")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c7e86acf
    • T
      net: dsa: microchip: initialize mutex before use · 284fb78e
      Tristram Ha 提交于
      Initialize mutex before use.  Avoid kernel complaint when
      CONFIG_DEBUG_LOCK_ALLOC is enabled.
      
      Fixes: b987e98e ("dsa: add DSA switch driver for Microchip KSZ9477")
      Signed-off-by: NTristram Ha <Tristram.Ha@microchip.com>
      Reviewed-by: NPavel Machek <pavel@ucw.cz>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      284fb78e
    • J
      net/ipv6: Add anycast addresses to a global hashtable · 2384d025
      Jeff Barnhill 提交于
      icmp6_send() function is expensive on systems with a large number of
      interfaces. Every time it’s called, it has to verify that the source
      address does not correspond to an existing anycast address by looping
      through every device and every anycast address on the device.  This can
      result in significant delays for a CPU when there are a large number of
      neighbors and ND timers are frequently timing out and calling
      neigh_invalidate().
      
      Add anycast addresses to a global hashtable to allow quick searching for
      matching anycast addresses.  This is based on inet6_addr_lst in addrconf.c.
      Signed-off-by: NJeff Barnhill <0xeffeff@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2384d025
    • F
      usbnet: smsc95xx: disable carrier check while suspending · 7b900ead
      Frieder Schrempf 提交于
      We need to make sure, that the carrier check polling is disabled
      while suspending. Otherwise we can end up with usbnet_read_cmd()
      being issued when only usbnet_read_cmd_nopm() is allowed. If this
      happens, read operations lock up.
      
      Fixes: d69d1694 ("usbnet: smsc95xx: fix link detection for disabled autonegotiation")
      Signed-off-by: NFrieder Schrempf <frieder.schrempf@kontron.de>
      Reviewed-by: NRaghuram Chary J <RaghuramChary.Jallipalli@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7b900ead
    • M
      net: document skb parameter in function 'skb_gso_size_check' · 49682bfa
      Mathieu Malaterre 提交于
      Remove kernel-doc warning:
      
        net/core/skbuff.c:4953: warning: Function parameter or member 'skb' not described in 'skb_gso_size_check'
      Signed-off-by: NMathieu Malaterre <malat@debian.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      49682bfa
    • D
      bpf: fix bpf_prog_get_info_by_fd to return 0 func_lens for unpriv · 28c2fae7
      Daniel Borkmann 提交于
      While dbecd738 ("bpf: get kernel symbol addresses via syscall")
      zeroed info.nr_jited_ksyms in bpf_prog_get_info_by_fd() for queries
      from unprivileged users, commit 815581c1 ("bpf: get JITed image
      lengths of functions via syscall") forgot about doing so and therefore
      returns the #elems of the user set up buffer which is incorrect. It
      also needs to indicate a info.nr_jited_func_lens of zero.
      
      Fixes: 815581c1 ("bpf: get JITed image lengths of functions via syscall")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Cc: Sandipan Das <sandipan@linux.vnet.ibm.com>
      Cc: Song Liu <songliubraving@fb.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      28c2fae7
    • D
      Merge branch 'bpf-accurate-prog-addr' · b0970f23
      Daniel Borkmann 提交于
      Song Liu says:
      
      ====================
      Changes v1 -> v2:
      1. Added main program length to bpf_prog_info->jited_fun_lens (3/3).
      2. Updated commit message of 1/3 and 2/3 with more background about the
         address masking, and why it is still save after the changes.
      3. Replace "ulong" with "unsigned long".
      
      This set improves bpf program address showed in /proc/kallsyms and in
      bpf_prog_info. First, real program address is showed instead of page
      address. Second, when there is no subprogram, bpf_prog_info->jited_ksyms
      and bpf_prog_info->jited_fun_lens returns the main prog address and
      length.
      ====================
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      b0970f23
    • S
      bpf: show main program address and length in bpf_prog_info · ff1889fc
      Song Liu 提交于
      Currently, when there is no subprog (prog->aux->func_cnt == 0),
      bpf_prog_info does not return any jited_ksyms or jited_func_lens. This
      patch adds main program address (prog->bpf_func) and main program
      length (prog->jited_len) to bpf_prog_info.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      ff1889fc
    • S
      bpf: show real jited address in bpf_prog_info->jited_ksyms · de57e99c
      Song Liu 提交于
      Currently, jited_ksyms in bpf_prog_info shows page addresses of jited
      bpf program. The main reason here is to not expose randomized start
      address. However, this is not ideal for detailed profiling (find hot
      instructions from stack traces). This patch replaces the page address
      with real prog start address.
      
      This change is OK because bpf_prog_get_info_by_fd() is only available
      to root.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      de57e99c
    • S
      bpf: show real jited prog address in /proc/kallsyms · df073470
      Song Liu 提交于
      Currently, /proc/kallsyms shows page address of jited bpf program. The
      main reason here is to not expose randomized start address. However,
      This is not ideal for detailed profiling (find hot instructions from
      stack traces). This patch replaces the page address with real prog start
      address.
      
      This change is OK because these addresses are still protected by sysctl
      kptr_restrict (see kallsyms_show_value()), and only programs loaded by
      root are added to kallsyms (see bpf_prog_kallsyms_add()).
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      df073470
  5. 02 11月, 2018 4 次提交
    • C
      net: drop skb on failure in ip_check_defrag() · 7de414a9
      Cong Wang 提交于
      Most callers of pskb_trim_rcsum() simply drop the skb when
      it fails, however, ip_check_defrag() still continues to pass
      the skb up to stack. This is suspicious.
      
      In ip_check_defrag(), after we learn the skb is an IP fragment,
      passing the skb to callers makes no sense, because callers expect
      fragments are defrag'ed on success. So, dropping the skb when we
      can't defrag it is reasonable.
      
      Note, prior to commit 88078d98, this is not a big problem as
      checksum will be fixed up anyway. After it, the checksum is not
      correct on failure.
      
      Found this during code review.
      
      Fixes: 88078d98 ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends")
      Cc: Eric Dumazet <edumazet@google.com>
      Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7de414a9
    • L
      Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · 7c6c54b5
      Linus Torvalds 提交于
      Pull i2c fixes from Wolfram Sang:
       "I2C has a core bugfix & cleanup as well as an ID addition and
        MAINTAINERS update for you"
      
      * 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        MAINTAINERS: add maintainer for IMX LPI2C driver
        dt-bindings: i2c: i2c-imx-lpi2c: add imx8qxp compatible string
        i2c: Clear client->irq in i2c_device_remove
        i2c: Remove unnecessary call to irq_find_mapping
      7c6c54b5
    • L
      Merge branch 'for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu · 6444ccfd
      Linus Torvalds 提交于
      Pull percpu fixes from Dennis Zhou:
       "Two small things for v4.20.
      
        The first fixes a clang uninitialized variable warning for arm64 in
        the default path calls BUILD_BUG(). The second removes an unnecessary
        unlikely() in a WARN_ON() use"
      
      * 'for-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu:
        arm64: percpu: Initialize ret in the default case
        mm: percpu: remove unnecessary unlikely()
      6444ccfd
    • L
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net · 82aa4671
      Linus Torvalds 提交于
      Pull networking fixes from David Miller:
      
       1) BPF verifier fixes from Daniel Borkmann.
      
       2) HNS driver fixes from Huazhong Tan.
      
       3) FDB only works for ethernet devices, reject attempts to install FDB
          rules for others. From Ido Schimmel.
      
       4) Fix spectre V1 in vhost, from Jason Wang.
      
       5) Don't pass on-stack object to irq_set_affinity_hint() in mvpp2
          driver, from Marc Zyngier.
      
       6) Fix mlx5e checksum handling when RXFCS is enabled, from Eric
          Dumazet.
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (49 commits)
        openvswitch: Fix push/pop ethernet validation
        net: stmmac: Fix stmmac_mdio_reset() when building stmmac as modules
        bpf: test make sure to run unpriv test cases in test_verifier
        bpf: add various test cases to test_verifier
        bpf: don't set id on after map lookup with ptr_to_map_val return
        bpf: fix partial copy of map_ptr when dst is scalar
        libbpf: Fix compile error in libbpf_attach_type_by_name
        kselftests/bpf: use ping6 as the default ipv6 ping binary if it exists
        selftests: mlxsw: qos_mc_aware: Add a test for UC awareness
        selftests: mlxsw: qos_mc_aware: Tweak for min shaper
        mlxsw: spectrum: Set minimum shaper on MC TCs
        mlxsw: reg: QEEC: Add minimum shaper fields
        net: hns3: bugfix for rtnl_lock's range in the hclgevf_reset()
        net: hns3: bugfix for rtnl_lock's range in the hclge_reset()
        net: hns3: bugfix for handling mailbox while the command queue reinitialized
        net: hns3: fix incorrect return value/type of some functions
        net: hns3: bugfix for hclge_mdio_write and hclge_mdio_read
        net: hns3: bugfix for is_valid_csq_clean_head()
        net: hns3: remove unnecessary queue reset in the hns3_uninit_all_ring()
        net: hns3: bugfix for the initialization of command queue's spin lock
        ...
      82aa4671