Patch "drbd: fix an invalid memory access caused by incorrect use of list iterator" has been added to the 5.10-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: fix an invalid memory access caused by incorrect use of list iterator

to the 5.10-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-fix-an-invalid-memory-access-caused-by-incorrec.patch
and it can be found in the queue-5.10 subdirectory.

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



commit 36b098452669221592e7d44f8172f4fb57ff2367
Author: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
Date:   Wed Apr 6 21:04:44 2022 +0200

    drbd: fix an invalid memory access caused by incorrect use of list iterator
    
    [ Upstream commit ae4d37b5df749926891583d42a6801b5da11e3c1 ]
    
    The bug is here:
            idr_remove(&connection->peer_devices, vnr);
    
    If the previous for_each_connection() don't exit early (no goto hit
    inside the loop), the iterator 'connection' after the loop will be a
    bogus pointer to an invalid structure object containing the HEAD
    (&resource->connections). As a result, the use of 'connection' above
    will lead to a invalid memory access (including a possible invalid free
    as idr_remove could call free_layer).
    
    The original intention should have been to remove all peer_devices,
    but the following lines have already done the work. So just remove
    this line and the unneeded label, to fix this bug.
    
    Cc: stable@xxxxxxxxxxxxxxx
    Fixes: c06ece6ba6f1b ("drbd: Turn connection->volumes into connection->peer_devices")
    Signed-off-by: Xiaomeng Tong <xiam0nd.tong@xxxxxxxxx>
    Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@xxxxxxxxxx>
    Reviewed-by: Lars Ellenberg <lars.ellenberg@xxxxxxxxxx>
    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 51450f7c81af..420bdaf8c356 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -2819,7 +2819,7 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
 
 	if (init_submitter(device)) {
 		err = ERR_NOMEM;
-		goto out_idr_remove_vol;
+		goto out_idr_remove_from_resource;
 	}
 
 	add_disk(disk);
@@ -2836,8 +2836,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
 	drbd_debugfs_device_add(device);
 	return NO_ERROR;
 
-out_idr_remove_vol:
-	idr_remove(&connection->peer_devices, vnr);
 out_idr_remove_from_resource:
 	for_each_connection_safe(connection, n, resource) {
 		peer_device = idr_remove(&connection->peer_devices, vnr);



[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