Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2810482pxb; Mon, 1 Nov 2021 02:15:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhgJm0+RcS8L2ipO/ad6Kwndw99PDwSVLYKrIcPvxt4Pw1GgSSYhY0fxV+aOlYRB77K2Hu X-Received: by 2002:a50:d4d1:: with SMTP id e17mr39271349edj.348.1635758102525; Mon, 01 Nov 2021 02:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635758102; cv=none; d=google.com; s=arc-20160816; b=l7KqoDYI8y/hSAT3Qer/1Ur477C8qNcufd5NPviNEVFgPjvCBiS31LLg/KBiRrX3eW dX6yzfsk4u+SRsDQ/qPJZnQVRREFUGs25IbEGJ1p/JSGC6XEaAR6K5UF+sKLntPaaOtD kKCJ2ur885tbNZLWoltKrae59ez5d3GIGx11riqbafvir2hheEkRT4z59ar+pMvEouOU zNX8dGW9XxdmesDzGzK9ZN58tIZC6T1kNOncX8ZGkHuI0dHeXlMy4OvrbSv/CeNH5GwG GGQ3ktg7phfYzuJJlekxlwkVIOxc/Kty9EXonPQxWBMMky9RAkj/8vE23pKJCfdeG5Fm wI6w== 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 :message-id:date:subject:cc:to:from; bh=sohE0ujRYKVeiU+be17Nr602RJiJvo16S86Ramp2JDQ=; b=f18Ms8rOF46tSqR+HsvL7IPsq0GL97y+wwMLwSqVmktE93ggJyj5FpNgVpA8JWKhSn a4G2auYF7hmVquAmdkyaExWPoDVtgC1P8Q2zET7FX4nwFpMmPrZuV0X+cBdTurnK7hjF ItDAlgyRRwCng6Z1a+PUL+rmGsXCSB83Qm9Ri3PbUwjxKGbMiJSemhQ7MdsW3ndzzgpZ DouIS98PqKmfiqZjHz24kjRTg0FtDWW0KodH5TVUF0VkFLt56D1+fbP4PcoHTGSS8zDS uftmSig5JGtjjjSA1iFAoqR7PmkofA0P2oTTOh2g7nhvMvCaNP58RXUhfe8kHBwyjUhi yBeA== 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 hc38si1149127ejc.749.2021.11.01.02.14.38; Mon, 01 Nov 2021 02:15:02 -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 S231485AbhKAJP0 (ORCPT + 99 others); Mon, 1 Nov 2021 05:15:26 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:25332 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231223AbhKAJPZ (ORCPT ); Mon, 1 Nov 2021 05:15:25 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HjRyb5T44zbcwY; Mon, 1 Nov 2021 17:08:07 +0800 (CST) Received: from kwepemm600009.china.huawei.com (7.193.23.164) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Mon, 1 Nov 2021 17:12:50 +0800 Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Mon, 1 Nov 2021 17:12:49 +0800 From: Yu Kuai To: , CC: , , , , Subject: [PATCH] nbd: error out if socket index doesn't match in nbd_handle_reply() Date: Mon, 1 Nov 2021 17:25:38 +0800 Message-ID: <20211101092538.1155842-1-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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