1. 30 Nov, 2022 2 commits
    • Pablo Neira Ayuso's avatar
      netfilter: ctnetlink: fix compilation warning after data race fixes in ct mark · 1feeae07
      Pablo Neira Ayuso authored
      All warnings (new ones prefixed by >>):
      
         net/netfilter/nf_conntrack_netlink.c: In function '__ctnetlink_glue_build':
      >> net/netfilter/nf_conntrack_netlink.c:2674:13: warning: unused variable 'mark' [-Wunused-variable]
          2674 |         u32 mark;
               |             ^~~~
      
      Fixes: 52d1aa8b ("netfilter: conntrack: Fix data-races around ct mark")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Tested-by: default avatarIvan Babrou <ivan@ivan.computer>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      1feeae07
    • Xin Long's avatar
      netfilter: conntrack: fix using __this_cpu_add in preemptible · 9464d0b6
      Xin Long authored
      Currently in nf_conntrack_hash_check_insert(), when it fails in
      nf_ct_ext_valid_pre/post(), NF_CT_STAT_INC() will be called in the
      preemptible context, a call trace can be triggered:
      
         BUG: using __this_cpu_add() in preemptible [00000000] code: conntrack/1636
         caller is nf_conntrack_hash_check_insert+0x45/0x430 [nf_conntrack]
         Call Trace:
          <TASK>
          dump_stack_lvl+0x33/0x46
          check_preemption_disabled+0xc3/0xf0
          nf_conntrack_hash_check_insert+0x45/0x430 [nf_conntrack]
          ctnetlink_create_conntrack+0x3cd/0x4e0 [nf_conntrack_netlink]
          ctnetlink_new_conntrack+0x1c0/0x450 [nf_conntrack_netlink]
          nfnetlink_rcv_msg+0x277/0x2f0 [nfnetlink]
          netlink_rcv_skb+0x50/0x100
          nfnetlink_rcv+0x65/0x144 [nfnetlink]
          netlink_unicast+0x1ae/0x290
          netlink_sendmsg+0x257/0x4f0
          sock_sendmsg+0x5f/0x70
      
      This patch is to fix it by changing to use NF_CT_STAT_INC_ATOMIC() for
      nf_ct_ext_valid_pre/post() check in nf_conntrack_hash_check_insert(),
      as well as nf_ct_ext_valid_post() in __nf_conntrack_confirm().
      
      Note that nf_ct_ext_valid_pre() check in __nf_conntrack_confirm() is
      safe to use NF_CT_STAT_INC(), as it's under local_bh_disable().
      
      Fixes: c56716c6 ("netfilter: extensions: introduce extension genid count")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      9464d0b6
  2. 28 Nov, 2022 14 commits
  3. 27 Nov, 2022 1 commit
    • Yang Yingliang's avatar
      net: phy: fix null-ptr-deref while probe() failed · 369eb2c9
      Yang Yingliang authored
      I got a null-ptr-deref report as following when doing fault injection test:
      
      BUG: kernel NULL pointer dereference, address: 0000000000000058
      Oops: 0000 [#1] PREEMPT SMP KASAN PTI
      CPU: 1 PID: 253 Comm: 507-spi-dm9051 Tainted: G    B            N 6.1.0-rc3+
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
      RIP: 0010:klist_put+0x2d/0xd0
      Call Trace:
       <TASK>
       klist_remove+0xf1/0x1c0
       device_release_driver_internal+0x23e/0x2d0
       bus_remove_device+0x1bd/0x240
       device_del+0x357/0x770
       phy_device_remove+0x11/0x30
       mdiobus_unregister+0xa5/0x140
       release_nodes+0x6a/0xa0
       devres_release_all+0xf8/0x150
       device_unbind_cleanup+0x19/0xd0
      
      //probe path:
      phy_device_register()
        device_add()
      
      phy_connect
        phy_attach_direct() //set device driver
          probe() //it's failed, driver is not bound
          device_bind_driver() // probe failed, it's not called
      
      //remove path:
      phy_device_remove()
        device_del()
          device_release_driver_internal()
            __device_release_driver() //dev->drv is not NULL
              klist_remove() <- knode_driver is not added yet, cause null-ptr-deref
      
      In phy_attach_direct(), after setting the 'dev->driver', probe() fails,
      device_bind_driver() is not called, so the knode_driver->n_klist is not
      set, then it causes null-ptr-deref in __device_release_driver() while
      deleting device. Fix this by setting dev->driver to NULL in the error
      path in phy_attach_direct().
      
      Fixes: e1393456 ("[PATCH] PHY Layer fixup")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      369eb2c9
  4. 25 Nov, 2022 8 commits
  5. 24 Nov, 2022 15 commits