Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1216846pxb; Thu, 16 Sep 2021 02:25:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztq+36+vtgdi2yWKXrpDIjd/w5ms5S4Os0OL8YmqiKovu/PU0gamMufsMqFhQDW2hhZrqf X-Received: by 2002:a17:906:fc7:: with SMTP id c7mr5214219ejk.333.1631784352670; Thu, 16 Sep 2021 02:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631784352; cv=none; d=google.com; s=arc-20160816; b=mQBc/7geRv+m/Nl0UwBP/U+52MYctu4hWGG8Q3ighOwrWyfwlpLlcVwmuFmv2/Kj1W Yl1wy0CaBTUDADqqlgKXSYGQ3nBpYDY1mRuALTpbAaopKpEYaXSKGG47KUzWbKAPwHcR nSMqPDeQ/vZ+RKpMp44b0I0U9Wdg+hlqTruJDG2XSLIUH55Iv4moZc9Hz6WFIlTgBSP4 W9BuD9tpMkonx6zTKhnL/Zhe5sB/alBVuB7ic/sDfKcPo+ZO2+wRDGNj4fgqA3yN23f2 IAIpsiXkLExak07ypudmsgUMPI5WDgrFrUS0ysbng3++ffZsyhEKdgQkqebOVNBhJQ13 3otA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Gl+/TOo56h2zAb2YwUkpxU/SMwcF/ck3gRqrWxcsBjU=; b=YZiOGySp77WM4Q75DdtADt1brMf+VhQTwd0fVgk4wEiqfJXroSuZOsOnI3Dh3a0N6C XjNlF/Nt9lzdiKrUYRjkSC0wlBqLykOlk2iFUaHwyrwoK24FxJy5MFIhQNCGKzyKq1oM +08MTZ86mcW3mAL2KBtKUmHl0Bsq1a9mfCt6h8It8ttBj4yjJZCwhC2LzaRVW2lXVRTH gRaC1I5iQL7CHZxwUzDHCD0zGj/3fpVeYAgkYv4c1N+W5mokxUp6Tjr1Ad35nS8idAvY Wmnbzj8YPe4BRLuVYh2wO/lz7qrpEY/dhWo0CTBZqDqS5L6yw7HPoR5EYGwTa0mRsUte U1pQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z18si2719310edq.553.2021.09.16.02.25.27; Thu, 16 Sep 2021 02:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235493AbhIPJZ0 (ORCPT + 99 others); Thu, 16 Sep 2021 05:25:26 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:15425 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235355AbhIPJZZ (ORCPT ); Thu, 16 Sep 2021 05:25:25 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4H9BPS4YxczRDQN; Thu, 16 Sep 2021 17:19:56 +0800 (CST) Received: from dggema762-chm.china.huawei.com (10.1.198.204) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.8; Thu, 16 Sep 2021 17:24:03 +0800 Received: from huawei.com (10.175.127.227) by dggema762-chm.china.huawei.com (10.1.198.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Thu, 16 Sep 2021 17:24:03 +0800 From: Yu Kuai To: , , , CC: , , , , Subject: [patch v8 3/7] nbd: check sock index in nbd_read_stat() Date: Thu, 16 Sep 2021 17:33:46 +0800 Message-ID: <20210916093350.1410403-4-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210916093350.1410403-1-yukuai3@huawei.com> References: <20210916093350.1410403-1-yukuai3@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggema762-chm.china.huawei.com (10.1.198.204) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/block/nbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 614c6ab2b8fe..c724a5bd7fa4 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -746,6 +746,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)); -- 2.31.1