1. 27 11月, 2018 5 次提交
  2. 23 11月, 2018 10 次提交
    • P
      RDMA/core: Sync unregistration with netlink commands · 01b67117
      Parav Pandit 提交于
      When the rdma device is getting removed, get resource info can race with
      device removal, as below:
      
            CPU-0                                  CPU-1
          --------                               --------
          rdma_nl_rcv_msg()
             nldev_res_get_cq_dumpit()
                mutex_lock(device_lock);
                get device reference
                mutex_unlock(device_lock);        [..]
                                                  ib_unregister_device()
                                                  /* Valid reference to
                                                   * device->dev exists.
                                                   */
                                                   ib_dealloc_device()
      
                [..]
                provider->fill_res_entry();
      
      Even though device object is not freed, fill_res_entry() can get called on
      device which doesn't have a driver anymore. Kernel core device reference
      count is not sufficient, as this only keeps the structure valid, and
      doesn't guarantee the driver is still loaded.
      
      Similar race can occur with device renaming and device removal, where
      device_rename() tries to rename a unregistered device. While this is fine
      for devices of a class which are not net namespace aware, but it is
      incorrect for net namespace aware class coming in subsequent series.  If a
      class is net namespace aware, then the below [1] call trace is observed in
      above situation.
      
      Therefore, to avoid the race, keep a reference count and let device
      unregistration wait until all netlink users drop the reference.
      
      [1] Call trace:
      kernfs: ns required in 'infiniband' for 'mlx5_0'
      WARNING: CPU: 18 PID: 44270 at fs/kernfs/dir.c:842 kernfs_find_ns+0x104/0x120
      libahci i2c_core mlxfw libata dca [last unloaded: devlink]
      RIP: 0010:kernfs_find_ns+0x104/0x120
      Call Trace:
      kernfs_find_and_get_ns+0x2e/0x50
      sysfs_rename_link_ns+0x40/0xb0
      device_rename+0xb2/0xf0
      ib_device_rename+0xb3/0x100 [ib_core]
      nldev_set_doit+0x165/0x190 [ib_core]
      rdma_nl_rcv_msg+0x249/0x250 [ib_core]
      ? netlink_deliver_tap+0x8f/0x3e0
      rdma_nl_rcv+0xd6/0x120 [ib_core]
      netlink_unicast+0x17c/0x230
      netlink_sendmsg+0x2f0/0x3e0
      sock_sendmsg+0x30/0x40
      __sys_sendto+0xdc/0x160
      
      Fixes: da5c8507 ("RDMA/nldev: add driver-specific resource tracking")
      Signed-off-by: NParav Pandit <parav@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      01b67117
    • P
      RDMA/cma: Move cma module specific functions to cma_priv.h · eeb8df87
      Parav Pandit 提交于
      Currently several rdma_cm module specific functions are declared in
      core_priv.h file. Now that we have cma_priv.h file specific to rdma_cm
      kernel module, move them from core_priv.h to cma_priv.h
      Signed-off-by: NParav Pandit <parav@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      eeb8df87
    • J
      RDMA/uverbs: Check for NULL driver methods for every write call · a140692a
      Jason Gunthorpe 提交于
      Add annotations to the uverbs_api structure indicating which driver
      methods are called by the implementation. If the required method
      is NULL the write API will be not be callable.
      
      This effectively duplicates the cmd_mask system, however it does it by
      expressing invariants required by the core code, not by delegating
      decision making to the driver. This is another step toward eliminating
      cmd_mask.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      a140692a
    • J
      RDMA/uverbs: Make all the method functions in uverbs_cmd static · 1de751ca
      Jason Gunthorpe 提交于
      Now that we use struct uverbs_uapi to link the method functions to the
      dispatcher there is no reason to have them be extern symbols.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      1de751ca
    • J
      RDMA/uverbs: Convert the write interface to use uverbs_api · d120c3c9
      Jason Gunthorpe 提交于
      This organizes the write commands into objects and links them to the
      uverbs_api data structure. The command path is reworked to use uapi
      instead of its internal structures.
      
      The command mask is moved from a runtime check to a registration time
      check in the uapi.
      
      Since the write interface does not have the object ID as part of the
      command, the radix bins are converted into linear lists to support the
      lookup.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      d120c3c9
    • J
      RDMA/verbs: Store the write/write_ex uapi entry points in the uverbs_api · 6884c6c4
      Jason Gunthorpe 提交于
      Bringing all uapi entry points into one place lets us deal with them
      consistently. For instance the write, write_ex and ioctl paths can be
      disabled when an API is not supported by the driver.
      
      This will replace the uverbs_cmd_table static arrays.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      6884c6c4
    • J
      RDMA/uverbs: Require all objects to have a driver destroy function · 0bd01f3d
      Jason Gunthorpe 提交于
      If we can't destroy the object then we certainly shouldn't allow it be
      created or used. Remove it from the uverbs_uapi in this case.
      
      This also disables methods of other objects that have mandatory object
      handle inputs - ie REG_DM_MR is now automatically removed if DM objects
      cannot be created.
      
      Typically drivers not supporting an interface will mark all of the
      supporting functions as NULL, including destroy.
      
      This is intended to automatically eliminate entire corner cases in the API
      that are difficult to test.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      0bd01f3d
    • J
      RDMA/uverbs: Add helpers to mark uapi functions as unsupported · 6829c1c2
      Jason Gunthorpe 提交于
      We have many cases where parts of the uapi are not supported in a driver,
      needs a certain protocol, or whatever. It is best to reflect this directly
      into the struct uverbs_api when it is built so that everything is simply
      blocked off, and future introspection can report a proper supported list.
      
      This is done by adding some additional helpers to the definition list
      language that disable objects based on a 'supported' call back, and a
      helper that disables based on a NULL struct ib_device function pointer.
      
      Disablement is global. For instance, if a driver disables an object then
      everything connected to that object is removed, including core methods.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      6829c1c2
    • J
      RDMA/uverbs: Factor out the add/get pattern into a helper · c27f6aa8
      Jason Gunthorpe 提交于
      The next patch needs another copy of this, provide a simple helper to
      reduce the coding. uapi_add_get_elm() returns an existing entry or adds a
      new one.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      c27f6aa8
    • J
      RDMA/uverbs: Use a linear list to describe the compiled-in uapi · 0cbf432d
      Jason Gunthorpe 提交于
      The 'tree' data structure is very hard to build at compile time, and this
      makes it very limited. The new radix tree based compiler can handle a more
      complex input language that does not require the compiler to perfectly
      group everything into a neat tree structure.
      
      Instead use a simple list to describe to input, where the list elements
      can be of various different 'opcodes' instructing the radix compiler what
      to do. Start out with opcodes chaining to other definition lists and
      chaining to the existing 'tree' definition.
      
      Replace the very top level of the 'object tree' with this list type and
      get rid of struct uverbs_object_tree_def and DECLARE_UVERBS_OBJECT_TREE.
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      0cbf432d
  3. 22 11月, 2018 1 次提交
  4. 13 11月, 2018 1 次提交
  5. 18 10月, 2018 1 次提交
  6. 17 10月, 2018 14 次提交
  7. 16 10月, 2018 3 次提交
    • G
      IB/ucm: Fix Spectre v1 vulnerability · 0295e395
      Gustavo A. R. Silva 提交于
      hdr.cmd can be indirectly controlled by user-space, hence leading to
      a potential exploitation of the Spectre variant 1 vulnerability.
      
      This issue was detected with the help of Smatch:
      
      drivers/infiniband/core/ucm.c:1127 ib_ucm_write() warn: potential
      spectre issue 'ucm_cmd_table' [r] (local cap)
      
      Fix this by sanitizing hdr.cmd before using it to index
      ucm_cmd_table.
      
      Notice that given that speculation windows are large, the policy is
      to kill the speculation on the first load and not worry if it can be
      completed with a dependent load/store [1].
      
      [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NDoug Ledford <dledford@redhat.com>
      0295e395
    • L
      RDMA/cm: Respect returned status of cm_init_av_by_path · e54b6a3b
      Leon Romanovsky 提交于
      Add missing check for failure of cm_init_av_by_path
      
      Fixes: e1444b5a ("IB/cm: Fix automatic path migration support")
      Reported-by: NSlava Shwartsman <slavash@mellanox.com>
      Reviewed-by: NParav Pandit <parav@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      e54b6a3b
    • L
      RDMA/restrack: Protect from reentry to resource return path · fe9bc164
      Leon Romanovsky 提交于
      Nullify the resource task struct pointer to ensure that subsequent calls
      won't try to release task_struct again.
      
      ------------[ cut here ]------------
      ODEBUG: free active (active state 1) object type: rcu_head hint:
      (null)
      WARNING: CPU: 0 PID: 6048 at lib/debugobjects.c:329
      debug_print_object+0x16a/0x210 lib/debugobjects.c:326
      Kernel panic - not syncing: panic_on_warn set ...
      
      CPU: 0 PID: 6048 Comm: syz-executor022 Not tainted
      4.19.0-rc7-next-20181008+ #89
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      Call Trace:
        __dump_stack lib/dump_stack.c:77 [inline]
        dump_stack+0x244/0x3ab lib/dump_stack.c:113
        panic+0x238/0x4e7 kernel/panic.c:184
        __warn.cold.8+0x163/0x1ba kernel/panic.c:536
        report_bug+0x254/0x2d0 lib/bug.c:186
        fixup_bug arch/x86/kernel/traps.c:178 [inline]
        do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:271
        do_invalid_op+0x36/0x40 arch/x86/kernel/traps.c:290
        invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:969
      RIP: 0010:debug_print_object+0x16a/0x210 lib/debugobjects.c:326
      Code: 41 88 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 92 00 00 00 48 8b 14
      dd
      60 02 41 88 4c 89 fe 48 c7 c7 00 f8 40 88 e8 36 2f b4 fd <0f> 0b 83 05
      a9
      f4 5e 06 01 48 83 c4 18 5b 41 5c 41 5d 41 5e 41 5f
      RSP: 0018:ffff8801d8c3eda8 EFLAGS: 00010086
      RAX: 0000000000000000 RBX: 0000000000000003 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: ffffffff8164d235 RDI: 0000000000000005
      RBP: ffff8801d8c3ede8 R08: ffff8801d70aa280 R09: ffffed003b5c3eda
      R10: ffffed003b5c3eda R11: ffff8801dae1f6d7 R12: 0000000000000001
      R13: ffffffff8939a760 R14: 0000000000000000 R15: ffffffff8840fca0
        __debug_check_no_obj_freed lib/debugobjects.c:786 [inline]
        debug_check_no_obj_freed+0x3ae/0x58d lib/debugobjects.c:818
        kmem_cache_free+0x202/0x290 mm/slab.c:3759
        free_task_struct kernel/fork.c:163 [inline]
        free_task+0x16e/0x1f0 kernel/fork.c:457
        __put_task_struct+0x2e6/0x620 kernel/fork.c:730
        put_task_struct include/linux/sched/task.h:96 [inline]
        finish_task_switch+0x66c/0x900 kernel/sched/core.c:2715
        context_switch kernel/sched/core.c:2834 [inline]
        __schedule+0x8d7/0x21d0 kernel/sched/core.c:3480
        schedule+0xfe/0x460 kernel/sched/core.c:3524
        freezable_schedule include/linux/freezer.h:172 [inline]
        futex_wait_queue_me+0x3f9/0x840 kernel/futex.c:2530
        futex_wait+0x45c/0xa50 kernel/futex.c:2645
        do_futex+0x31a/0x26d0 kernel/futex.c:3528
        __do_sys_futex kernel/futex.c:3589 [inline]
        __se_sys_futex kernel/futex.c:3557 [inline]
        __x64_sys_futex+0x472/0x6a0 kernel/futex.c:3557
        do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x446549
      Code: e8 2c b3 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7
      48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff
      ff 0f 83 2b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007f3a998f5da8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
      RAX: ffffffffffffffda RBX: 00000000006dbc38 RCX: 0000000000446549
      RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00000000006dbc38
      RBP: 00000000006dbc30 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc3c
      R13: 2f646e6162696e69 R14: 666e692f7665642f R15: 00000000006dbd2c
      Kernel Offset: disabled
      
      Reported-by: syzbot+71aff6ea121ffefc280f@syzkaller.appspotmail.com
      Fixes: ed7a01fd ("RDMA/restrack: Release task struct which was hold by CM_ID object")
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      fe9bc164
  8. 11 10月, 2018 2 次提交
  9. 06 10月, 2018 3 次提交