FAILED: patch "[PATCH] RDMA/core: Fix race between destroy and release FD object" failed to apply to 4.14-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f0abc761bbb9418876cc4d1ebc473e4ea6352e42 Mon Sep 17 00:00:00 2001
From: Leon Romanovsky <[email protected]>
Date: Thu, 23 Apr 2020 09:01:22 +0300
Subject: [PATCH] RDMA/core: Fix race between destroy and release FD object
The call to ->lookup_put() was too early and it caused an unlock of the read/write protection of the uobject after the FD was put. This allows a race:
CPU1 CPU2
rdma_lookup_put_uobject()
lookup_put_fd_uobject()
fput() fput() uverbs_uobject_fd_release() WARN_ON(uverbs_try_lock_object(uobj, UVERBS_LOOKUP_WRITE));
atomic_dec(usecnt)
Fix the code by changing the order, first unlock and call to ->lookup_put() after that.
drivers/infiniband/core/rdma_core.c +1 -1
@@ -678,7 +678,6 @@ void rdma_lookup_put_uobject(struct ib_uobject *uobj, enum rdma_lookup_mode mode) {assert_uverbs_usecnt (uobj, mode); - uobj->uapi_object->type_class->lookup_put (uobj, mode);/* * In order to unlock an object, either decrease its usecnt for * read access or zero it in case of exclusive access. See
@@ -695,6 +694,7 @@ void rdma_lookup_put_uobject(struct ib_uobject *uobj,break ; } + uobj->uapi_object->type_class->lookup_put (uobj, mode);/* Pairs with the kref obtained by type->lookup_get */ uverbs_uobject_put (uobj); }