1. 22 4月, 2021 2 次提交
  2. 13 4月, 2021 2 次提交
  3. 26 3月, 2021 1 次提交
    • M
      RDMA: Support more than 255 rdma ports · 1fb7f897
      Mark Bloch 提交于
      Current code uses many different types when dealing with a port of a RDMA
      device: u8, unsigned int and u32. Switch to u32 to clean up the logic.
      
      This allows us to make (at least) the core view consistent and use the
      same type. Unfortunately not all places can be converted. Many uverbs
      functions expect port to be u8 so keep those places in order not to break
      UAPIs.  HW/Spec defined values must also not be changed.
      
      With the switch to u32 we now can support devices with more than 255
      ports. U32_MAX is reserved to make control logic a bit easier to deal
      with. As a device with U32_MAX ports probably isn't going to happen any
      time soon this seems like a non issue.
      
      When a device with more than 255 ports is created uverbs will report the
      RDMA device as having 255 ports as this is the max currently supported.
      
      The verbs interface is not changed yet because the IBTA spec limits the
      port size in too many places to be u8 and all applications that relies in
      verbs won't be able to cope with this change. At this stage, we are
      extending the interfaces that are using vendor channel solely
      
      Once the limitation is lifted mlx5 in switchdev mode will be able to have
      thousands of SFs created by the device. As the only instance of an RDMA
      device that reports more than 255 ports will be a representor device and
      it exposes itself as a RAW Ethernet only device CM/MAD/IPoIB and other
      ULPs aren't effected by this change and their sysfs/interfaces that are
      exposes to userspace can remain unchanged.
      
      While here cleanup some alignment issues and remove unneeded sanity
      checks (mainly in rdmavt),
      
      Link: https://lore.kernel.org/r/20210301070420.439400-1-leon@kernel.orgSigned-off-by: NMark Bloch <mbloch@nvidia.com>
      Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      1fb7f897
  4. 22 3月, 2021 1 次提交
  5. 11 3月, 2021 1 次提交
  6. 17 2月, 2021 2 次提交
    • A
      RDMA/ucma: Fix use-after-free bug in ucma_create_uevent · fe454dc3
      Avihai Horon 提交于
      ucma_process_join() allocates struct ucma_multicast mc and frees it if an
      error occurs during its run.  Specifically, if an error occurs in
      copy_to_user(), a use-after-free might happen in the following scenario:
      
      1. mc struct is allocated.
      2. rdma_join_multicast() is called and succeeds. During its run,
         cma_iboe_join_multicast() enqueues a work that will later use the
         aforementioned mc struct.
      3. copy_to_user() is called and fails.
      4. mc struct is deallocated.
      5. The work that was enqueued by cma_iboe_join_multicast() is run and
         calls ucma_create_uevent() which tries to access mc struct (which is
         freed by now).
      
      Fix this bug by cancelling the work enqueued by cma_iboe_join_multicast().
      Since cma_work_handler() frees struct cma_work, we don't use it in
      cma_iboe_join_multicast() so we can safely cancel the work later.
      
      The following syzkaller report revealed it:
      
         BUG: KASAN: use-after-free in ucma_create_uevent+0x2dd/0x;3f0 drivers/infiniband/core/ucma.c:272
         Read of size 8 at addr ffff88810b3ad110 by task kworker/u8:1/108
      
         CPU: 1 PID: 108 Comm: kworker/u8:1 Not tainted 5.10.0-rc6+ #257
         Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS   rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
         Workqueue: rdma_cm cma_work_handler
         Call Trace:
          __dump_stack lib/dump_stack.c:77 [inline]
          dump_stack+0xbe/0xf9 lib/dump_stack.c:118
          print_address_description.constprop.0+0x3e/0×60 mm/kasan/report.c:385
          __kasan_report mm/kasan/report.c:545 [inline]
          kasan_report.cold+0x1f/0×37 mm/kasan/report.c:562
          ucma_create_uevent+0x2dd/0×3f0 drivers/infiniband/core/ucma.c:272
          ucma_event_handler+0xb7/0×3c0 drivers/infiniband/core/ucma.c:349
          cma_cm_event_handler+0x5d/0×1c0 drivers/infiniband/core/cma.c:1977
          cma_work_handler+0xfa/0×190 drivers/infiniband/core/cma.c:2718
          process_one_work+0x54c/0×930 kernel/workqueue.c:2272
          worker_thread+0x82/0×830 kernel/workqueue.c:2418
          kthread+0x1ca/0×220 kernel/kthread.c:292
          ret_from_fork+0x1f/0×30 arch/x86/entry/entry_64.S:296
      
         Allocated by task 359:
           kasan_save_stack+0x1b/0×40 mm/kasan/common.c:48
           kasan_set_track mm/kasan/common.c:56 [inline]
           __kasan_kmalloc mm/kasan/common.c:461 [inline]
           __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:434
           kmalloc include/linux/slab.h:552 [inline]
           kzalloc include/linux/slab.h:664 [inline]
           ucma_process_join+0x16e/0×3f0 drivers/infiniband/core/ucma.c:1453
           ucma_join_multicast+0xda/0×140 drivers/infiniband/core/ucma.c:1538
           ucma_write+0x1f7/0×280 drivers/infiniband/core/ucma.c:1724
           vfs_write fs/read_write.c:603 [inline]
           vfs_write+0x191/0×4c0 fs/read_write.c:585
           ksys_write+0x1a1/0×1e0 fs/read_write.c:658
           do_syscall_64+0x2d/0×40 arch/x86/entry/common.c:46
           entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
         Freed by task 359:
           kasan_save_stack+0x1b/0×40 mm/kasan/common.c:48
           kasan_set_track+0x1c/0×30 mm/kasan/common.c:56
           kasan_set_free_info+0x1b/0×30 mm/kasan/generic.c:355
           __kasan_slab_free+0x112/0×160 mm/kasan/common.c:422
           slab_free_hook mm/slub.c:1544 [inline]
           slab_free_freelist_hook mm/slub.c:1577 [inline]
           slab_free mm/slub.c:3142 [inline]
           kfree+0xb3/0×3e0 mm/slub.c:4124
           ucma_process_join+0x22d/0×3f0 drivers/infiniband/core/ucma.c:1497
           ucma_join_multicast+0xda/0×140 drivers/infiniband/core/ucma.c:1538
           ucma_write+0x1f7/0×280 drivers/infiniband/core/ucma.c:1724
           vfs_write fs/read_write.c:603 [inline]
           vfs_write+0x191/0×4c0 fs/read_write.c:585
           ksys_write+0x1a1/0×1e0 fs/read_write.c:658
           do_syscall_64+0x2d/0×40 arch/x86/entry/common.c:46
           entry_SYSCALL_64_after_hwframe+0x44/0xa9
           The buggy address belongs to the object at ffff88810b3ad100
           which belongs to the cache kmalloc-192 of size 192
           The buggy address is located 16 bytes inside of
           192-byte region [ffff88810b3ad100, ffff88810b3ad1c0)
      
      Fixes: b5de0c60 ("RDMA/cma: Fix use after free race in roce multicast join")
      Link: https://lore.kernel.org/r/20210211090517.1278415-1-leon@kernel.orgReported-by: NAmit Matityahu <mitm@nvidia.com>
      Signed-off-by: NAvihai Horon <avihaih@nvidia.com>
      Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      fe454dc3
    • C
      RDMA/ipoib: Remove racy Subnet Manager sendonly join checks · 633d6102
      Christoph Lameter 提交于
      When a system receives a REREG event from the SM, then the SM information
      in the kernel is marked as invalid and a request is sent to the SM to
      update the information. The SM information is invalid in that time period.
      
      However, receiving a REREG also occurs simultaneously in user space
      applications that are now trying to rejoin the multicast groups. Some of
      those may be sendonly multicast groups which are then failing.
      
      If the SM information is invalid then ib_sa_sendonly_fullmem_support()
      returns false. That is wrong because it just means that we do not know yet
      if the potentially new SM supports sendonly joins.
      
      Sendonly join was introduced in 2015 and all the Subnet managers have
      supported it ever since. So there is no point in checking if a subnet
      manager supports it.
      
      Should an old opensm get a request for a sendonly join then the request
      will fail. The code that is removed here accomodated that situation and
      fell back to a full join.
      
      Falling back to a full join is problematic in itself. The reason to use
      the sendonly join was to reduce the traffic on the Infiniband fabric
      otherwise one could have just stayed with the regular join.  So this patch
      may cause users of very old opensms to discover that lots of traffic
      needlessly crosses their IB fabrics.
      
      Link: https://lore.kernel.org/r/alpine.DEB.2.22.394.2101281845160.13303@www.lameter.comSigned-off-by: NChristoph Lameter <cl@linux.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      633d6102
  7. 15 12月, 2020 1 次提交
    • L
      RDMA/cma: Don't overwrite sgid_attr after device is released · e246b7c0
      Leon Romanovsky 提交于
      As part of the cma_dev release, that pointer will be set to NULL.  In case
      it happens in rdma_bind_addr() (part of an error flow), the next call to
      addr_handler() will have a call to cma_acquire_dev_by_src_ip() which will
      overwrite sgid_attr without releasing it.
      
        WARNING: CPU: 2 PID: 108 at drivers/infiniband/core/cma.c:606 cma_bind_sgid_attr drivers/infiniband/core/cma.c:606 [inline]
        WARNING: CPU: 2 PID: 108 at drivers/infiniband/core/cma.c:606 cma_acquire_dev_by_src_ip+0x470/0x4b0 drivers/infiniband/core/cma.c:649
        CPU: 2 PID: 108 Comm: kworker/u8:1 Not tainted 5.10.0-rc6+ #257
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
        Workqueue: ib_addr process_one_req
        RIP: 0010:cma_bind_sgid_attr drivers/infiniband/core/cma.c:606 [inline]
        RIP: 0010:cma_acquire_dev_by_src_ip+0x470/0x4b0 drivers/infiniband/core/cma.c:649
        Code: 66 d9 4a ff 4d 8b 6e 10 49 8d bd 1c 08 00 00 e8 b6 d6 4a ff 45 0f b6 bd 1c 08 00 00 41 83 e7 01 e9 49 fd ff ff e8 90 c5 29 ff <0f> 0b e9 80 fe ff ff e8 84 c5 29 ff 4c 89 f7 e8 2c d9 4a ff 4d 8b
        RSP: 0018:ffff8881047c7b40 EFLAGS: 00010293
        RAX: ffff888104789c80 RBX: 0000000000000001 RCX: ffffffff820b8ef8
        RDX: 0000000000000000 RSI: ffffffff820b9080 RDI: ffff88810cd4c998
        RBP: ffff8881047c7c08 R08: ffff888104789c80 R09: ffffed10209f4036
        R10: ffff888104fa01ab R11: ffffed10209f4035 R12: ffff88810cd4c800
        R13: ffff888105750e28 R14: ffff888108f0a100 R15: ffff88810cd4c998
        FS:  0000000000000000(0000) GS:ffff888119c00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000000 CR3: 0000000104e60005 CR4: 0000000000370ea0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        Call Trace:
         addr_handler+0x266/0x350 drivers/infiniband/core/cma.c:3190
         process_one_req+0xa3/0x300 drivers/infiniband/core/addr.c:645
         process_one_work+0x54c/0x930 kernel/workqueue.c:2272
         worker_thread+0x82/0x830 kernel/workqueue.c:2418
         kthread+0x1ca/0x220 kernel/kthread.c:292
         ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
      
      Fixes: ff11c6cd ("RDMA/cma: Introduce and use cma_acquire_dev_by_src_ip()")
      Link: https://lore.kernel.org/r/20201213132940.345554-5-leon@kernel.orgSigned-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: NJason Gunthorpe <jgg@nvidia.com>
      e246b7c0
  8. 25 11月, 2020 1 次提交
  9. 17 11月, 2020 1 次提交
  10. 28 10月, 2020 1 次提交
  11. 02 10月, 2020 1 次提交
  12. 29 9月, 2020 1 次提交
  13. 23 9月, 2020 4 次提交
  14. 17 9月, 2020 8 次提交
  15. 27 8月, 2020 1 次提交
  16. 24 8月, 2020 1 次提交
  17. 30 7月, 2020 4 次提交
  18. 18 6月, 2020 1 次提交
    • M
      RDMA/cma: Protect bind_list and listen_list while finding matching cm id · 730c8912
      Mark Zhang 提交于
      The bind_list and listen_list must be accessed under a lock, add the
      missing locking around the access in cm_ib_id_from_event()
      
      In addition add lockdep asserts to make it clearer what the locking
      semantic is here.
      
        general protection fault: 0000 [#1] SMP NOPTI
        CPU: 226 PID: 126135 Comm: kworker/226:1 Tainted: G OE 4.12.14-150.47-default #1 SLE15
        Hardware name: Cray Inc. Windom/Windom, BIOS 0.8.7 01-10-2020
        Workqueue: ib_cm cm_work_handler [ib_cm]
        task: ffff9c5a60a1d2c0 task.stack: ffffc1d91f554000
        RIP: 0010:cma_ib_req_handler+0x3f1/0x11b0 [rdma_cm]
        RSP: 0018:ffffc1d91f557b40 EFLAGS: 00010286
        RAX: deacffffffffff30 RBX: 0000000000000001 RCX: ffff9c2af5bb6000
        RDX: 00000000000000a9 RSI: ffff9c5aa4ed2f10 RDI: ffffc1d91f557b08
        RBP: ffffc1d91f557d90 R08: ffff9c340cc80000 R09: ffff9c2c0f901900
        R10: 0000000000000000 R11: 0000000000000001 R12: deacffffffffff30
        R13: ffff9c5a48aeec00 R14: ffffc1d91f557c30 R15: ffff9c5c2eea3688
        FS: 0000000000000000(0000) GS:ffff9c5c2fa80000(0000) knlGS:0000000000000000
        CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00002b5cc03fa320 CR3: 0000003f8500a000 CR4: 00000000003406e0
        Call Trace:
        ? rdma_addr_cancel+0xa0/0xa0 [ib_core]
        ? cm_process_work+0x28/0x140 [ib_cm]
        cm_process_work+0x28/0x140 [ib_cm]
        ? cm_get_bth_pkey.isra.44+0x34/0xa0 [ib_cm]
        cm_work_handler+0xa06/0x1a6f [ib_cm]
        ? __switch_to_asm+0x34/0x70
        ? __switch_to_asm+0x34/0x70
        ? __switch_to_asm+0x40/0x70
        ? __switch_to_asm+0x34/0x70
        ? __switch_to_asm+0x40/0x70
        ? __switch_to_asm+0x34/0x70
        ? __switch_to_asm+0x40/0x70
        ? __switch_to+0x7c/0x4b0
        ? __switch_to_asm+0x40/0x70
        ? __switch_to_asm+0x34/0x70
        process_one_work+0x1da/0x400
        worker_thread+0x2b/0x3f0
        ? process_one_work+0x400/0x400
        kthread+0x118/0x140
        ? kthread_create_on_node+0x40/0x40
        ret_from_fork+0x22/0x40
        Code: 00 66 83 f8 02 0f 84 ca 05 00 00 49 8b 84 24 d0 01 00 00 48 85 c0 0f 84 68 07 00 00 48 2d d0 01
        00 00 49 89 c4 0f 84 59 07 00 00 <41> 0f b7 44 24 20 49 8b 77 50 66 83 f8 0a 75 9e 49 8b 7c 24 28
      
      Fixes: 4c21b5bc ("IB/cma: Add net_dev and private data checks to RDMA CM")
      Link: https://lore.kernel.org/r/20200616104304.2426081-1-leon@kernel.orgSigned-off-by: NMark Zhang <markz@mellanox.com>
      Reviewed-by: NMaor Gottlieb <maorg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      730c8912
  19. 03 6月, 2020 1 次提交
    • C
      RDMA/core: Move and rename trace_cm_id_create() · 278f74b3
      Chuck Lever 提交于
      The restrack ID for an rdma_cm_id is not assigned until it is
      associated with a device.
      
      Here's an example I captured while testing NFS/RDMA's support for
      DEVICE_REMOVAL. The new tracepoint name is "cm_id_attach".
      
                 <...>-4261  [001]   366.581299: cm_event_handler:     cm.id=0 src=0.0.0.0:45919 dst=192.168.2.55:20049 tos=0 ADDR_ERROR (1/-19)
                 <...>-4261  [001]   366.581304: cm_event_done:        cm.id=0 src=0.0.0.0:45919 dst=192.168.2.55:20049 tos=0 ADDR_ERROR consumer returns 0
                 <...>-1950  [000]   366.581309: cm_id_destroy:        cm.id=0 src=0.0.0.0:45919 dst=192.168.2.55:20049 tos=0
                 <...>-7     [001]   369.589400: cm_event_handler:     cm.id=0 src=0.0.0.0:49023 dst=192.168.2.55:20049 tos=0 ADDR_ERROR (1/-19)
                 <...>-7     [001]   369.589404: cm_event_done:        cm.id=0 src=0.0.0.0:49023 dst=192.168.2.55:20049 tos=0 ADDR_ERROR consumer returns 0
                 <...>-1950  [000]   369.589407: cm_id_destroy:        cm.id=0 src=0.0.0.0:49023 dst=192.168.2.55:20049 tos=0
                 <...>-4261  [001]   372.597650: cm_id_attach:         cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 device=mlx4_0
                 <...>-4261  [001]   372.597652: cm_event_handler:     cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 ADDR_RESOLVED (0/0)
                 <...>-4261  [001]   372.597654: cm_event_done:        cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 ADDR_RESOLVED consumer returns 0
                 <...>-4261  [001]   372.597738: cm_event_handler:     cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 ROUTE_RESOLVED (2/0)
                 <...>-4261  [001]   372.597740: cm_event_done:        cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 ROUTE_RESOLVED consumer returns 0
                 <...>-4691  [007]   372.600101: cm_qp_create:         cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 pd.id=2 qp_type=RC send_wr=4091 recv_wr=256 qp_num=530 rc=0
                 <...>-4691  [007]   372.600207: cm_send_req:          cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 qp_num=530
                 <...>-185   [002]   372.601212: cm_send_mra:          cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0
                 <...>-185   [002]   372.601362: cm_send_rtu:          cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0
                 <...>-185   [002]   372.601372: cm_event_handler:     cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 ESTABLISHED (9/0)
                 <...>-185   [002]   372.601379: cm_event_done:        cm.id=0 src=192.168.2.51:47492 dst=192.168.2.55:20049 tos=0 ESTABLISHED consumer returns 0
      
      Fixes: ed999f82 ("RDMA/cma: Add trace points in RDMA Connection Manager")
      Link: https://lore.kernel.org/r/20200530174934.21362.56754.stgit@manet.1015granger.netSigned-off-by: NChuck Lever <chuck.lever@oracle.com>
      Reviewed-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      278f74b3
  20. 28 5月, 2020 4 次提交
  21. 07 5月, 2020 1 次提交