Commit ae4d37b
drbd: fix an invalid memory access caused by incorrect use of list iterator
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@vger.kernel.org
Fixes: c06ece6 ("drbd: Turn connection->volumes into connection->peer_devices")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Reviewed-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent aadb22b commit ae4d37b
1 file changed
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2773 | 2773 | | |
2774 | 2774 | | |
2775 | 2775 | | |
2776 | | - | |
| 2776 | + | |
2777 | 2777 | | |
2778 | 2778 | | |
2779 | 2779 | | |
2780 | 2780 | | |
2781 | | - | |
| 2781 | + | |
2782 | 2782 | | |
2783 | 2783 | | |
2784 | 2784 | | |
| |||
2792 | 2792 | | |
2793 | 2793 | | |
2794 | 2794 | | |
2795 | | - | |
2796 | | - | |
2797 | 2795 | | |
2798 | 2796 | | |
2799 | 2797 | | |
| |||
0 commit comments