+2
−5
Loading
In the following sequence there will be a use-after-free problem in spdk_for_each_channel: 1. I/O channel of device D on thread T is obtained and assigned to i->ch in spdk_for_each_channel or spdk_for_each_channel_continue. 2. The I/O channel is destroyed. 3. A new I/O channel of device D on thread T is created. 4. _call_channel is called on thread T, i->fn is called because there is an I/O channel of device D on thread T. However, the I/O channel that i->ch points to has been freed. To fix this, we assign i->ch in _call_channel instead of spdk_for_each_channel and spdk_for_each_channel_continue, so that we can always get the correct I/O channel. Change-Id: I6d43a3e3842874327d2ac02085c1571283bd787d Signed-off-by:Jinlong Chen <chenjinlong.cjl@alibaba-inc.com> Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26231 Tested-by:
SPDK Automated Test System <spdkbot@gmail.com> Reviewed-by:
Jim Harris <jim.harris@nvidia.com> Reviewed-by:
Shuhei Matsumoto <smatsumoto@nvidia.com>