OSDN Git Service

RDMA/core: Use READ_ONCE for ib_ufile.async_file
authorJason Gunthorpe <jgg@mellanox.com>
Wed, 8 Jan 2020 17:22:06 +0000 (19:22 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 13 Jan 2020 20:20:16 +0000 (16:20 -0400)
commit5c55cfd6a553d008fcd54e4a4e3fed1340ee5090
tree0dd95d4166c15b2bee2fbb220f9f0d5e7d12d08f
parent3e032c0e92aa0c4c0b46c5e2d6d41706c8fce488
RDMA/core: Use READ_ONCE for ib_ufile.async_file

The writer for async_file holds the ucontext_lock, while the readers are
left unlocked. Most readers rely on an implicit locking, either by having
a uobject (which cannot be created before a context) or by holding the
ib_ufile kref.

However ib_uverbs_free_hw_resources() has no implicit lock and has a
possible race. Make this all clear and sane by using READ_ONCE
consistently.

Link: https://lore.kernel.org/r/1578504126-9400-15-git-send-email-yishaih@mellanox.com
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/uverbs.h
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/core/uverbs_std_types.c
drivers/infiniband/core/uverbs_std_types_cq.c