2021-11-01 09:15:02

by Yu Kuai

[permalink] [raw]
Subject: [PATCH] nbd: error out if socket index doesn't match in nbd_handle_reply()

commit fcf3d633d8e1 ("nbd: check sock index in nbd_read_stat()") just
add error message when socket index doesn't match. Since the request
and reply must be transmitted over the same socket, it's ok to error
out in such situation.

Signed-off-by: Yu Kuai <[email protected]>
---
drivers/block/nbd.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b47b2a87ae8f..18da6385645c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -755,6 +755,8 @@ static struct nbd_cmd *nbd_handle_reply(struct nbd_device *nbd, int index,
if (cmd->index != index) {
dev_err(disk_to_dev(nbd->disk), "Unexpected reply %d from different sock %d (expected %d)",
tag, index, cmd->index);
+ ret = -ENOENT;
+ goto out;
}
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",
--
2.31.1


2021-11-01 22:24:53

by Josef Bacik

[permalink] [raw]
Subject: Re: [PATCH] nbd: error out if socket index doesn't match in nbd_handle_reply()

On Mon, Nov 01, 2021 at 05:25:38PM +0800, Yu Kuai wrote:
> commit fcf3d633d8e1 ("nbd: check sock index in nbd_read_stat()") just
> add error message when socket index doesn't match. Since the request
> and reply must be transmitted over the same socket, it's ok to error
> out in such situation.
>
> Signed-off-by: Yu Kuai <[email protected]>

Reviewed-by: Josef Bacik <[email protected]>

Thanks,

Josef

2021-11-02 20:46:30

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH] nbd: error out if socket index doesn't match in nbd_handle_reply()

On Mon, 1 Nov 2021 17:25:38 +0800, Yu Kuai wrote:
> commit fcf3d633d8e1 ("nbd: check sock index in nbd_read_stat()") just
> add error message when socket index doesn't match. Since the request
> and reply must be transmitted over the same socket, it's ok to error
> out in such situation.
>
>

Applied, thanks!

[1/1] nbd: error out if socket index doesn't match in nbd_handle_reply()
commit: 494dbee341e7a02529ce776ee9a5e0b7733ca280

Best regards,
--
Jens Axboe