1. 10 3月, 2021 3 次提交
    • B
      net: check if protocol extracted by virtio_net_hdr_set_proto is correct · 924a9bc3
      Balazs Nemeth 提交于
      For gso packets, virtio_net_hdr_set_proto sets the protocol (if it isn't
      set) based on the type in the virtio net hdr, but the skb could contain
      anything since it could come from packet_snd through a raw socket. If
      there is a mismatch between what virtio_net_hdr_set_proto sets and
      the actual protocol, then the skb could be handled incorrectly later
      on.
      
      An example where this poses an issue is with the subsequent call to
      skb_flow_dissect_flow_keys_basic which relies on skb->protocol being set
      correctly. A specially crafted packet could fool
      skb_flow_dissect_flow_keys_basic preventing EINVAL to be returned.
      
      Avoid blindly trusting the information provided by the virtio net header
      by checking that the protocol in the packet actually matches the
      protocol set by virtio_net_hdr_set_proto. Note that since the protocol
      is only checked if skb->dev implements header_ops->parse_protocol,
      packets from devices without the implementation are not checked at this
      stage.
      
      Fixes: 9274124f ("net: stricter validation of untrusted gso packets")
      Signed-off-by: NBalazs Nemeth <bnemeth@redhat.com>
      Acked-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      924a9bc3
    • G
      net: dsa: xrs700x: check if partner is same as port in hsr join · 286a8624
      George McCollister 提交于
      Don't assign dp to partner if it's the same port that xrs700x_hsr_join
      was called with. The partner port is supposed to be the other port in
      the HSR/PRP redundant pair not the same port. This fixes an issue
      observed in testing where forwarding between redundant HSR ports on this
      switch didn't work depending on the order the ports were added to the
      hsr device.
      
      Fixes: bd62e6f5 ("net: dsa: xrs700x: add HSR offloading support")
      Signed-off-by: NGeorge McCollister <george.mccollister@gmail.com>
      Reviewed-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      286a8624
    • X
      net: lapbether: Remove netif_start_queue / netif_stop_queue · f7d9d485
      Xie He 提交于
      For the devices in this driver, the default qdisc is "noqueue",
      because their "tx_queue_len" is 0.
      
      In function "__dev_queue_xmit" in "net/core/dev.c", devices with the
      "noqueue" qdisc are specially handled. Packets are transmitted without
      being queued after a "dev->flags & IFF_UP" check. However, it's possible
      that even if this check succeeds, "ops->ndo_stop" may still have already
      been called. This is because in "__dev_close_many", "ops->ndo_stop" is
      called before clearing the "IFF_UP" flag.
      
      If we call "netif_stop_queue" in "ops->ndo_stop", then it's possible in
      "__dev_queue_xmit", it sees the "IFF_UP" flag is present, and then it
      checks "netif_xmit_stopped" and finds that the queue is already stopped.
      In this case, it will complain that:
      "Virtual device ... asks to queue packet!"
      
      To prevent "__dev_queue_xmit" from generating this complaint, we should
      not call "netif_stop_queue" in "ops->ndo_stop".
      
      We also don't need to call "netif_start_queue" in "ops->ndo_open",
      because after a netdev is allocated and registered, the
      "__QUEUE_STATE_DRV_XOFF" flag is initially not set, so there is no need
      to call "netif_start_queue" to clear it.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: NXie He <xie.he.0141@gmail.com>
      Acked-by: NMartin Schiller <ms@dev.tdt.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f7d9d485
  2. 09 3月, 2021 18 次提交
  3. 07 3月, 2021 1 次提交
    • D
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf · 9270bbe2
      David S. Miller 提交于
      Pablo Neira Ayuso says:
      
      ====================
      Netfilter fixes for net
      
      The following patchset contains Netfilter fixes for net:
      
      1) Fix incorrect enum type definition in nfnetlink_cthelper UAPI,
         from Dmitry V. Levin.
      
      2) Remove extra space in deprecated automatic helper assignment
         notice, from Klemen Košir.
      
      3) Drop early socket demux socket after NAT mangling, from
         Florian Westphal. Add a test to exercise this bug.
      
      4) Fix bogus invalid packet report in the conntrack TCP tracker,
         also from Florian.
      
      5) Fix access to xt[NFPROTO_UNSPEC] list with no mutex
         in target/match_revfn(), from Vasily Averin.
      
      6) Disallow updates on the table ownership flag.
      
      7) Fix double hook unregistration of tables with owner.
      
      8) Remove bogus check on the table owner in __nft_release_tables().
      ====================
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9270bbe2
  4. 06 3月, 2021 15 次提交
    • J
      ethernet: alx: fix order of calls on resume · a4dcfbc4
      Jakub Kicinski 提交于
      netif_device_attach() will unpause the queues so we can't call
      it before __alx_open(). This went undetected until
      commit b0999223 ("alx: add ability to allocate and free
      alx_napi structures") but now if stack tries to xmit immediately
      on resume before __alx_open() we'll crash on the NAPI being null:
      
       BUG: kernel NULL pointer dereference, address: 0000000000000198
       CPU: 0 PID: 12 Comm: ksoftirqd/0 Tainted: G           OE 5.10.0-3-amd64 #1 Debian 5.10.13-1
       Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./H77-D3H, BIOS F15 11/14/2013
       RIP: 0010:alx_start_xmit+0x34/0x650 [alx]
       Code: 41 56 41 55 41 54 55 53 48 83 ec 20 0f b7 57 7c 8b 8e b0
      0b 00 00 39 ca 72 06 89 d0 31 d2 f7 f1 89 d2 48 8b 84 df
       RSP: 0018:ffffb09240083d28 EFLAGS: 00010297
       RAX: 0000000000000000 RBX: ffffa04d80ae7800 RCX: 0000000000000004
       RDX: 0000000000000000 RSI: ffffa04d80afa000 RDI: ffffa04e92e92a00
       RBP: 0000000000000042 R08: 0000000000000100 R09: ffffa04ea3146700
       R10: 0000000000000014 R11: 0000000000000000 R12: ffffa04e92e92100
       R13: 0000000000000001 R14: ffffa04e92e92a00 R15: ffffa04e92e92a00
       FS:  0000000000000000(0000) GS:ffffa0508f600000(0000) knlGS:0000000000000000
       i915 0000:00:02.0: vblank wait timed out on crtc 0
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000198 CR3: 000000004460a001 CR4: 00000000001706f0
       Call Trace:
        dev_hard_start_xmit+0xc7/0x1e0
        sch_direct_xmit+0x10f/0x310
      
      Cc: <stable@vger.kernel.org> # 4.9+
      Fixes: bc2bebe8 ("alx: remove WoL support")
      Reported-by: NZbynek Michl <zbynek.michl@gmail.com>
      Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983595Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Tested-by: NZbynek Michl <zbynek.michl@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a4dcfbc4
    • G
      lan743x: trim all 4 bytes of the FCS; not just 2 · 3e21a10f
      George McCollister 提交于
      Trim all 4 bytes of the received FCS; not just 2 of them. Leaving 2
      bytes of the FCS on the frame breaks DSA tailing tag drivers.
      
      Fixes: a8db76d4 ("lan743x: boost performance on cpu archs w/o dma cache snooping")
      Signed-off-by: NGeorge McCollister <george.mccollister@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3e21a10f
    • M
      gianfar: fix jumbo packets+napi+rx overrun crash · d8861bab
      Michael Braun 提交于
      When using jumbo packets and overrunning rx queue with napi enabled,
      the following sequence is observed in gfar_add_rx_frag:
      
         | lstatus                              |       | skb                   |
      t  | lstatus,  size, flags                | first | len, data_len, *ptr   |
      ---+--------------------------------------+-------+-----------------------+
      13 | 18002348, 9032, INTERRUPT LAST       | 0     | 9600, 8000,  f554c12e |
      12 | 10000640, 1600, INTERRUPT            | 0     | 8000, 6400,  f554c12e |
      11 | 10000640, 1600, INTERRUPT            | 0     | 6400, 4800,  f554c12e |
      10 | 10000640, 1600, INTERRUPT            | 0     | 4800, 3200,  f554c12e |
      09 | 10000640, 1600, INTERRUPT            | 0     | 3200, 1600,  f554c12e |
      08 | 14000640, 1600, INTERRUPT FIRST      | 0     | 1600, 0,     f554c12e |
      07 | 14000640, 1600, INTERRUPT FIRST      | 1     | 0,    0,     f554c12e |
      06 | 1c000080, 128,  INTERRUPT LAST FIRST | 1     | 0,    0,     abf3bd6e |
      05 | 18002348, 9032, INTERRUPT LAST       | 0     | 8000, 6400,  c5a57780 |
      04 | 10000640, 1600, INTERRUPT            | 0     | 6400, 4800,  c5a57780 |
      03 | 10000640, 1600, INTERRUPT            | 0     | 4800, 3200,  c5a57780 |
      02 | 10000640, 1600, INTERRUPT            | 0     | 3200, 1600,  c5a57780 |
      01 | 10000640, 1600, INTERRUPT            | 0     | 1600, 0,     c5a57780 |
      00 | 14000640, 1600, INTERRUPT FIRST      | 1     | 0,    0,     c5a57780 |
      
      So at t=7 a new packets is started but not finished, probably due to rx
      overrun - but rx overrun is not indicated in the flags. Instead a new
      packets starts at t=8. This results in skb->len to exceed size for the LAST
      fragment at t=13 and thus a negative fragment size added to the skb.
      
      This then crashes:
      
      kernel BUG at include/linux/skbuff.h:2277!
      Oops: Exception in kernel mode, sig: 5 [#1]
      ...
      NIP [c04689f4] skb_pull+0x2c/0x48
      LR [c03f62ac] gfar_clean_rx_ring+0x2e4/0x844
      Call Trace:
      [ec4bfd38] [c06a84c4] _raw_spin_unlock_irqrestore+0x60/0x7c (unreliable)
      [ec4bfda8] [c03f6a44] gfar_poll_rx_sq+0x48/0xe4
      [ec4bfdc8] [c048d504] __napi_poll+0x54/0x26c
      [ec4bfdf8] [c048d908] net_rx_action+0x138/0x2c0
      [ec4bfe68] [c06a8f34] __do_softirq+0x3a4/0x4fc
      [ec4bfed8] [c0040150] run_ksoftirqd+0x58/0x70
      [ec4bfee8] [c0066ecc] smpboot_thread_fn+0x184/0x1cc
      [ec4bff08] [c0062718] kthread+0x140/0x144
      [ec4bff38] [c0012350] ret_from_kernel_thread+0x14/0x1c
      
      This patch fixes this by checking for computed LAST fragment size, so a
      negative sized fragment is never added.
      In order to prevent the newer rx frame from getting corrupted, the FIRST
      flag is checked to discard the incomplete older frame.
      Signed-off-by: NMichael Braun <michael-dev@fami-braun.de>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d8861bab
    • D
      sun/niu: fix wrong RXMAC_BC_FRM_CNT_COUNT count · 155b23e6
      Denis Efremov 提交于
      RXMAC_BC_FRM_CNT_COUNT added to mp->rx_bcasts twice in a row
      in niu_xmac_interrupt(). Remove the second addition.
      Signed-off-by: NDenis Efremov <efremov@linux.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      155b23e6
    • D
      net/hamradio/6pack: remove redundant check in sp_encaps() · 85554bcd
      Denis Efremov 提交于
      "len > sp->mtu" checked twice in a row in sp_encaps().
      Remove the second check.
      Signed-off-by: NDenis Efremov <efremov@linux.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      85554bcd
    • H
      r8169: fix r8168fp_adjust_ocp_cmd function · abbf9a0e
      Hayes Wang 提交于
      The (0xBAF70000 & 0x00FFF000) << 6 should be (0xf70 << 18).
      
      Fixes: 561535b0 ("r8169: fix OCP access on RTL8117")
      Signed-off-by: NHayes Wang <hayeswang@realtek.com>
      Acked-by: NHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      abbf9a0e
    • X
      selftest/net/ipsec.c: Remove unneeded semicolon · 0a7e0c3b
      Xu Wang 提交于
      fix semicolon.cocci warning:
      tools/testing/selftests/net/ipsec.c:1788:2-3: Unneeded semicolon
      Signed-off-by: NXu Wang <vulab@iscas.ac.cn>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0a7e0c3b
    • J
      ibmvnic: remove excessive irqsave · 69cdb794
      Junlin Yang 提交于
      ibmvnic_remove locks multiple spinlocks while disabling interrupts:
      spin_lock_irqsave(&adapter->state_lock, flags);
      spin_lock_irqsave(&adapter->rwi_lock, flags);
      
      As reported by coccinelle, the second _irqsave() overwrites the value
      saved in 'flags' by the first _irqsave(),   therefore when the second
      _irqrestore() comes,the value in 'flags' is not valid,the value saved
      by the first _irqsave() has been lost.
      This likely leads to IRQs remaining disabled. So remove the second
      _irqsave():
      spin_lock_irqsave(&adapter->state_lock, flags);
      spin_lock(&adapter->rwi_lock);
      
      Generated by: ./scripts/coccinelle/locks/flags.cocci
      ./drivers/net/ethernet/ibm/ibmvnic.c:5413:1-18:
      ERROR: nested lock+irqsave that reuses flags from line 5404.
      
      Fixes: 4a41c421 ("ibmvnic: serialize access to work queue on remove")
      Signed-off-by: NJunlin Yang <yangjunlin@yulong.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      69cdb794
    • S
      CIPSO: Fix unaligned memory access in cipso_v4_gentag_hdr · e233febd
      Sergey Nazarov 提交于
      We need to use put_unaligned when writing 32-bit DOI value
      in cipso_v4_gentag_hdr to avoid unaligned memory access.
      
      v2: unneeded type cast removed as Ondrej Mosnacek suggested.
      Signed-off-by: NSergey Nazarov <s-nazarov@yandex.ru>
      Acked-by: NPaul Moore <paul@paul-moore.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e233febd
    • W
      stmmac: intel: Fixes clock registration error seen for multiple interfaces · 8eb37ab7
      Wong Vee Khee 提交于
      Issue seen when enumerating multiple Intel mGbE interfaces in EHL.
      
      [    6.898141] intel-eth-pci 0000:00:1d.2: enabling device (0000 -> 0002)
      [    6.900971] intel-eth-pci 0000:00:1d.2: Fail to register stmmac-clk
      [    6.906434] intel-eth-pci 0000:00:1d.2: User ID: 0x51, Synopsys ID: 0x52
      
      We fix it by making the clock name to be unique following the format
      of stmmac-pci_name(pci_dev) so that we can differentiate the clock for
      these Intel mGbE interfaces in EHL platform as follow:
      
        /sys/kernel/debug/clk/stmmac-0000:00:1d.1
        /sys/kernel/debug/clk/stmmac-0000:00:1d.2
        /sys/kernel/debug/clk/stmmac-0000:00:1e.4
      
      Fixes: 58da0cfa ("net: stmmac: create dwmac-intel.c to contain all Intel platform")
      Signed-off-by: NWong Vee Khee <vee.khee.wong@intel.com>
      Signed-off-by: NVoon Weifeng <weifeng.voon@intel.com>
      Co-developed-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8eb37ab7
    • O
      net: stmmac: Fix VLAN filter delete timeout issue in Intel mGBE SGMII · 9a7b3950
      Ong Boon Leong 提交于
      For Intel mGbE controller, MAC VLAN filter delete operation will time-out
      if serdes power-down sequence happened first during driver remove() with
      below message.
      
      [82294.764958] intel-eth-pci 0000:00:1e.4 eth2: stmmac_dvr_remove: removing driver
      [82294.778677] intel-eth-pci 0000:00:1e.4 eth2: Timeout accessing MAC_VLAN_Tag_Filter
      [82294.779997] intel-eth-pci 0000:00:1e.4 eth2: failed to kill vid 0081/0
      [82294.947053] intel-eth-pci 0000:00:1d.2 eth1: stmmac_dvr_remove: removing driver
      [82295.002091] intel-eth-pci 0000:00:1d.1 eth0: stmmac_dvr_remove: removing driver
      
      Therefore, we delay the serdes power-down to be after unregister_netdev()
      which triggers the VLAN filter delete.
      
      Fixes: b9663b7c ("net: stmmac: Enable SERDES power up/down sequence")
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9a7b3950
    • J
      net: intel: iavf: fix error return code of iavf_init_get_resources() · 6650d31f
      Jia-Ju Bai 提交于
      When iavf_process_config() fails, no error return code of
      iavf_init_get_resources() is assigned.
      To fix this bug, err is assigned with the return value of
      iavf_process_config(), and then err is checked.
      Reported-by: NTOTE Robot <oslab@tsinghua.edu.cn>
      Signed-off-by: NJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6650d31f
    • J
      net: tehuti: fix error return code in bdx_probe() · 38c26ff3
      Jia-Ju Bai 提交于
      When bdx_read_mac() fails, no error return code of bdx_probe()
      is assigned.
      To fix this bug, err is assigned with -EFAULT as error return code.
      Reported-by: NTOTE Robot <oslab@tsinghua.edu.cn>
      Signed-off-by: NJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      38c26ff3
    • K
      net/mlx4_en: update moderation when config reset · 00ff801b
      Kevin(Yudong) Yang 提交于
      This patch fixes a bug that the moderation config will not be
      applied when calling mlx4_en_reset_config. For example, when
      turning on rx timestamping, mlx4_en_reset_config() will be called,
      causing the NIC to forget previous moderation config.
      
      This fix is in phase with a previous fix:
      commit 79c54b6b ("net/mlx4_en: Fix TX moderation info loss
      after set_ringparam is called")
      
      Tested: Before this patch, on a host with NIC using mlx4, run
      netserver and stream TCP to the host at full utilization.
      $ sar -I SUM 1
                       INTR    intr/s
      14:03:56          sum  48758.00
      
      After rx hwtstamp is enabled:
      $ sar -I SUM 1
      14:10:38          sum 317771.00
      We see the moderation is not working properly and issued 7x more
      interrupts.
      
      After the patch, and turned on rx hwtstamp, the rate of interrupts
      is as expected:
      $ sar -I SUM 1
      14:52:11          sum  49332.00
      
      Fixes: 79c54b6b ("net/mlx4_en: Fix TX moderation info loss after set_ringparam is called")
      Signed-off-by: NKevin(Yudong) Yang <yyd@google.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Reviewed-by: NNeal Cardwell <ncardwell@google.com>
      CC: Tariq Toukan <tariqt@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      00ff801b
    • D
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf · 638526bb
      David S. Miller 提交于
      Alexei Starovoitov says:
      
      ====================
      pull-request: bpf 2021-03-04
      
      The following pull-request contains BPF updates for your *net* tree.
      
      We've added 7 non-merge commits during the last 4 day(s) which contain
      a total of 9 files changed, 128 insertions(+), 40 deletions(-).
      
      The main changes are:
      
      1) Fix 32-bit cmpxchg, from Brendan.
      
      2) Fix atomic+fetch logic, from Ilya.
      
      3) Fix usage of bpf_csum_diff in selftests, from Yauheni.
      ====================
      638526bb
  5. 05 3月, 2021 3 次提交