Commit f7c4d9b
committed
rbd: avoid use-after-free in do_rbd_add() when rbd_dev_create() fails
If getting an ID or setting up a work queue in rbd_dev_create() fails,
use-after-free on rbd_dev->rbd_client, rbd_dev->spec and rbd_dev->opts
is triggered in do_rbd_add(). The root cause is that the ownership of
these structures is transfered to rbd_dev prematurely and they all end
up getting freed when rbd_dev_create() calls rbd_dev_free() prior to
returning to do_rbd_add().
Found by Linux Verification Center (linuxtesting.org) with SVACE, an
incomplete patch submitted by Natalia Petrova <n.petrova@fintech.ru>.
Cc: stable@vger.kernel.org
Fixes: 1643dfa ("rbd: introduce a per-device ordered workqueue")
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>1 parent e027253 commit f7c4d9b
1 file changed
Lines changed: 9 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5292 | 5292 | | |
5293 | 5293 | | |
5294 | 5294 | | |
5295 | | - | |
5296 | | - | |
| 5295 | + | |
5297 | 5296 | | |
5298 | 5297 | | |
5299 | 5298 | | |
| |||
5338 | 5337 | | |
5339 | 5338 | | |
5340 | 5339 | | |
5341 | | - | |
5342 | | - | |
5343 | | - | |
5344 | 5340 | | |
5345 | 5341 | | |
5346 | 5342 | | |
| |||
5353 | 5349 | | |
5354 | 5350 | | |
5355 | 5351 | | |
5356 | | - | |
| 5352 | + | |
5357 | 5353 | | |
5358 | 5354 | | |
5359 | 5355 | | |
5360 | | - | |
5361 | | - | |
5362 | 5356 | | |
5363 | 5357 | | |
5364 | 5358 | | |
| |||
5375 | 5369 | | |
5376 | 5370 | | |
5377 | 5371 | | |
| 5372 | + | |
| 5373 | + | |
| 5374 | + | |
| 5375 | + | |
5378 | 5376 | | |
5379 | 5377 | | |
5380 | 5378 | | |
| |||
6736 | 6734 | | |
6737 | 6735 | | |
6738 | 6736 | | |
6739 | | - | |
| 6737 | + | |
6740 | 6738 | | |
6741 | 6739 | | |
6742 | 6740 | | |
| |||
6746 | 6744 | | |
6747 | 6745 | | |
6748 | 6746 | | |
6749 | | - | |
6750 | | - | |
| 6747 | + | |
| 6748 | + | |
6751 | 6749 | | |
6752 | 6750 | | |
6753 | 6751 | | |
| |||
0 commit comments