aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Kuai <[email protected]>2021-09-16 17:33:46 +0800
committerJens Axboe <[email protected]>2021-10-18 14:50:37 -0600
commitfcf3d633d8e101e84a0e072ab79957b938ac7e06 (patch)
tree0d88bf8b4ff410dfa31e98dbd9bec444232b622e
parent07175cb1baf4c51051b1fbd391097e349f9a02a9 (diff)
nbd: check sock index in nbd_read_stat()
The sock that clent send request in nbd_send_cmd() and receive reply in nbd_read_stat() should be the same. Signed-off-by: Yu Kuai <[email protected]> Reviewed-by: Ming Lei <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r--drivers/block/nbd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 0bb3c1e2d575..49c501cf8a8b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -751,6 +751,10 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
ret = -ENOENT;
goto out;
}
+ if (cmd->index != index) {
+ dev_err(disk_to_dev(nbd->disk), "Unexpected reply %d from different sock %d (expected %d)",
+ tag, index, cmd->index);
+ }
if (cmd->cmd_cookie != nbd_handle_to_cookie(handle)) {
dev_err(disk_to_dev(nbd->disk), "Double reply on req %p, cmd_cookie %u, handle cookie %u\n",
req, cmd->cmd_cookie, nbd_handle_to_cookie(handle));