1. 11 3月, 2022 1 次提交
    • D
      PM: core: keep irq flags in device_pm_check_callbacks() · 524bb1da
      Dmitry Baryshkov 提交于
      The function device_pm_check_callbacks() can be called under the spin
      lock (in the reported case it happens from genpd_add_device() ->
      dev_pm_domain_set(), when the genpd uses spinlocks rather than mutexes.
      
      However this function uncoditionally uses spin_lock_irq() /
      spin_unlock_irq(), thus not preserving the CPU flags. Use the
      irqsave/irqrestore instead.
      
      The backtrace for the reference:
      [    2.752010] ------------[ cut here ]------------
      [    2.756769] raw_local_irq_restore() called with IRQs enabled
      [    2.762596] WARNING: CPU: 4 PID: 1 at kernel/locking/irqflag-debug.c:10 warn_bogus_irq_restore+0x34/0x50
      [    2.772338] Modules linked in:
      [    2.775487] CPU: 4 PID: 1 Comm: swapper/0 Tainted: G S                5.17.0-rc6-00384-ge330d0d82eff-dirty #684
      [    2.781384] Freeing initrd memory: 46024K
      [    2.785839] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [    2.785841] pc : warn_bogus_irq_restore+0x34/0x50
      [    2.785844] lr : warn_bogus_irq_restore+0x34/0x50
      [    2.785846] sp : ffff80000805b7d0
      [    2.785847] x29: ffff80000805b7d0 x28: 0000000000000000 x27: 0000000000000002
      [    2.785850] x26: ffffd40e80930b18 x25: ffff7ee2329192b8 x24: ffff7edfc9f60800
      [    2.785853] x23: ffffd40e80930b18 x22: ffffd40e80930d30 x21: ffff7edfc0dffa00
      [    2.785856] x20: ffff7edfc09e3768 x19: 0000000000000000 x18: ffffffffffffffff
      [    2.845775] x17: 6572206f74206465 x16: 6c696166203a3030 x15: ffff80008805b4f7
      [    2.853108] x14: 0000000000000000 x13: ffffd40e809550b0 x12: 00000000000003d8
      [    2.860441] x11: 0000000000000148 x10: ffffd40e809550b0 x9 : ffffd40e809550b0
      [    2.867774] x8 : 00000000ffffefff x7 : ffffd40e809ad0b0 x6 : ffffd40e809ad0b0
      [    2.875107] x5 : 000000000000bff4 x4 : 0000000000000000 x3 : 0000000000000000
      [    2.882440] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff7edfc03a8000
      [    2.889774] Call trace:
      [    2.892290]  warn_bogus_irq_restore+0x34/0x50
      [    2.896770]  _raw_spin_unlock_irqrestore+0x94/0xa0
      [    2.901690]  genpd_unlock_spin+0x20/0x30
      [    2.905724]  genpd_add_device+0x100/0x2d0
      [    2.909850]  __genpd_dev_pm_attach+0xa8/0x23c
      [    2.914329]  genpd_dev_pm_attach_by_id+0xc4/0x190
      [    2.919167]  genpd_dev_pm_attach_by_name+0x3c/0xd0
      [    2.924086]  dev_pm_domain_attach_by_name+0x24/0x30
      [    2.929102]  psci_dt_attach_cpu+0x24/0x90
      [    2.933230]  psci_cpuidle_probe+0x2d4/0x46c
      [    2.937534]  platform_probe+0x68/0xe0
      [    2.941304]  really_probe.part.0+0x9c/0x2fc
      [    2.945605]  __driver_probe_device+0x98/0x144
      [    2.950085]  driver_probe_device+0x44/0x15c
      [    2.954385]  __device_attach_driver+0xb8/0x120
      [    2.958950]  bus_for_each_drv+0x78/0xd0
      [    2.962896]  __device_attach+0xd8/0x180
      [    2.966843]  device_initial_probe+0x14/0x20
      [    2.971144]  bus_probe_device+0x9c/0xa4
      [    2.975092]  device_add+0x380/0x88c
      [    2.978679]  platform_device_add+0x114/0x234
      [    2.983067]  platform_device_register_full+0x100/0x190
      [    2.988344]  psci_idle_init+0x6c/0xb0
      [    2.992113]  do_one_initcall+0x74/0x3a0
      [    2.996060]  kernel_init_freeable+0x2fc/0x384
      [    3.000543]  kernel_init+0x28/0x130
      [    3.004132]  ret_from_fork+0x10/0x20
      [    3.007817] irq event stamp: 319826
      [    3.011404] hardirqs last  enabled at (319825): [<ffffd40e7eda0268>] __up_console_sem+0x78/0x84
      [    3.020332] hardirqs last disabled at (319826): [<ffffd40e7fd6d9d8>] el1_dbg+0x24/0x8c
      [    3.028458] softirqs last  enabled at (318312): [<ffffd40e7ec90410>] _stext+0x410/0x588
      [    3.036678] softirqs last disabled at (318299): [<ffffd40e7ed1bf68>] __irq_exit_rcu+0x158/0x174
      [    3.045607] ---[ end trace 0000000000000000 ]---
      Signed-off-by: NDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      524bb1da
  2. 05 3月, 2022 1 次提交
  3. 26 2月, 2022 1 次提交
    • J
      RDMA/cma: Do not change route.addr.src_addr outside state checks · 22e9f710
      Jason Gunthorpe 提交于
      If the state is not idle then resolve_prepare_src() should immediately
      fail and no change to global state should happen. However, it
      unconditionally overwrites the src_addr trying to build a temporary any
      address.
      
      For instance if the state is already RDMA_CM_LISTEN then this will corrupt
      the src_addr and would cause the test in cma_cancel_operation():
      
                 if (cma_any_addr(cma_src_addr(id_priv)) && !id_priv->cma_dev)
      
      Which would manifest as this trace from syzkaller:
      
        BUG: KASAN: use-after-free in __list_add_valid+0x93/0xa0 lib/list_debug.c:26
        Read of size 8 at addr ffff8881546491e0 by task syz-executor.1/32204
      
        CPU: 1 PID: 32204 Comm: syz-executor.1 Not tainted 5.12.0-rc8-syzkaller #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        Call Trace:
         __dump_stack lib/dump_stack.c:79 [inline]
         dump_stack+0x141/0x1d7 lib/dump_stack.c:120
         print_address_description.constprop.0.cold+0x5b/0x2f8 mm/kasan/report.c:232
         __kasan_report mm/kasan/report.c:399 [inline]
         kasan_report.cold+0x7c/0xd8 mm/kasan/report.c:416
         __list_add_valid+0x93/0xa0 lib/list_debug.c:26
         __list_add include/linux/list.h:67 [inline]
         list_add_tail include/linux/list.h:100 [inline]
         cma_listen_on_all drivers/infiniband/core/cma.c:2557 [inline]
         rdma_listen+0x787/0xe00 drivers/infiniband/core/cma.c:3751
         ucma_listen+0x16a/0x210 drivers/infiniband/core/ucma.c:1102
         ucma_write+0x259/0x350 drivers/infiniband/core/ucma.c:1732
         vfs_write+0x28e/0xa30 fs/read_write.c:603
         ksys_write+0x1ee/0x250 fs/read_write.c:658
         do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
         entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      This is indicating that an rdma_id_private was destroyed without doing
      cma_cancel_listens().
      
      Instead of trying to re-use the src_addr memory to indirectly create an
      any address derived from the dst build one explicitly on the stack and
      bind to that as any other normal flow would do. rdma_bind_addr() will copy
      it over the src_addr once it knows the state is valid.
      
      This is similar to commit bc0bdc5a ("RDMA/cma: Do not change
      route.addr.src_addr.ss_family")
      
      Link: https://lore.kernel.org/r/0-v2-e975c8fd9ef2+11e-syz_cma_srcaddr_jgg@nvidia.com
      Cc: stable@vger.kernel.org
      Fixes: 732d41c5 ("RDMA/cma: Make the locking for automatic state transition more clear")
      Reported-by: syzbot+c94a3675a626f6333d74@syzkaller.appspotmail.com
      Reviewed-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      22e9f710
  4. 25 2月, 2022 6 次提交
  5. 24 2月, 2022 31 次提交