Skip to content
  1. Nov 23, 2019
    • Florian Westphal's avatar
      udp: drop skb extensions before marking skb stateless · 677bf08c
      Florian Westphal authored
      Once udp stack has set the UDP_SKB_IS_STATELESS flag, later skb free
      assumes all skb head state has been dropped already.
      
      This will leak the extension memory in case the skb has extensions other
      than the ipsec secpath, e.g. bridge nf data.
      
      To fix this, set the UDP_SKB_IS_STATELESS flag only if we don't have
      extensions or if the extension space can be free'd.
      
      Fixes: 895b5c9f
      
       ("netfilter: drop bridge nf reset from nf_reset")
      Cc: Paolo Abeni <pabeni@redhat.com>
      Reported-by: default avatarByron Stanoszek <gandalf@winds.org>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      677bf08c
    • Dan Carpenter's avatar
      net: rtnetlink: prevent underflows in do_setvfinfo() · ff08ddba
      Dan Carpenter authored
      
      
      The "ivm->vf" variable is a u32, but the problem is that a number of
      drivers cast it to an int and then forget to check for negatives.  An
      example of this is in the cxgb4 driver.
      
      drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
        2890  static int cxgb4_mgmt_get_vf_config(struct net_device *dev,
        2891                                      int vf, struct ifla_vf_info *ivi)
                                                  ^^^^^^
        2892  {
        2893          struct port_info *pi = netdev_priv(dev);
        2894          struct adapter *adap = pi->adapter;
        2895          struct vf_info *vfinfo;
        2896
        2897          if (vf >= adap->num_vfs)
                          ^^^^^^^^^^^^^^^^^^^
        2898                  return -EINVAL;
        2899          vfinfo = &adap->vfinfo[vf];
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
      
      There are 48 functions affected.
      
      drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c:8435 hclge_set_vf_vlan_filter() warn: can 'vfid' underflow 's32min-2147483646'
      drivers/net/ethernet/freescale/enetc/enetc_pf.c:377 enetc_pf_set_vf_mac() warn: can 'vf' underflow 's32min-2147483646'
      drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:2899 cxgb4_mgmt_get_vf_config() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:2960 cxgb4_mgmt_set_vf_rate() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:3019 cxgb4_mgmt_set_vf_rate() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:3038 cxgb4_mgmt_set_vf_vlan() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:3086 cxgb4_mgmt_set_vf_link_state() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/chelsio/cxgb/cxgb2.c:791 get_eeprom() warn: can 'i' underflow 's32min-(-4),0,4-s32max'
      drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:82 bnxt_set_vf_spoofchk() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:164 bnxt_set_vf_trust() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:186 bnxt_get_vf_config() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:228 bnxt_set_vf_mac() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:264 bnxt_set_vf_vlan() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:293 bnxt_set_vf_bw() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c:333 bnxt_set_vf_link_state() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c:2595 bnx2x_vf_op_prep() warn: can 'vfidx' underflow 's32min-63'
      drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c:2595 bnx2x_vf_op_prep() warn: can 'vfidx' underflow 's32min-63'
      drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c:2281 bnx2x_post_vf_bulletin() warn: can 'vf' underflow 's32min-63'
      drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c:2285 bnx2x_post_vf_bulletin() warn: can 'vf' underflow 's32min-63'
      drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c:2286 bnx2x_post_vf_bulletin() warn: can 'vf' underflow 's32min-63'
      drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c:2292 bnx2x_post_vf_bulletin() warn: can 'vf' underflow 's32min-63'
      drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c:2297 bnx2x_post_vf_bulletin() warn: can 'vf' underflow 's32min-63'
      drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c:1832 qlcnic_sriov_set_vf_mac() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c:1864 qlcnic_sriov_set_vf_tx_rate() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c:1937 qlcnic_sriov_set_vf_vlan() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c:2005 qlcnic_sriov_get_vf_config() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c:2036 qlcnic_sriov_set_vf_spoofchk() warn: can 'vf' underflow 's32min-254'
      drivers/net/ethernet/emulex/benet/be_main.c:1914 be_get_vf_config() warn: can 'vf' underflow 's32min-65534'
      drivers/net/ethernet/emulex/benet/be_main.c:1915 be_get_vf_config() warn: can 'vf' underflow 's32min-65534'
      drivers/net/ethernet/emulex/benet/be_main.c:1922 be_set_vf_tvt() warn: can 'vf' underflow 's32min-65534'
      drivers/net/ethernet/emulex/benet/be_main.c:1951 be_clear_vf_tvt() warn: can 'vf' underflow 's32min-65534'
      drivers/net/ethernet/emulex/benet/be_main.c:2063 be_set_vf_tx_rate() warn: can 'vf' underflow 's32min-65534'
      drivers/net/ethernet/emulex/benet/be_main.c:2091 be_set_vf_link_state() warn: can 'vf' underflow 's32min-65534'
      drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c:2609 ice_set_vf_port_vlan() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c:3050 ice_get_vf_cfg() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c:3103 ice_set_vf_spoofchk() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c:3181 ice_set_vf_mac() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c:3237 ice_set_vf_trust() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c:3286 ice_set_vf_link_state() warn: can 'vf_id' underflow 's32min-65534'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3919 i40e_validate_vf() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:3957 i40e_ndo_set_vf_mac() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:4104 i40e_ndo_set_vf_port_vlan() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:4263 i40e_ndo_set_vf_bw() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:4309 i40e_ndo_get_vf_config() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:4371 i40e_ndo_set_vf_link_state() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:4441 i40e_ndo_set_vf_spoofchk() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:4441 i40e_ndo_set_vf_spoofchk() warn: can 'vf_id' underflow 's32min-2147483646'
      drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:4504 i40e_ndo_set_vf_trust() warn: can 'vf_id' underflow 's32min-2147483646'
      
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ff08ddba
  2. Nov 22, 2019
  3. Nov 21, 2019
  4. Nov 20, 2019
    • Geert Uytterhoeven's avatar
      mdio_bus: Fix init if CONFIG_RESET_CONTROLLER=n · 6e4ff1c9
      Geert Uytterhoeven authored
      Commit 1d463956 ("mdio_bus: Fix PTR_ERR applied after initialization
      to constant") accidentally changed a check from -ENOTSUPP to -ENOSYS,
      causing failures if reset controller support is not enabled.  E.g. on
      r7s72100/rskrza1:
      
          sh-eth e8203000.ethernet: MDIO init failed: -524
          sh-eth: probe of e8203000.ethernet failed with error -524
      
      Seen on r8a7740/armadillo, r7s72100/rskrza1, and r7s9210/rza2mevb.
      
      Fixes: 1d463956
      
       ("mdio_bus: Fix PTR_ERR applied after initialization to constant")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Cc: David S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6e4ff1c9
    • David S. Miller's avatar
      Revert "mdio_bus: fix mdio_register_device when RESET_CONTROLLER is disabled" · 2c61e821
      David S. Miller authored
      This reverts commit 075e238d
      
      .
      
      Going to go with Geert's fix instead, which also has a
      correct Fixes tag.
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2c61e821
    • Huazhong Tan's avatar
      net: hns3: fix a wrong reset interrupt status mask · 74e78d6b
      Huazhong Tan authored
      According to hardware user manual, bits5~7 in register
      HCLGE_MISC_VECTOR_INT_STS means reset interrupts status,
      but HCLGE_RESET_INT_M is defined as bits0~2 now. So it
      will make hclge_reset_err_handle() read the wrong reset
      interrupt status.
      
      This patch fixes this wrong bit mask.
      
      Fixes: 2336f19d
      
       ("net: hns3: check reset interrupt status when reset fails")
      Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      74e78d6b
    • Chuhong Yuan's avatar
      net: fec: fix clock count mis-match · a31eda65
      Chuhong Yuan authored
      pm_runtime_put_autosuspend in probe will call runtime suspend to
      disable clks automatically if CONFIG_PM is defined. (If CONFIG_PM
      is not defined, its implementation will be empty, then runtime
      suspend will not be called.)
      
      Therefore, we can call pm_runtime_get_sync to runtime resume it
      first to enable clks, which matches the runtime suspend. (Only when
      CONFIG_PM is defined, otherwise pm_runtime_get_sync will also be
      empty, then runtime resume will not be called.)
      
      Then it is fine to disable clks without causing clock count mis-match.
      
      Fixes: c43eab3e
      
       ("net: fec: add missed clk_disable_unprepare in remove")
      Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
      Acked-by: default avatarFugang Duan <fugang.duan@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a31eda65
    • Davide Caratti's avatar
      net/sched: act_pedit: fix WARN() in the traffic path · f67169fe
      Davide Caratti authored
      when configuring act_pedit rules, the number of keys is validated only on
      addition of a new entry. This is not sufficient to avoid hitting a WARN()
      in the traffic path: for example, it is possible to replace a valid entry
      with a new one having 0 extended keys, thus causing splats in dmesg like:
      
       pedit BUG: index 42
       WARNING: CPU: 2 PID: 4054 at net/sched/act_pedit.c:410 tcf_pedit_act+0xc84/0x1200 [act_pedit]
       [...]
       RIP: 0010:tcf_pedit_act+0xc84/0x1200 [act_pedit]
       Code: 89 fa 48 c1 ea 03 0f b6 04 02 84 c0 74 08 3c 03 0f 8e ac 00 00 00 48 8b 44 24 10 48 c7 c7 a0 c4 e4 c0 8b 70 18 e8 1c 30 95 ea <0f> 0b e9 a0 fa ff ff e8 00 03 f5 ea e9 14 f4 ff ff 48 89 58 40 e9
       RSP: 0018:ffff888077c9f320 EFLAGS: 00010286
       RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffffac2983a2
       RDX: 0000000000000001 RSI: 0000000000000008 RDI: ffff888053927bec
       RBP: dffffc0000000000 R08: ffffed100a726209 R09: ffffed100a726209
       R10: 0000000000000001 R11: ffffed100a726208 R12: ffff88804beea780
       R13: ffff888079a77400 R14: ffff88804beea780 R15: ffff888027ab2000
       FS:  00007fdeec9bd740(0000) GS:ffff888053900000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 00007ffdb3dfd000 CR3: 000000004adb4006 CR4: 00000000001606e0
       Call Trace:
        tcf_action_exec+0x105/0x3f0
        tcf_classify+0xf2/0x410
        __dev_queue_xmit+0xcbf/0x2ae0
        ip_finish_output2+0x711/0x1fb0
        ip_output+0x1bf/0x4b0
        ip_send_skb+0x37/0xa0
        raw_sendmsg+0x180c/0x2430
        sock_sendmsg+0xdb/0x110
        __sys_sendto+0x257/0x2b0
        __x64_sys_sendto+0xdd/0x1b0
        do_syscall_64+0xa5/0x4e0
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
       RIP: 0033:0x7fdeeb72e993
       Code: 48 8b 0d e0 74 2c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 0d d6 2c 00 00 75 13 49 89 ca b8 2c 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 34 c3 48 83 ec 08 e8 4b cc 00 00 48 89 04 24
       RSP: 002b:00007ffdb3de8a18 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
       RAX: ffffffffffffffda RBX: 000055c81972b700 RCX: 00007fdeeb72e993
       RDX: 0000000000000040 RSI: 000055c81972b700 RDI: 0000000000000003
       RBP: 00007ffdb3dea130 R08: 000055c819728510 R09: 0000000000000010
       R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000040
       R13: 000055c81972b6c0 R14: 000055c81972969c R15: 0000000000000080
      
      Fix this moving the check on 'nkeys' earlier in tcf_pedit_init(), so that
      attempts to install rules having 0 keys are always rejected with -EINVAL.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f67169fe
    • Russell King's avatar
      net: phylink: fix link mode modification in PHY mode · d9922c0e
      Russell King authored
      
      
      Modifying the link settings via phylink_ethtool_ksettings_set() and
      phylink_ethtool_set_pauseparam() didn't always work as intended for
      PHY based setups, as calling phylink_mac_config() would result in the
      unresolved configuration being committed to the MAC, rather than the
      configuration with the speed and duplex setting.
      
      This would work fine if the update caused the link to renegotiate,
      but if no settings have changed, phylib won't trigger a renegotiation
      cycle, and the MAC will be left incorrectly configured.
      
      Avoid calling phylink_mac_config() unless we are using an inband mode
      in phylink_ethtool_ksettings_set(), and use phy_set_asym_pause() as
      introduced in 4.20 to set the PHY settings in
      phylink_ethtool_set_pauseparam().
      
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d9922c0e