Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Nov 17, 2022
  2. Nov 16, 2022
    • Wang Yufen's avatar
      netdevsim: Fix memory leak of nsim_dev->fa_cookie · 064bc731
      Wang Yufen authored
      kmemleak reports this issue:
      
      unreferenced object 0xffff8881bac872d0 (size 8):
        comm "sh", pid 58603, jiffies 4481524462 (age 68.065s)
        hex dump (first 8 bytes):
          04 00 00 00 de ad be ef                          ........
        backtrace:
          [<00000000c80b8577>] __kmalloc+0x49/0x150
          [<000000005292b8c6>] nsim_dev_trap_fa_cookie_write+0xc1/0x210 [netdevsim]
          [<0000000093d78e77>] full_proxy_write+0xf3/0x180
          [<000000005a662c16>] vfs_write+0x1c5/0xaf0
          [<000000007aabf84a>] ksys_write+0xed/0x1c0
          [<000000005f1d2e47>] do_syscall_64+0x3b/0x90
          [<000000006001c6ec>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      The issue occurs in the following scenarios:
      
      nsim_dev_trap_fa_cookie_write()
        kmalloc() fa_cookie
        nsim_dev->fa_cookie = fa_cookie
      ..
      nsim_drv_remove()
      
      The fa_cookie allocked in nsim_dev_trap_fa_cookie_write() is not freed. To
      fix, add kfree(nsim_dev->fa_cookie) to nsim_drv_remove().
      
      Fixes: d3cbb907
      
       ("netdevsim: add ACL trap reporting cookie as a metadata")
      Signed-off-by: default avatarWang Yufen <wangyufen@huawei.com>
      Cc: Jiri Pirko <jiri@mellanox.com>
      Link: https://lore.kernel.org/r/1668504625-14698-1-git-send-email-wangyufen@huawei.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      064bc731
    • Gleb Mazovetskiy's avatar
      tcp: configurable source port perturb table size · aeac4ec8
      Gleb Mazovetskiy authored
      On embedded systems with little memory and no relevant
      security concerns, it is beneficial to reduce the size
      of the table.
      
      Reducing the size from 2^16 to 2^8 saves 255 KiB
      of kernel RAM.
      
      Makes the table size configurable as an expert option.
      
      The size was previously increased from 2^8 to 2^16
      in commit 4c2c8f03
      
       ("tcp: increase source port perturb table to
      2^16").
      
      Signed-off-by: default avatarGleb Mazovetskiy <glex.spb@gmail.com>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aeac4ec8
    • Jakub Sitnicki's avatar
      l2tp: Serialize access to sk_user_data with sk_callback_lock · b68777d5
      Jakub Sitnicki authored
      sk->sk_user_data has multiple users, which are not compatible with each
      other. Writers must synchronize by grabbing the sk->sk_callback_lock.
      
      l2tp currently fails to grab the lock when modifying the underlying tunnel
      socket fields. Fix it by adding appropriate locking.
      
      We err on the side of safety and grab the sk_callback_lock also inside the
      sk_destruct callback overridden by l2tp, even though there should be no
      refs allowing access to the sock at the time when sk_destruct gets called.
      
      v4:
      - serialize write to sk_user_data in l2tp sk_destruct
      
      v3:
      - switch from sock lock to sk_callback_lock
      - document write-protection for sk_user_data
      
      v2:
      - update Fixes to point to origin of the bug
      - use real names in Reported/Tested-by tags
      
      Cc: Tom Parkin <tparkin@katalix.com>
      Fixes: 3557baab
      
       ("[L2TP]: PPP over L2TP driver core")
      Reported-by: default avatarHaowei Yan <g1042620637@gmail.com>
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b68777d5
    • Yuan Can's avatar
      net: thunderbolt: Fix error handling in tbnet_init() · f524b728
      Yuan Can authored
      A problem about insmod thunderbolt-net failed is triggered with following
      log given while lsmod does not show thunderbolt_net:
      
       insmod: ERROR: could not insert module thunderbolt-net.ko: File exists
      
      The reason is that tbnet_init() returns tb_register_service_driver()
      directly without checking its return value, if tb_register_service_driver()
      failed, it returns without removing property directory, resulting the
      property directory can never be created later.
      
       tbnet_init()
         tb_register_property_dir() # register property directory
         tb_register_service_driver()
           driver_register()
             bus_add_driver()
               priv = kzalloc(...) # OOM happened
         # return without remove property directory
      
      Fix by remove property directory when tb_register_service_driver() returns
      error.
      
      Fixes: e69b6c02
      
       ("net: Add support for networking over Thunderbolt cable")
      Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f524b728
    • David S. Miller's avatar
      Merge branch 'microchip-fixes' · e4aa85cf
      David S. Miller authored
      
      Shang XiaoJing says:
      
      ====================
      net: microchip: Fix potential null-ptr-deref due to create_singlethread_workqueue()
      
      There are some functions call create_singlethread_workqueue() without
      checking ret value, and the NULL workqueue_struct pointer may causes
      null-ptr-deref. Will be fixed by this patch.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e4aa85cf
    • Shang XiaoJing's avatar
      net: microchip: sparx5: Fix potential null-ptr-deref in sparx_stats_init() and sparx5_start() · 639f5d00
      Shang XiaoJing authored
      sparx_stats_init() calls create_singlethread_workqueue() and not
      checked the ret value, which may return NULL. And a null-ptr-deref may
      happen:
      
      sparx_stats_init()
          create_singlethread_workqueue() # failed, sparx5->stats_queue is NULL
          queue_delayed_work()
              queue_delayed_work_on()
                  __queue_delayed_work()  # warning here, but continue
                      __queue_work()      # access wq->flags, null-ptr-deref
      
      Check the ret value and return -ENOMEM if it is NULL. So as
      sparx5_start().
      
      Fixes: af4b1102 ("net: sparx5: add ethtool configuration and statistics support")
      Fixes: b37a1bae
      
       ("net: sparx5: add mactable support")
      Signed-off-by: default avatarShang XiaoJing <shangxiaojing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      639f5d00
    • Shang XiaoJing's avatar
      net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init() · ba86af37
      Shang XiaoJing authored
      lan966x_stats_init() calls create_singlethread_workqueue() and not
      checked the ret value, which may return NULL. And a null-ptr-deref may
      happen:
      
      lan966x_stats_init()
          create_singlethread_workqueue() # failed, lan966x->stats_queue is NULL
          queue_delayed_work()
              queue_delayed_work_on()
                  __queue_delayed_work()  # warning here, but continue
                      __queue_work()      # access wq->flags, null-ptr-deref
      
      Check the ret value and return -ENOMEM if it is NULL.
      
      Fixes: 12c2d0a5
      
       ("net: lan966x: add ethtool configuration and statistics")
      Signed-off-by: default avatarShang XiaoJing <shangxiaojing@huawei.com>
      Reviewed-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ba86af37
  3. Nov 15, 2022
  4. Nov 14, 2022
  5. Nov 11, 2022