Skip to content
  1. Oct 28, 2021
  2. Oct 27, 2021
  3. Oct 26, 2021
    • Vadym Kochan's avatar
    • Johan Hovold's avatar
      net: lan78xx: fix division by zero in send path · db6c3c06
      Johan Hovold authored
      Add the missing endpoint max-packet sanity check to probe() to avoid
      division by zero in lan78xx_tx_bh() in case a malicious device has
      broken descriptors (or when doing descriptor fuzz testing).
      
      Note that USB core will reject URBs submitted for endpoints with zero
      wMaxPacketSize but that drivers doing packet-size calculations still
      need to handle this (cf. commit 2548288b ("USB: Fix: Don't skip
      endpoint descriptors with maxpacket=0")).
      
      Fixes: 55d7de9d
      
       ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
      Cc: stable@vger.kernel.org      # 4.3
      Cc: Woojung.Huh@microchip.com <Woojung.Huh@microchip.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      db6c3c06
    • Pavel Skripkin's avatar
      net: batman-adv: fix error handling · 6f68cd63
      Pavel Skripkin authored
      Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
      in wrong error handling in batadv_mesh_init().
      
      Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
      of any batadv_*_init() calls failure. This approach may work well, when
      there is some kind of indicator, which can tell which parts of batadv are
      initialized; but there isn't any.
      
      All written above lead to cleaning up uninitialized fields. Even if we hide
      ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
      GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]
      
      To fix these bugs we can unwind batadv_*_init() calls one by one.
      It is good approach for 2 reasons: 1) It fixes bugs on error handling
      path 2) It improves the performance, since we won't call unneeded
      batadv_*_free() functions.
      
      So, this patch makes all batadv_*_init() clean up all allocated memory
      before returning with an error to no call correspoing batadv_*_free()
      and open-codes batadv_mesh_free() with proper order to avoid touching
      uninitialized fields.
      
      Link: https://lore.kernel.org/netdev/000000000000c87fbd05cef6bcb0@google.com/
      
       [1]
      Reported-and-tested-by: default avatar <syzbot+28b0702ada0bf7381f58@syzkaller.appspotmail.com>
      Fixes: c6c8fea2
      
       ("net: Add batman-adv meshing protocol")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Acked-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6f68cd63
    • Max VA's avatar
      tipc: fix size validations for the MSG_CRYPTO type · fa40d973
      Max VA authored
      The function tipc_crypto_key_rcv is used to parse MSG_CRYPTO messages
      to receive keys from other nodes in the cluster in order to decrypt any
      further messages from them.
      This patch verifies that any supplied sizes in the message body are
      valid for the received message.
      
      Fixes: 1ef6f7c9
      
       ("tipc: add automatic session key exchange")
      Signed-off-by: default avatarMax VA <maxv@sentinelone.com>
      Acked-by: default avatarYing Xue <ying.xue@windriver.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fa40d973
    • Krzysztof Kozlowski's avatar
      nfc: port100: fix using -ERRNO as command type mask · 2195f206
      Krzysztof Kozlowski authored
      During probing, the driver tries to get a list (mask) of supported
      command types in port100_get_command_type_mask() function.  The value
      is u64 and 0 is treated as invalid mask (no commands supported).  The
      function however returns also -ERRNO as u64 which will be interpret as
      valid command mask.
      
      Return 0 on every error case of port100_get_command_type_mask(), so the
      probing will stop.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 0347a6ab
      
       ("NFC: port100: Commands mechanism implementation")
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2195f206
    • David S. Miller's avatar
      Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue · eacd68b7
      David S. Miller authored
      
      
      Tony Nguyen says:
      
      ====================
      Intel Wired LAN Driver Updates 2021-10-25
      
      This series contains updates to ice driver only.
      
      Dave adds event handler for LAG NETDEV_UNREGISTER to unlink device from
      link aggregate.
      
      Yongxin Liu adds a check for PTP support during release which would
      cause a call trace on non-PTP supported devices.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      eacd68b7
    • Cyril Strejc's avatar
      net: multicast: calculate csum of looped-back and forwarded packets · 9122a70a
      Cyril Strejc authored
      During a testing of an user-space application which transmits UDP
      multicast datagrams and utilizes multicast routing to send the UDP
      datagrams out of defined network interfaces, I've found a multicast
      router does not fill-in UDP checksum into locally produced, looped-back
      and forwarded UDP datagrams, if an original output NIC the datagrams
      are sent to has UDP TX checksum offload enabled.
      
      The datagrams are sent malformed out of the NIC the datagrams have been
      forwarded to.
      
      It is because:
      
      1. If TX checksum offload is enabled on the output NIC, UDP checksum
         is not calculated by kernel and is not filled into skb data.
      
      2. dev_loopback_xmit(), which is called solely by
         ip_mc_finish_output(), sets skb->ip_summed = CHECKSUM_UNNECESSARY
         unconditionally.
      
      3. Since 35fc92a9
      
       ("[NET]: Allow forwarding of ip_summed except
         CHECKSUM_COMPLETE"), the ip_summed value is preserved during
         forwarding.
      
      4. If ip_summed != CHECKSUM_PARTIAL, checksum is not calculated during
         a packet egress.
      
      The minimum fix in dev_loopback_xmit():
      
      1. Preserves skb->ip_summed CHECKSUM_PARTIAL. This is the
         case when the original output NIC has TX checksum offload enabled.
         The effects are:
      
           a) If the forwarding destination interface supports TX checksum
              offloading, the NIC driver is responsible to fill-in the
              checksum.
      
           b) If the forwarding destination interface does NOT support TX
              checksum offloading, checksums are filled-in by kernel before
              skb is submitted to the NIC driver.
      
           c) For local delivery, checksum validation is skipped as in the
              case of CHECKSUM_UNNECESSARY, thanks to skb_csum_unnecessary().
      
      2. Translates ip_summed CHECKSUM_NONE to CHECKSUM_UNNECESSARY. It
         means, for CHECKSUM_NONE, the behavior is unmodified and is there
         to skip a looped-back packet local delivery checksum validation.
      
      Signed-off-by: default avatarCyril Strejc <cyril.strejc@skoda.cz>
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9122a70a
    • Ido Schimmel's avatar
      mlxsw: pci: Recycle received packet upon allocation failure · 75963576
      Ido Schimmel authored
      When the driver fails to allocate a new Rx buffer, it passes an empty Rx
      descriptor (contains zero address and size) to the device and marks it
      as invalid by setting the skb pointer in the descriptor's metadata to
      NULL.
      
      After processing enough Rx descriptors, the driver will try to process
      the invalid descriptor, but will return immediately seeing that the skb
      pointer is NULL. Since the driver no longer passes new Rx descriptors to
      the device, the Rx queue will eventually become full and the device will
      start to drop packets.
      
      Fix this by recycling the received packet if allocation of the new
      packet failed. This means that allocation is no longer performed at the
      end of the Rx routine, but at the start, before tearing down the DMA
      mapping of the received packet.
      
      Remove the comment about the descriptor being zeroed as it is no longer
      correct. This is OK because we either use the descriptor as-is (when
      recycling) or overwrite its address and size fields with that of the
      newly allocated Rx buffer.
      
      The issue was discovered when a process ("perf") consumed too much
      memory and put the system under memory pressure. It can be reproduced by
      injecting slab allocation failures [1]. After the fix, the Rx queue no
      longer comes to a halt.
      
      [1]
       # echo 10 > /sys/kernel/debug/failslab/times
       # echo 1000 > /sys/kernel/debug/failslab/interval
       # echo 100 > /sys/kernel/debug/failslab/probability
      
       FAULT_INJECTION: forcing a failure.
       name failslab, interval 1000, probability 100, space 0, times 8
       [...]
       Call Trace:
        <IRQ>
        dump_stack_lvl+0x34/0x44
        should_fail.cold+0x32/0x37
        should_failslab+0x5/0x10
        kmem_cache_alloc_node+0x23/0x190
        __alloc_skb+0x1f9/0x280
        __netdev_alloc_skb+0x3a/0x150
        mlxsw_pci_rdq_skb_alloc+0x24/0x90
        mlxsw_pci_cq_tasklet+0x3dc/0x1200
        tasklet_action_common.constprop.0+0x9f/0x100
        __do_softirq+0xb5/0x252
        irq_exit_rcu+0x7a/0xa0
        common_interrupt+0x83/0xa0
        </IRQ>
        asm_common_interrupt+0x1e/0x40
       RIP: 0010:cpuidle_enter_state+0xc8/0x340
       [...]
       mlxsw_spectrum2 0000:06:00.0: Failed to alloc skb for RDQ
      
      Fixes: eda6500a
      
       ("mlxsw: Add PCI bus implementation")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Link: https://lore.kernel.org/r/20211024064014.1060919-1-idosch@idosch.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      75963576
    • Yongxin Liu's avatar
      ice: check whether PTP is initialized in ice_ptp_release() · fd1b5beb
      Yongxin Liu authored
      PTP is currently only supported on E810 devices, it is checked
      in ice_ptp_init(). However, there is no check in ice_ptp_release().
      For other E800 series devices, ice_ptp_release() will be wrongly executed.
      
      Fix the following calltrace.
      
        INFO: trying to register non-static key.
        The code is fine but needs lockdep annotation, or maybe
        you didn't initialize this object before use?
        turning off the locking correctness validator.
        Workqueue: ice ice_service_task [ice]
        Call Trace:
         dump_stack_lvl+0x5b/0x82
         dump_stack+0x10/0x12
         register_lock_class+0x495/0x4a0
         ? find_held_lock+0x3c/0xb0
         __lock_acquire+0x71/0x1830
         lock_acquire+0x1e6/0x330
         ? ice_ptp_release+0x3c/0x1e0 [ice]
         ? _raw_spin_lock+0x19/0x70
         ? ice_ptp_release+0x3c/0x1e0 [ice]
         _raw_spin_lock+0x38/0x70
         ? ice_ptp_release+0x3c/0x1e0 [ice]
         ice_ptp_release+0x3c/0x1e0 [ice]
         ice_prepare_for_reset+0xcb/0xe0 [ice]
         ice_do_reset+0x38/0x110 [ice]
         ice_service_task+0x138/0xf10 [ice]
         ? __this_cpu_preempt_check+0x13/0x20
         process_one_work+0x26a/0x650
         worker_thread+0x3f/0x3b0
         ? __kthread_parkme+0x51/0xb0
         ? process_one_work+0x650/0x650
         kthread+0x161/0x190
         ? set_kthread_struct+0x40/0x40
         ret_from_fork+0x1f/0x30
      
      Fixes: 4dd0d5c3
      
       ("ice: add lock around Tx timestamp tracker flush")
      Signed-off-by: default avatarYongxin Liu <yongxin.liu@windriver.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      fd1b5beb
    • Dave Ertman's avatar
      ice: Respond to a NETDEV_UNREGISTER event for LAG · 6a8b3572
      Dave Ertman authored
      When the PF is a member of a link aggregate, and the driver
      is removed, the process will hang unless we respond to the
      NETDEV_UNREGISTER event that is sent to the event_handler
      for LAG.
      
      Add a case statement for the ice_lag_event_handler to unlink
      the PF from the link aggregate.
      
      Also remove code that was incorrectly applying a dev_hold to
      peer_netdevs that were associated with the ice driver.
      
      Fixes: df006dd4
      
       ("ice: Add initial support framework for LAG")
      Signed-off-by: default avatarDave Ertman <david.m.ertman@intel.com>
      Tested-by: default avatarTony Brelinski <tony.brelinski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      6a8b3572
  4. Oct 25, 2021