Spdk/test/unit/lib/bdev
Nathan Claudel d0038b70df bdev: fix use-after-free in bdev registration
When a bdev is registered, it is examined by the bdev modules before the
bdev register even is notified.

Examination may be asychronous, e.g. when the bdev module has to perform
I/O on the new bdev.

This causes a race condition where the bdev might be destroyed while
examination is not finished. Then, once all modules have signaled that
examination is done, `bdev_register_finished` makes an invalid access to
the freed bdev pointer.

To fix this, defer the unregistration until the examine is completed by
opening a descriptor on the bdev.

Change-Id: I79a2faa96c1c893fc1cee645fbe31f689b03ea4a
Signed-off-by: Nathan Claudel <nclaudel@kalray.eu>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13630
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-07-22 06:40:10 +00:00
..
bdev_zone.c Replace most BSD 3-clause license text with SPDX identifier. 2022-06-09 07:35:12 +00:00
bdev.c bdev: fix use-after-free in bdev registration 2022-07-22 06:40:10 +00:00
compress.c check_format: For C files only, fix return type breaks 2022-06-27 09:33:48 +00:00
crypto.c check_format: For C files only, fix return type breaks 2022-06-27 09:33:48 +00:00
gpt Replace most BSD 3-clause license text with SPDX identifier. 2022-06-09 07:35:12 +00:00
mt Replace most BSD 3-clause license text with SPDX identifier. 2022-06-09 07:35:12 +00:00
nvme check_format: For C files only, fix return type breaks 2022-06-27 09:33:48 +00:00
part.c Replace most BSD 3-clause license text with SPDX identifier. 2022-06-09 07:35:12 +00:00
pmem Replace most BSD 3-clause license text with SPDX identifier. 2022-06-09 07:35:12 +00:00
raid raid/concat: update bdev readv/writev to ext API. 2022-07-14 09:46:56 +00:00
scsi_nvme.c Replace most BSD 3-clause license text with SPDX identifier. 2022-06-09 07:35:12 +00:00
vbdev_lvol.c blobstore: implement spdk_bs_grow and bdev_lvol_grow_lvstore RPC 2022-06-28 17:55:43 +00:00
vbdev_zone_block.c check_format: For C files only, fix return type breaks 2022-06-27 09:33:48 +00:00
Makefile Replace most BSD 3-clause license text with SPDX identifier. 2022-06-09 07:35:12 +00:00