Patch "drbd: use after free in drbd_create_device()" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drbd: use after free in drbd_create_device()

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drbd-use-after-free-in-drbd_create_device.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3d1fbfc435a5d4f281b8352462f58aee252d9442
Author: Dan Carpenter <error27@xxxxxxxxx>
Date:   Tue Nov 15 16:16:43 2022 +0300

    drbd: use after free in drbd_create_device()
    
    [ Upstream commit a7a1598189228b5007369a9622ccdf587be0730f ]
    
    The drbd_destroy_connection() frees the "connection" so use the _safe()
    iterator to prevent a use after free.
    
    Fixes: b6f85ef9538b ("drbd: Iterate over all connections")
    Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
    Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/Y3Jd5iZRbNQ9w6gm@kili
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index 1e02cb60b65b..872e70f5b4d6 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2804,7 +2804,7 @@ static int init_submitter(struct drbd_device *device)
 enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigned int minor)
 {
 	struct drbd_resource *resource = adm_ctx->resource;
-	struct drbd_connection *connection;
+	struct drbd_connection *connection, *n;
 	struct drbd_device *device;
 	struct drbd_peer_device *peer_device, *tmp_peer_device;
 	struct gendisk *disk;
@@ -2933,7 +2933,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
 out_idr_remove_vol:
 	idr_remove(&connection->peer_devices, vnr);
 out_idr_remove_from_resource:
-	for_each_connection(connection, resource) {
+	for_each_connection_safe(connection, n, resource) {
 		peer_device = idr_remove(&connection->peer_devices, vnr);
 		if (peer_device)
 			kref_put(&connection->kref, drbd_destroy_connection);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux